Written secret length verification in the wrong place.
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
cacf512cde
commit
6bdec1ccd0
|
@ -126,7 +126,7 @@ var appNewCommand = cli.Command{
|
|||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := ensureSecretLengths(secrets, internal.Domain); err != nil {
|
||||
if err := ensureSecretLengths(secrets, sanitisedAppName); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -262,20 +262,35 @@ func ensureServerFlag() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func ensureSecretLengths(secrets AppSecrets, domain string) error {
|
||||
domainLength := len(domain)
|
||||
func ensureSecretLengths(secrets AppSecrets, sanitisedAppName string) error {
|
||||
if len(sanitisedAppName) > 45 {
|
||||
sanitisedAppName = sanitisedAppName[:45]
|
||||
}
|
||||
|
||||
domainLength := len(sanitisedAppName)
|
||||
failingSecrets := []string{}
|
||||
maxSecretLength := 0
|
||||
|
||||
for secretName := range secrets {
|
||||
if len(secretName)+domainLength > 64 {
|
||||
|
||||
if len(secretName) > maxSecretLength {
|
||||
maxSecretLength = len(secretName)
|
||||
}
|
||||
|
||||
if len(secretName+"_v1")+domainLength > 64 {
|
||||
failingSecrets = append(failingSecrets, secretName)
|
||||
}
|
||||
}
|
||||
|
||||
if len(failingSecrets) > 0 {
|
||||
failedSecretsString := strings.Join(failingSecrets, ", ")
|
||||
return fmt.Errorf("The following secrets are too long to work with the domain name %s, change their length or use a shorter domain name: %s", domain, failedSecretsString)
|
||||
return fmt.Errorf("the following secrets are too long to work with the domain name %s, change their length or use a shorter domain name: %s", sanitisedAppName, 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, domainLength, domainLength+maxSecretLength+4)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue