feat: handle generate=false env var mod

See toolshed/organising#461
This commit is contained in:
2025-08-19 00:09:18 +02:00
parent 6fad1a1dcc
commit 868ab217a5

View File

@ -37,6 +37,9 @@ type Secret struct {
// variable. For Example:
// SECRET_FOO=v1 # charset=default,special
Charset string
// Whether or not to skip generation of the secret or not
// For example: SECRET_FOO=v1 # generate=false
SkipGenerate bool
// RemoteName is the name of the secret on the server. For example:
// name: ${STACK_NAME}_test_pass_two_${SECRET_TEST_PASS_TWO_VERSION}
// With the following:
@ -155,6 +158,13 @@ func ReadSecretsConfig(appEnvPath string, composeFiles []string, stackName strin
value.Length = length
}
generateRaw, ok := modifierValues["generate"]
if ok {
if generateRaw == "true" {
value.SkipGenerate = true
}
}
value.Charset = resolveCharset(modifierValues["charset"])
break
}
@ -192,6 +202,12 @@ func GenerateSecrets(cl *dockerClient.Client, secrets map[string]Secret, server
go func(secretName string, secret Secret) {
defer wg.Done()
if secret.SkipGenerate {
log.Debugf("skipping generation of %s (generate=false)", secretName)
ch <- nil
return
}
log.Debugf("attempting to generate and store %s on %s", secret.RemoteName, server)
if secret.Length > 0 {