external-dns/pkg/apis/externaldns/validation/validation.go
Khris Richardson cab3e0454e Initial commit of Infoblox provider (#349)
* Initial commit of Infoblox provider

* address @ideahitme's observations

* fail at addressing @szuecs comments

* fix(infoblox): avoid shadowing err variable

* fix flag descriptions

* default ssl verify to true. thanks @szuecs

* chore(infoblox): bump minium required version

This should ideally be a minor bump but let's do that when we have v0.5
2017-10-12 13:41:18 +02:00

57 lines
1.6 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")
}
}
return nil
}