func (s *Options) Validate() error {
	var errs []error
	backends := sets.NewString(validBackends...)
	if !backends.Has(s.BackendName) {
		errs = append(errs, fmt.Errorf("invalid backend name %q, allowed: %s", s.BackendName, strings.Join(validBackends, ", ")))
	}
	if s.BackendName == "gke" {
		if s.GKEClusterID == "" {
			errs = append(errs, errors.New("GKE cluster name is unset"))
		}
	}
	return utilerrors.NewAggregate(errs)
}
Validate is used to validate the options and config before launching.
package options
import (
	"errors"
	"fmt"
	"strings"
	"time"
	"github.com/spf13/pflag"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	utilerrors "k8s.io/apimachinery/pkg/util/errors"
	"k8s.io/apimachinery/pkg/util/sets"
)
type Options struct {
	Kubeconfig string
	MinResyncPeriod metav1.Duration
	KubeAPIQPS float32
	KubeAPIBurst int32
	ControllerName string
	BackendName string
	GKEClusterID string
	GKEClusterZone string
	GKEProjectID string
}
var validBackends = []string{"node", "gke"}
func New() *Options {
	s := Options{
		MinResyncPeriod: metav1.Duration{Duration: 5 * time.Minute},
		ControllerName:  "default",
	}
	return &s
}
func (s *Options) AddFlags(fs *pflag.FlagSet) {
	fs.StringVar(&s.Kubeconfig, "kubeconfig", s.Kubeconfig, "Path to kubeconfig file with authorization and master location information.")
	fs.DurationVar(&s.MinResyncPeriod.Duration, "min-resync-period", s.MinResyncPeriod.Duration, "The resync period in reflectors will be random between MinResyncPeriod and 2*MinResyncPeriod")
	fs.Float32Var(&s.KubeAPIQPS, "kube-api-qps", s.KubeAPIQPS, "QPS to use while talking with kubernetes apiserver")
	fs.Int32Var(&s.KubeAPIBurst, "kube-api-burst", s.KubeAPIBurst, "Burst to use while talking with kubernetes apiserver")
	fs.StringVar(&s.ControllerName, "controller-name", s.ControllerName, "Name of the NodeSet controller, used to select which pods will be processed by this controller, based on pod's \"spec.ControllerName\".")
	fs.StringVar(&s.BackendName, "backend", s.ControllerName, fmt.Sprintf("The backend to use (supported: %s).", strings.Join(validBackends, ", ")))
	fs.StringVar(&s.GKEClusterID, "gke-cluster-id", s.GKEClusterID, "The cluster name in GKE if that backend is enabled.")
	fs.StringVar(&s.GKEClusterZone, "gke-zone", s.GKEClusterZone, "The zone of the cluster in GKE if that backend is enabled.")
	fs.StringVar(&s.GKEProjectID, "gke-project-id", s.GKEProjectID, "The project ID in google if the GKE backend is enabled.")
}