provider/postgresql: Quote connection string parameters

This commit is contained in:
Igor Dubinskiy 2016-12-23 00:39:26 -08:00
parent 2d894bae48
commit 56a1ea9012
3 changed files with 5 additions and 4 deletions

View File

@ -4,7 +4,8 @@ PSQL?=/opt/local/lib/postgresql96/bin/psql
PGDATA?=$(GOPATH)/src/github.com/hashicorp/terraform/builtin/providers/postgresql/data
initdb::
/opt/local/lib/postgresql96/bin/initdb --no-locale -U postgres -D $(PGDATA)
echo "" > pwfile
/opt/local/lib/postgresql96/bin/initdb --no-locale -U postgres -A md5 --pwfile=pwfile -D $(PGDATA)
startdb::
2>&1 \
@ -18,6 +19,7 @@ startdb::
cleandb::
rm -rf $(PGDATA)
rm -f pwfile
freshdb:: cleandb initdb startdb

View File

@ -31,7 +31,7 @@ type Client struct {
func (c *Config) NewClient() (*Client, error) {
// NOTE: dbname must come before user otherwise dbname will be set to
// user.
const dsnFmt = "host=%s port=%d dbname=%s user=%s password=%s sslmode=%s fallback_application_name=%s connect_timeout=%d"
const dsnFmt = "host='%s' port='%d' dbname='%s' user='%s' password='%s' sslmode='%s' fallback_application_name='%s' connect_timeout='%d'"
logDSN := fmt.Sprintf(dsnFmt, c.Host, c.Port, c.Database, c.Username, "<redacted>", c.SSLMode, c.ApplicationName, c.ConnectTimeoutSec)
log.Printf("[INFO] PostgreSQL DSN: `%s`", logDSN)

View File

@ -112,11 +112,10 @@ func tfAppName() string {
const VersionPrerelease = terraform.VersionPrerelease
var versionString bytes.Buffer
fmt.Fprintf(&versionString, "'Terraform v%s", terraform.Version)
fmt.Fprintf(&versionString, "Terraform v%s", terraform.Version)
if terraform.VersionPrerelease != "" {
fmt.Fprintf(&versionString, "-%s", terraform.VersionPrerelease)
}
fmt.Fprintf(&versionString, "'")
return versionString.String()
}