Report error when illegal values are provided for configType and overrideType

This commit is contained in:
Pengfei Ni 2019-05-24 15:52:55 +08:00
parent 9516ade5c4
commit d127ef5a44
2 changed files with 27 additions and 1 deletions

View File

@ -273,6 +273,32 @@ func (az *Cloud) initializeCloudFromConfig(config *Config, fromSecret bool) erro
config.VMType = vmTypeStandard config.VMType = vmTypeStandard
} }
if config.OverrideType == "" {
// The default override type is secretOverrideTypeCan.
config.OverrideType = secretOverrideTypeCan
} else {
supportedOverrideTypes := sets.NewString(
string(secretOverrideTypeCan),
string(secretOverrideTypeMust),
string(secretOverrideTypeNo))
if !supportedOverrideTypes.Has(string(config.OverrideType)) {
return fmt.Errorf("overrideType %v is not supported, supported values are %v", config.OverrideType, supportedOverrideTypes.List())
}
}
if config.ConfigType == "" {
// The default config type is secretConfigureAll.
config.ConfigType = secretConfigureAll
} else {
supportedConfigTypes := sets.NewString(
string(secretConfigureAll),
string(secretConfigureNode),
string(secretConfigureControlPlane))
if !supportedConfigTypes.Has(string(config.ConfigType)) {
return fmt.Errorf("configType %v is not supported, supported values are %v", config.ConfigType, supportedConfigTypes.List())
}
}
env, err := auth.ParseAzureEnvironment(config.Cloud) env, err := auth.ParseAzureEnvironment(config.Cloud)
if err != nil { if err != nil {
return err return err

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2016 The Kubernetes Authors. Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.