func MakeParams(cmd *cobra.Command, params []GeneratorParam) map[string]interface{} {
	result := map[string]interface{}{}
	for ix := range params {
		f := cmd.Flags().Lookup(params[ix].Name)
		if f != nil {
			result[params[ix].Name] = f.Value.String()
		}
	}
	return result
}
MakeParams is a utility that creates generator parameters from a command line
package kubectl
import (
	"fmt"
	"reflect"
	"strconv"
	"strings"
	"github.com/spf13/cobra"
	"github.com/spf13/pflag"
	"k8s.io/kubernetes/pkg/runtime"
	utilerrors "k8s.io/kubernetes/pkg/util/errors"
)
type GeneratorParam struct {
	Name     string
	Required bool
}
type Generator interface {
	Generate(params map[string]interface{}) (runtime.Object, error)
	ParamNames() []GeneratorParam
}
type StructuredGenerator interface {
	StructuredGenerate() (runtime.Object, error)
}
func IsZero(i interface{}) bool {
	if i == nil {
		return true
	}
	return reflect.DeepEqual(i, reflect.Zero(reflect.TypeOf(i)).Interface())
}
func ValidateParams(paramSpec []GeneratorParam, params map[string]interface{}) error {
	allErrs := []error{}
	for ix := range paramSpec {
		if paramSpec[ix].Required {
			value, found := params[paramSpec[ix].Name]
			if !found || IsZero(value) {
				allErrs = append(allErrs, fmt.Errorf("Parameter: %s is required", paramSpec[ix].Name))
			}
		}
	}
	return utilerrors.NewAggregate(allErrs)
}
func AnnotateFlags(cmd *cobra.Command, generators map[string]Generator) {
	for name, generator := range generators {
		generatorParams := map[string]struct{}{}
		for _, param := range generator.ParamNames() {
			generatorParams[param.Name] = struct{}{}
		}
		cmd.Flags().VisitAll(func(flag *pflag.Flag) {
			if _, found := generatorParams[flag.Name]; !found {
				return
			}
			if flag.Annotations == nil {
				flag.Annotations = map[string][]string{}
			}
			if annotations := flag.Annotations["generator"]; annotations == nil {
				flag.Annotations["generator"] = []string{}
			}
			flag.Annotations["generator"] = append(flag.Annotations["generator"], name)
		})
	}
}
func EnsureFlagsValid(cmd *cobra.Command, generators map[string]Generator, generatorInUse string) error {
	AnnotateFlags(cmd, generators)
	allErrs := []error{}
	cmd.Flags().VisitAll(func(flag *pflag.Flag) {
		if !flag.Changed {
			return
		}
		if annotations := flag.Annotations["generator"]; len(annotations) > 0 {
			annotationMap := map[string]struct{}{}
			for _, ann := range annotations {
				annotationMap[ann] = struct{}{}
			}
			if _, found := annotationMap[generatorInUse]; !found {
				allErrs = append(allErrs, fmt.Errorf("cannot use --%s with --generator=%s", flag.Name, generatorInUse))
			}
		}
	})
	return utilerrors.NewAggregate(allErrs)
}