pkg/apis/externaldns/validation/validation.go
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")
		}
	}

	if cfg.IgnoreHostnameAnnotation && cfg.FQDNTemplate == "" {
		return errors.New("FQDN Template must be set if ignoring annotations")
	}
	return nil
}
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")
		}
	}

	if cfg.IgnoreHostnameAnnotation && cfg.FQDNTemplate == "" {
		return errors.New("FQDN Template must be set if ignoring annotations")
	}
	return nil
}
// ValidateConfig performs validation on the Config object