fix: add warning for long secret names #359

Merged
decentral1se merged 14 commits from rix/abra:add-secret-length-linting into main 2024-04-06 21:41:37 +00:00
1 changed files with 1 additions and 19 deletions
Showing only changes of commit 2583fe2861 - Show all commits

View File

@ -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

nitpick: drop extra newline?

nitpick: drop extra newline?
Outdated
Review

Think I've got this one now but let me know if I misinterpreted which line you were talking about : )

Think I've got this one now but let me know if I misinterpreted which line you were talking about : )
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
}