refactor(be): move consts to func

This commit is contained in:
fiftin 2024-05-21 13:39:51 +02:00
parent 300f5c230e
commit a07e4bd69d
No known key found for this signature in database
GPG Key ID: 044381366A5D4731
2 changed files with 13 additions and 11 deletions

View File

@ -31,18 +31,8 @@ func (p AnsiblePlaybook) makeCmd(command string, args []string, environmentVars
cmd.Env = append(cmd.Env, *environmentVars...) cmd.Env = append(cmd.Env, *environmentVars...)
} }
sensitiveEnvs := []string{
"SEMAPHORE_ACCESS_KEY_ENCRYPTION",
"SEMAPHORE_ADMIN_PASSWORD",
"SEMAPHORE_DB_USER",
"SEMAPHORE_DB_NAME",
"SEMAPHORE_DB_HOST",
"SEMAPHORE_DB_PASS",
"SEMAPHORE_LDAP_PASSWORD",
}
// Remove sensitive env variables from cmd process // Remove sensitive env variables from cmd process
for _, env := range sensitiveEnvs { for _, env := range getSensitiveEnvs() {
cmd.Env = append(cmd.Env, env+"=") cmd.Env = append(cmd.Env, env+"=")
} }

View File

@ -6,6 +6,18 @@ import (
"github.com/ansible-semaphore/semaphore/pkg/task_logger" "github.com/ansible-semaphore/semaphore/pkg/task_logger"
) )
func getSensitiveEnvs() []string {
return []string{
"SEMAPHORE_ACCESS_KEY_ENCRYPTION",
"SEMAPHORE_ADMIN_PASSWORD",
"SEMAPHORE_DB_USER",
"SEMAPHORE_DB_NAME",
"SEMAPHORE_DB_HOST",
"SEMAPHORE_DB_PASS",
"SEMAPHORE_LDAP_PASSWORD",
}
}
type LocalApp interface { type LocalApp interface {
SetLogger(logger task_logger.Logger) task_logger.Logger SetLogger(logger task_logger.Logger) task_logger.Logger
InstallRequirements() error InstallRequirements() error