Merge pull request #115 from zalando-incubator/database-name-fix
Adding '_' to allowed chars.
This commit is contained in:
commit
bd9b0b613a
|
|
@ -31,6 +31,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
alphaNumericRegexp = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]*$")
|
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])?)*$`)
|
userRegexp = regexp.MustCompile(`^[a-z0-9]([-_a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-_a-z0-9]*[a-z0-9])?)*$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -165,21 +165,21 @@ func (c *Cluster) createDatabases() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.initDbConn(); err != nil {
|
if err := c.initDbConn(); err != nil {
|
||||||
return fmt.Errorf("could not init db connection")
|
return fmt.Errorf("could not init database connection")
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := c.closeDbConn(); err != nil {
|
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 {
|
for datname, owner := range newDbs {
|
||||||
if _, ok := c.pgUsers[owner]; !ok {
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !alphaNumericRegexp.MatchString(datname) {
|
if !databaseNameRegexp.MatchString(datname) {
|
||||||
c.logger.Infof("database %q has invalid name", datname)
|
c.logger.Infof("database %q has invalid name", datname)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue