Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow environment substitution for more config vars #164

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/github/freno

go 1.17
go 1.20

require (
github.com/DATA-DOG/go-sqlmock v1.5.0
Expand Down
12 changes: 12 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ func (settings *ConfigurationSettings) postReadAdjustments() error {
if submatch := envVariableRegexp.FindStringSubmatch(settings.BackendMySQLPassword); len(submatch) > 1 {
settings.BackendMySQLPassword = os.Getenv(submatch[1])
}
if submatch := envVariableRegexp.FindStringSubmatch(settings.DataCenter); len(submatch) > 1 {
settings.DataCenter = os.Getenv(submatch[1])
}
if submatch := envVariableRegexp.FindStringSubmatch(settings.Environment); len(submatch) > 1 {
settings.Environment = os.Getenv(submatch[1])
}
if submatch := envVariableRegexp.FindStringSubmatch(settings.Domain); len(submatch) > 1 {
settings.Domain = os.Getenv(submatch[1])
}
if submatch := envVariableRegexp.FindStringSubmatch(settings.ShareDomain); len(submatch) > 1 {
settings.ShareDomain = os.Getenv(submatch[1])
}
if settings.RaftDataDir == "" && settings.BackendMySQLHost == "" {
return fmt.Errorf("Either RaftDataDir or BackendMySQLHost must be set")
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/config/mysql_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ func (settings *MySQLConfigurationSettings) postReadAdjustments() error {
settings.Password = os.Getenv(submatch[1])
}

for i := 0; i < len(settings.VitessCells); i++ {
cell := settings.VitessCells[i]
if submatch := envVariableRegexp.FindStringSubmatch(cell); len(submatch) > 1 {
settings.VitessCells[i] = os.Getenv(submatch[1])
}
}

for _, clusterSettings := range settings.Clusters {
if err := clusterSettings.postReadAdjustments(); err != nil {
return err
Expand Down
Loading