fix: add warning for long secret names #359
|
@ -2,7 +2,6 @@ package app
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
|
@ -268,29 +267,12 @@ func ensureSecretLengths(secrets map[string]string, domainName string, sanitised
|
|||
}
|
||||
|
||||
domainAndFormatLength := len(sanitisedAppName) + 4
|
||||
failingSecrets := []string{}
|
||||
maxSecretLength := 0
|
||||
|
||||
for secretName := range secrets {
|
||||
|
||||
if len(secretName) > maxSecretLength {
|
||||
maxSecretLength = len(secretName)
|
||||
}
|
||||
|
||||
if len(secretName)+domainAndFormatLength > 64 {
|
||||
failingSecrets = append(failingSecrets, secretName)
|
||||
return fmt.Errorf("%s is too long (> 64 chars when combined with %s)", secretName, sanitisedAppName)
|
||||
}
|
||||
}
|
||||
decentral1se marked this conversation as resolved
Outdated
|
||||
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
nitpick: drop extra newline?
Think I've got this one now but let me know if I misinterpreted which line you were talking about : )