mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 06:16:08 -04:00
init: create kubeconfig file with unique user/cluster name (#1133)
* Generate kubeconfig with unique name * Move create name flag to config * Add name validation to config * Move name flag in e2e tests to config generation * Remove name flag from create * Update ascii cinema flow --------- Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
fd860ddb91
commit
c29107f5be
29 changed files with 359 additions and 436 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
||||
|
@ -366,3 +367,28 @@ func returnsTrue(fl validator.FieldLevel) bool {
|
|||
func validateUpgradeConfig(sl validator.StructLevel) {
|
||||
fmt.Printf("WARNING: the config key `upgrade` will be deprecated in an upcoming version. Please check the documentation for more information.\n")
|
||||
}
|
||||
|
||||
func registerValidateNameError(ut ut.Translator) error {
|
||||
return ut.Add("validate_name", "{0} must be no more than {1} characters long", true)
|
||||
}
|
||||
|
||||
func (c *Config) translateValidateNameError(ut ut.Translator, fe validator.FieldError) string {
|
||||
var t string
|
||||
if c.Provider.AWS != nil {
|
||||
t, _ = ut.T("validate_name", fe.Field(), strconv.Itoa(constants.AWSConstellationNameLength))
|
||||
} else {
|
||||
t, _ = ut.T("validate_name", fe.Field(), strconv.Itoa(constants.ConstellationNameLength))
|
||||
}
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
// validateName makes sure the name of the constellation is not too long.
|
||||
// Since this value may differ between providers, we can't simply use built-in validation.
|
||||
// This also allows us to eventually add more validation rules for constellation names if necessary.
|
||||
func (c *Config) validateName(fl validator.FieldLevel) bool {
|
||||
if c.Provider.AWS != nil {
|
||||
return len(fl.Field().String()) <= constants.AWSConstellationNameLength
|
||||
}
|
||||
return len(fl.Field().String()) <= constants.ConstellationNameLength
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue