add comments to better explain how the length modifier gets added to the secret
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
2de6934322
commit
02b726db02
|
@ -78,6 +78,7 @@ func ReadSecretsConfig(appEnvPath string, composeFiles []string, recipeName stri
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Read the compose files without injecting environment variables.
|
||||
configWithoutEnv, err := loader.LoadComposefile(opts, map[string]string{}, loader.SkipInterpolation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -111,12 +112,16 @@ func ReadSecretsConfig(appEnvPath string, composeFiles []string, recipeName stri
|
|||
value := SecretValue{Version: secretVersion}
|
||||
|
||||
// Check if the length modifier is set for this secret.
|
||||
for k, v := range appModifiers {
|
||||
for envName, modifierValues := range appModifiers {
|
||||
// configWithoutEnv contains the raw name as defined in the compose.yaml
|
||||
if !strings.Contains(configWithoutEnv.Secrets[secretId].Name, k) {
|
||||
// The name will look something like this:
|
||||
// name: ${STACK_NAME}_test_pass_two_${SECRET_TEST_PASS_TWO_VERSION}
|
||||
// To check if the current modifier is for the current secret we check
|
||||
// if the raw name contains the env name (e.g. SECRET_TEST_PASS_TWO_VERSION).
|
||||
if !strings.Contains(configWithoutEnv.Secrets[secretId].Name, envName) {
|
||||
continue
|
||||
}
|
||||
lengthRaw, ok := v["length"]
|
||||
lengthRaw, ok := modifierValues["length"]
|
||||
if ok {
|
||||
length, err := strconv.Atoi(lengthRaw)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue