Error when domain is too long for secret lengths.
This commit is contained in:
parent
82bcaaa86f
commit
cacf512cde
|
@ -2,6 +2,7 @@ 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"
|
||||||
|
@ -125,6 +126,10 @@ var appNewCommand = cli.Command{
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := ensureSecretLengths(secrets, internal.Domain); err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
secretCols := []string{"Name", "Value"}
|
secretCols := []string{"Name", "Value"}
|
||||||
secretTable = formatter.CreateTable(secretCols)
|
secretTable = formatter.CreateTable(secretCols)
|
||||||
for name, val := range secrets {
|
for name, val := range secrets {
|
||||||
|
@ -256,3 +261,21 @@ func ensureServerFlag() error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ensureSecretLengths(secrets AppSecrets, domain string) error {
|
||||||
|
domainLength := len(domain)
|
||||||
|
failingSecrets := []string{}
|
||||||
|
|
||||||
|
for secretName := range secrets {
|
||||||
|
if len(secretName)+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 nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue