From 4a1170855aecc597864487e656d1ba564b48e7c9 Mon Sep 17 00:00:00 2001 From: Jan M Date: Thu, 5 Oct 2017 10:53:19 +0200 Subject: [PATCH] Adding '_' to allowed chars. --- pkg/cluster/cluster.go | 1 + pkg/cluster/pg.go | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index 6fb2b7eee..9d6d3701d 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -31,6 +31,7 @@ import ( var ( alphaNumericRegexp = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]*$") + databaseNameRegexp = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9_]*$") userRegexp = regexp.MustCompile(`^[a-z0-9]([-_a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-_a-z0-9]*[a-z0-9])?)*$`) ) diff --git a/pkg/cluster/pg.go b/pkg/cluster/pg.go index d7e5a9b0a..7f421573f 100644 --- a/pkg/cluster/pg.go +++ b/pkg/cluster/pg.go @@ -165,21 +165,21 @@ func (c *Cluster) createDatabases() error { } if err := c.initDbConn(); err != nil { - return fmt.Errorf("could not init db connection") + return fmt.Errorf("could not init database connection") } defer func() { if err := c.closeDbConn(); err != nil { - c.logger.Errorf("could not close db connection: %v", err) + c.logger.Errorf("could not close database connection: %v", err) } }() for datname, owner := range newDbs { if _, ok := c.pgUsers[owner]; !ok { - c.logger.Infof("skipping creationg of the %q database, user %q does not exist", datname, owner) + c.logger.Infof("skipping creation of the %q database, user %q does not exist", datname, owner) continue } - if !alphaNumericRegexp.MatchString(datname) { + if !databaseNameRegexp.MatchString(datname) { c.logger.Infof("database %q has invalid name", datname) continue }