mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 14:26:23 -04:00
Allow unset 'name' key but print warning if unset (#1208)
* Allow unset name key in config but print warning if unset * Print deprecation warnings for config to os.Stderr --------- Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
d90828cb3c
commit
f70447bf7d
3 changed files with 13 additions and 4 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -384,7 +385,7 @@ func validateUpgradeConfig(sl validator.StructLevel) {
|
|||
if config.Image == "" && config.CSP == cloudprovider.Unknown && config.Measurements == nil {
|
||||
return
|
||||
}
|
||||
fmt.Println("WARNING: the config key `upgrade` will be deprecated in an upcoming version. Please check the documentation for more information.")
|
||||
fmt.Fprintln(os.Stderr, "WARNING: the config key `upgrade` will be deprecated in an upcoming version. Please check the documentation for more information.")
|
||||
}
|
||||
|
||||
func registerValidateNameError(ut ut.Translator) error {
|
||||
|
@ -406,6 +407,12 @@ func (c *Config) translateValidateNameError(ut ut.Translator, fe validator.Field
|
|||
// 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 {
|
||||
// TODO: v2.7: remove fallback to defaultName and make name a required field
|
||||
if c.Name == "" {
|
||||
fmt.Fprintln(os.Stderr, "WARNING: the config key `name` is not set. This key will be required in the next version. Falling back to default name.")
|
||||
c.Name = defaultName
|
||||
}
|
||||
|
||||
if c.Provider.AWS != nil {
|
||||
return len(fl.Field().String()) <= constants.AWSConstellationNameLength
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue