Skip to content

Commit

Permalink
Adding '_' to allowed chars.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-M committed Oct 5, 2017
1 parent 48ec6b3 commit 4a11708
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])?)*$`)
)

Expand Down
8 changes: 4 additions & 4 deletions pkg/cluster/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 4a11708

Please sign in to comment.