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

Updated cs components to access pg password from secrets #8723

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
154 changes: 151 additions & 3 deletions api/config/pg_gateway/config_request.pb.a2svc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 21 additions & 5 deletions api/config/shared/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (c *GlobalConfig) Validate() error { // nolint gocyclo
"show",
"userconfig.es_password",
}
execGetPass := exec.Command(getLatestPlatformToolsPath()+"/bin/secrets-helper", args...)
execGetPass := exec.Command(GetLatestPlatformToolsPath()+"/bin/secrets-helper", args...)
getPass, err := execGetPass.Output()
if err != nil || string(getPass) == "" {
cfgErr.AddMissingKey("global.v1.external.elasticsearch.auth.basic_auth.password")
Expand Down Expand Up @@ -314,7 +314,7 @@ func (c *GlobalConfig) Validate() error { // nolint gocyclo
"show",
"userconfig.os_password",
}
execGetPass := exec.Command(getLatestPlatformToolsPath()+"/bin/secrets-helper", args...)
execGetPass := exec.Command(GetLatestPlatformToolsPath()+"/bin/secrets-helper", args...)
getPass, err := execGetPass.Output()
if err != nil || string(getPass) == "" {
cfgErr.AddMissingKey("global.v1.external.opensearch.auth.basic_auth.password")
Expand Down Expand Up @@ -348,7 +348,15 @@ func (c *GlobalConfig) Validate() error { // nolint gocyclo
cfgErr.AddMissingKey("global.v1.external.postgresql.auth.password.superuser.username")
}
if sp == "" {
cfgErr.AddMissingKey("global.v1.external.postgresql.auth.password.superuser.password")
args := []string{
"show",
"userconfig.pg_superuser_password",
}
execGetPass := exec.Command(GetLatestPlatformToolsPath()+"/bin/secrets-helper", args...)
getPass, err := execGetPass.Output()
if err != nil || string(getPass) == "" {
cfgErr.AddMissingKey("global.v1.external.postgresql.auth.password.superuser.password")
}
}

// dbuser username and password
Expand All @@ -358,7 +366,15 @@ func (c *GlobalConfig) Validate() error { // nolint gocyclo
cfgErr.AddMissingKey("global.v1.external.postgresql.auth.password.dbuser.username")
}
if dp == "" {
cfgErr.AddMissingKey("global.v1.external.postgresql.auth.password.dbuser.password")
args := []string{
"show",
"userconfig.pg_dbuser_password",
}
execGetPass := exec.Command(GetLatestPlatformToolsPath()+"/bin/secrets-helper", args...)
getPass, err := execGetPass.Output()
if err != nil || string(getPass) == "" {
cfgErr.AddMissingKey("global.v1.external.postgresql.auth.password.dbuser.password")
}
}
}
}
Expand Down Expand Up @@ -448,7 +464,7 @@ func (c *GlobalConfig) ValidateReDirectSysLogConfig() error {
return nil
}

func getLatestPlatformToolsPath() string {
func GetLatestPlatformToolsPath() string {
cmd, err := exec.Command("/bin/sh", "-c", habPkgPlatformToolsPath).Output()
if err != nil {
fmt.Printf("error %s", err)
Expand Down
120 changes: 120 additions & 0 deletions api/config/shared/global.pb.a2svc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading