-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
36 lines (29 loc) · 982 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package rdsbroker
import (
"errors"
"fmt"
"github.com/AusDTO/pe-rds-broker/utils"
)
type Config struct {
Region string `yaml:"region"`
DBPrefix string `yaml:"db_prefix"`
AllowUserProvisionParameters bool `yaml:"allow_user_provision_parameters"`
AllowUserUpdateParameters bool `yaml:"allow_user_update_parameters"`
AllowUserBindParameters bool `yaml:"allow_user_bind_parameters"`
Catalog Catalog `yaml:"catalog"`
}
func (c Config) Validate() error {
if c.Region == "" {
return errors.New("Must provide a non-empty Region")
}
if c.DBPrefix == "" {
return errors.New("Must provide a non-empty DBPrefix")
}
if !utils.IsSimpleIdentifier(c.DBPrefix) {
return errors.New("DBPrefix must begin with a letter and contain only alphanumeric characters")
}
if err := c.Catalog.Validate(); err != nil {
return fmt.Errorf("Validating Catalog configuration: %s", err)
}
return nil
}