provider/postgres: Correct casing -> PostgreSQL

This commit is contained in:
James Nugent 2016-09-05 15:04:48 -07:00
parent 006ab910b8
commit 34a17d3b46
3 changed files with 30 additions and 29 deletions

View File

@ -22,7 +22,7 @@ type Client struct {
connStr string
}
//NewClient returns new client config
// NewClient returns new client config
func (c *Config) NewClient() (*Client, error) {
connStr := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=postgres sslmode=%s", c.Host, c.Port, c.Username, c.Password, c.SslMode)
@ -34,11 +34,12 @@ func (c *Config) NewClient() (*Client, error) {
return &client, nil
}
//Connect will manually connect/diconnect to prevent a large number or db connections being made
// Connect will manually connect/disconnect to prevent a large
// number or db connections being made
func (c *Client) Connect() (*sql.DB, error) {
db, err := sql.Open("postgres", c.connStr)
if err != nil {
return nil, fmt.Errorf("Error connecting to postgresql server: %s", err)
return nil, fmt.Errorf("Error connecting to PostgreSQL server: %s", err)
}
return db, nil

View File

@ -10,12 +10,12 @@ import (
"github.com/lib/pq"
)
func resourcePostgresqlDatabase() *schema.Resource {
func resourcePostgreSQLDatabase() *schema.Resource {
return &schema.Resource{
Create: resourcePostgresqlDatabaseCreate,
Read: resourcePostgresqlDatabaseRead,
Update: resourcePostgresqlDatabaseUpdate,
Delete: resourcePostgresqlDatabaseDelete,
Create: resourcePostgreSQLDatabaseCreate,
Read: resourcePostgreSQLDatabaseRead,
Update: resourcePostgreSQLDatabaseUpdate,
Delete: resourcePostgreSQLDatabaseDelete,
Schema: map[string]*schema.Schema{
"name": {
@ -33,7 +33,7 @@ func resourcePostgresqlDatabase() *schema.Resource {
}
}
func resourcePostgresqlDatabaseCreate(d *schema.ResourceData, meta interface{}) error {
func resourcePostgreSQLDatabaseCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Client)
conn, err := client.Connect()
if err != nil {
@ -61,15 +61,15 @@ func resourcePostgresqlDatabaseCreate(d *schema.ResourceData, meta interface{})
query := fmt.Sprintf("CREATE DATABASE %s %s", pq.QuoteIdentifier(dbName), dbOwnerCfg)
_, err = conn.Query(query)
if err != nil {
return errwrap.Wrapf(fmt.Sprintf("Error creating postgresql database %s: {{err}}", dbName), err)
return errwrap.Wrapf(fmt.Sprintf("Error creating database %s: {{err}}", dbName), err)
}
d.SetId(dbName)
return resourcePostgresqlDatabaseRead(d, meta)
return resourcePostgreSQLDatabaseRead(d, meta)
}
func resourcePostgresqlDatabaseDelete(d *schema.ResourceData, meta interface{}) error {
func resourcePostgreSQLDatabaseDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Client)
conn, err := client.Connect()
if err != nil {
@ -97,7 +97,7 @@ func resourcePostgresqlDatabaseDelete(d *schema.ResourceData, meta interface{})
return nil
}
func resourcePostgresqlDatabaseRead(d *schema.ResourceData, meta interface{}) error {
func resourcePostgreSQLDatabaseRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Client)
conn, err := client.Connect()
if err != nil {
@ -114,14 +114,14 @@ func resourcePostgresqlDatabaseRead(d *schema.ResourceData, meta interface{}) er
d.SetId("")
return nil
case err != nil:
return errwrap.Wrapf("Error reading info about database: {{err}}", err)
return errwrap.Wrapf("Error reading database: {{err}}", err)
default:
d.Set("owner", owner)
return nil
}
}
func resourcePostgresqlDatabaseUpdate(d *schema.ResourceData, meta interface{}) error {
func resourcePostgreSQLDatabaseUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Client)
conn, err := client.Connect()
if err != nil {
@ -137,12 +137,12 @@ func resourcePostgresqlDatabaseUpdate(d *schema.ResourceData, meta interface{})
query := fmt.Sprintf("ALTER DATABASE %s OWNER TO %s", pq.QuoteIdentifier(dbName), pq.QuoteIdentifier(owner))
_, err := conn.Query(query)
if err != nil {
return errwrap.Wrapf("Error updating owner for database: {{err}}", err)
return errwrap.Wrapf("Error updating owner: {{err}}", err)
}
}
}
return resourcePostgresqlDatabaseRead(d, meta)
return resourcePostgreSQLDatabaseRead(d, meta)
}
func grantRoleMembership(conn *sql.DB, dbOwner string, connUsername string) error {

View File

@ -9,12 +9,12 @@ import (
"github.com/lib/pq"
)
func resourcePostgresqlRole() *schema.Resource {
func resourcePostgreSQLRole() *schema.Resource {
return &schema.Resource{
Create: resourcePostgresqlRoleCreate,
Read: resourcePostgresqlRoleRead,
Update: resourcePostgresqlRoleUpdate,
Delete: resourcePostgresqlRoleDelete,
Create: resourcePostgreSQLRoleCreate,
Read: resourcePostgreSQLRoleRead,
Update: resourcePostgreSQLRoleUpdate,
Delete: resourcePostgreSQLRoleDelete,
Schema: map[string]*schema.Schema{
"name": {
@ -43,7 +43,7 @@ func resourcePostgresqlRole() *schema.Resource {
}
}
func resourcePostgresqlRoleCreate(d *schema.ResourceData, meta interface{}) error {
func resourcePostgreSQLRoleCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Client)
conn, err := client.Connect()
if err != nil {
@ -65,10 +65,10 @@ func resourcePostgresqlRoleCreate(d *schema.ResourceData, meta interface{}) erro
d.SetId(roleName)
return resourcePostgresqlRoleRead(d, meta)
return resourcePostgreSQLRoleRead(d, meta)
}
func resourcePostgresqlRoleDelete(d *schema.ResourceData, meta interface{}) error {
func resourcePostgreSQLRoleDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Client)
conn, err := client.Connect()
if err != nil {
@ -89,7 +89,7 @@ func resourcePostgresqlRoleDelete(d *schema.ResourceData, meta interface{}) erro
return nil
}
func resourcePostgresqlRoleRead(d *schema.ResourceData, meta interface{}) error {
func resourcePostgreSQLRoleRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Client)
conn, err := client.Connect()
if err != nil {
@ -100,7 +100,7 @@ func resourcePostgresqlRoleRead(d *schema.ResourceData, meta interface{}) error
roleName := d.Get("name").(string)
var canLogin bool
err = conn.QueryRow("select rolcanlogin from pg_roles where rolname=$1", roleName).Scan(&canLogin)
err = conn.QueryRow("SELECT rolcanlogin FROM pg_roles WHERE rolname=$1", roleName).Scan(&canLogin)
switch {
case err == sql.ErrNoRows:
d.SetId("")
@ -113,7 +113,7 @@ func resourcePostgresqlRoleRead(d *schema.ResourceData, meta interface{}) error
}
}
func resourcePostgresqlRoleUpdate(d *schema.ResourceData, meta interface{}) error {
func resourcePostgreSQLRoleUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Client)
conn, err := client.Connect()
if err != nil {
@ -162,7 +162,7 @@ func resourcePostgresqlRoleUpdate(d *schema.ResourceData, meta interface{}) erro
}
d.Partial(false)
return resourcePostgresqlRoleRead(d, meta)
return resourcePostgreSQLRoleRead(d, meta)
}
func getLoginStr(canLogin bool) string {