Minor updates

This commit is contained in:
TwinProduction 2020-11-20 17:24:56 -05:00
parent 07312794c4
commit 315791151e

View File

@ -73,7 +73,7 @@ type Config struct {
// Kubernetes is the Kubernetes configuration // Kubernetes is the Kubernetes configuration
Kubernetes *k8s.Config `yaml:"kubernetes"` Kubernetes *k8s.Config `yaml:"kubernetes"`
// webConfig is the optional configuration of the web listener providing the frontend UI // Web is the configuration for the web listener
Web *webConfig `yaml:"web"` Web *webConfig `yaml:"web"`
} }
@ -138,18 +138,17 @@ func parseAndValidateConfigBytes(yamlBytes []byte) (config *Config, err error) {
validateSecurityConfig(config) validateSecurityConfig(config)
validateServicesConfig(config) validateServicesConfig(config)
validateKubernetesConfig(config) validateKubernetesConfig(config)
validateAddressAndPortConfig(config) validateWebConfig(config)
} }
return return
} }
func validateAddressAndPortConfig(config *Config) { func validateWebConfig(config *Config) {
if config.Web == nil { if config.Web == nil {
config.Web = &webConfig{Address: DefaultAddress, Port: DefaultPort} config.Web = &webConfig{Address: DefaultAddress, Port: DefaultPort}
} else { } else {
config.Web.validateAndSetDefaults() config.Web.validateAndSetDefaults()
} }
} }
func validateKubernetesConfig(config *Config) { func validateKubernetesConfig(config *Config) {
@ -275,10 +274,9 @@ func (web *webConfig) validateAndSetDefaults() {
if len(web.Address) == 0 { if len(web.Address) == 0 {
web.Address = DefaultAddress web.Address = DefaultAddress
} }
if web.Port == 0 { if web.Port == 0 {
web.Port = DefaultPort web.Port = DefaultPort
} else if web.Port < 0 || web.Port > math.MaxUint16 { } else if web.Port < 0 || web.Port > math.MaxUint16 {
panic(fmt.Sprintf("port has an invalid value %d shoud be between %d - %d\r\n", web.Port, 0, math.MaxUint16)) panic(fmt.Sprintf("port has an invalid: value should be between %d and %d", 0, math.MaxUint16))
} }
} }