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

@ -34,11 +34,12 @@ func (c *Config) NewClient() (*Client, error) {
return &client, nil 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) { func (c *Client) Connect() (*sql.DB, error) {
db, err := sql.Open("postgres", c.connStr) db, err := sql.Open("postgres", c.connStr)
if err != nil { 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 return db, nil

View File

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

View File

@ -9,12 +9,12 @@ import (
"github.com/lib/pq" "github.com/lib/pq"
) )
func resourcePostgresqlRole() *schema.Resource { func resourcePostgreSQLRole() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
Create: resourcePostgresqlRoleCreate, Create: resourcePostgreSQLRoleCreate,
Read: resourcePostgresqlRoleRead, Read: resourcePostgreSQLRoleRead,
Update: resourcePostgresqlRoleUpdate, Update: resourcePostgreSQLRoleUpdate,
Delete: resourcePostgresqlRoleDelete, Delete: resourcePostgreSQLRoleDelete,
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": { "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) client := meta.(*Client)
conn, err := client.Connect() conn, err := client.Connect()
if err != nil { if err != nil {
@ -65,10 +65,10 @@ func resourcePostgresqlRoleCreate(d *schema.ResourceData, meta interface{}) erro
d.SetId(roleName) 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) client := meta.(*Client)
conn, err := client.Connect() conn, err := client.Connect()
if err != nil { if err != nil {
@ -89,7 +89,7 @@ func resourcePostgresqlRoleDelete(d *schema.ResourceData, meta interface{}) erro
return nil return nil
} }
func resourcePostgresqlRoleRead(d *schema.ResourceData, meta interface{}) error { func resourcePostgreSQLRoleRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Client) client := meta.(*Client)
conn, err := client.Connect() conn, err := client.Connect()
if err != nil { if err != nil {
@ -100,7 +100,7 @@ func resourcePostgresqlRoleRead(d *schema.ResourceData, meta interface{}) error
roleName := d.Get("name").(string) roleName := d.Get("name").(string)
var canLogin bool 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 { switch {
case err == sql.ErrNoRows: case err == sql.ErrNoRows:
d.SetId("") 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) client := meta.(*Client)
conn, err := client.Connect() conn, err := client.Connect()
if err != nil { if err != nil {
@ -162,7 +162,7 @@ func resourcePostgresqlRoleUpdate(d *schema.ResourceData, meta interface{}) erro
} }
d.Partial(false) d.Partial(false)
return resourcePostgresqlRoleRead(d, meta) return resourcePostgreSQLRoleRead(d, meta)
} }
func getLoginStr(canLogin bool) string { func getLoginStr(canLogin bool) string {