mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-07 01:56:57 +02:00
* Graceful handling of misconfigure password for dyn If a bad password is given for provider "dyn" then the next login attempt is at least 30minutes apart. This prevents an account from being suspended. Improve validation of flags for dyn provider. Add test for ValidateConfig() and Config.String() Also add --dyn-min-ttl option which sets the lower limit of a record's TTL. Ignored if 0 (the default). * docs: add graceful handling of misconfiguration to changelog
70 lines
1.8 KiB
Go
70 lines
1.8 KiB
Go
/*
|
|
Copyright 2017 The Kubernetes Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package validation
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/kubernetes-incubator/external-dns/pkg/apis/externaldns"
|
|
)
|
|
|
|
// ValidateConfig performs validation on the Config object
|
|
func ValidateConfig(cfg *externaldns.Config) error {
|
|
// TODO: Should probably return field.ErrorList
|
|
if cfg.LogFormat != "text" && cfg.LogFormat != "json" {
|
|
return fmt.Errorf("unsupported log format: %s", cfg.LogFormat)
|
|
}
|
|
if len(cfg.Sources) == 0 {
|
|
return errors.New("no sources specified")
|
|
}
|
|
if cfg.Provider == "" {
|
|
return errors.New("no provider specified")
|
|
}
|
|
|
|
// Azure provider specific validations
|
|
if cfg.Provider == "azure" {
|
|
if cfg.AzureConfigFile == "" {
|
|
return errors.New("no Azure config file specified")
|
|
}
|
|
}
|
|
|
|
// Infoblox provider specific validations
|
|
if cfg.Provider == "infoblox" {
|
|
if cfg.InfobloxGridHost == "" {
|
|
return errors.New("no Infoblox Grid Manager host specified")
|
|
}
|
|
if cfg.InfobloxWapiPassword == "" {
|
|
return errors.New("no Infoblox WAPI password specified")
|
|
}
|
|
}
|
|
|
|
if cfg.Provider == "dyn" {
|
|
if cfg.DynUsername == "" {
|
|
return errors.New("no Dyn username specified")
|
|
}
|
|
if cfg.DynCustomerName == "" {
|
|
return errors.New("no Dyn customer name specified")
|
|
}
|
|
|
|
if cfg.DynMinTTLSeconds < 0 {
|
|
return errors.New("TTL specified for Dyn is negative")
|
|
}
|
|
}
|
|
return nil
|
|
}
|