Drop debug logging and fail on first secret that is too long.
This commit is contained in:
parent
d78abfec2f
commit
2583fe2861
|
@ -2,7 +2,6 @@ package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"coopcloud.tech/abra/cli/internal"
|
"coopcloud.tech/abra/cli/internal"
|
||||||
"coopcloud.tech/abra/pkg/autocomplete"
|
"coopcloud.tech/abra/pkg/autocomplete"
|
||||||
|
@ -268,29 +267,12 @@ func ensureSecretLengths(secrets map[string]string, domainName string, sanitised
|
||||||
}
|
}
|
||||||
|
|
||||||
domainAndFormatLength := len(sanitisedAppName) + 4
|
domainAndFormatLength := len(sanitisedAppName) + 4
|
||||||
failingSecrets := []string{}
|
|
||||||
maxSecretLength := 0
|
|
||||||
|
|
||||||
for secretName := range secrets {
|
for secretName := range secrets {
|
||||||
|
|
||||||
if len(secretName) > maxSecretLength {
|
|
||||||
maxSecretLength = len(secretName)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(secretName)+domainAndFormatLength > 64 {
|
if len(secretName)+domainAndFormatLength > 64 {
|
||||||
failingSecrets = append(failingSecrets, secretName)
|
return fmt.Errorf("%s is too long (> 64 chars when combined with %s)", secretName, sanitisedAppName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(failingSecrets) > 0 {
|
|
||||||
failedSecretsString := strings.Join(failingSecrets, ", ")
|
|
||||||
return fmt.Errorf("the following secrets are too long to work with the domain name %s\n change their length or use a shorter domain name:\n %s", domainName, failedSecretsString)
|
|
||||||
}
|
|
||||||
|
|
||||||
logrus.Debugf(
|
|
||||||
`The longest secret name is %d
|
|
||||||
including 4 extra characters for format %s_<name>_v1
|
|
||||||
fits with domain length of %d for max docker secret length of %d`,
|
|
||||||
maxSecretLength, sanitisedAppName, domainAndFormatLength, domainAndFormatLength+maxSecretLength)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue