// MakeLabelValidator returns a MapValidatorFunc using apimachinery.
554290
func (v *KustValidator) MakeLabelValidator() func(map[string]string) error {
	return func(x map[string]string) error {
		errs := v1validation.ValidateLabels(x, field.NewPath("field"))
		if len(errs) > 0 {
			return errors.New(errs.ToAggregate().Error())
		}
		return nil
	}
}
293832
func (env *joyentEnviron) ConstraintsValidator(ctx context.ProviderCallContext) (constraints.Validator, error) {
	validator := constraints.NewValidator()
	validator.RegisterUnsupported(unsupportedConstraints)
	packages, err := env.compute.cloudapi.ListPackages(nil)
	if err != nil {
		return nil, err
	}
	instTypeNames := make([]string, len(packages))
	for i, pkg := range packages {
		instTypeNames[i] = pkg.Name
	}
	validator.RegisterVocabulary(constraints.InstanceType, instTypeNames)
	return validator, nil
}
35717
func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer {
	var signer Signer
	switch {
	case config.IsEIP155(blockNumber):
		signer = NewEIP155Signer(config.ChainID)
	case config.IsHomestead(blockNumber):
		signer = HomesteadSigner{}
	default:
		signer = FrontierSigner{}
	}
	return signer
}
2325
func Validate(label string) error {
	if strings.Contains(label, "z") && strings.Contains(label, "Z") {
		return ErrIncompatibleLabel
	}
	return nil
}
1263983
func ValidateLabels(labels map[string]string, fldPath *field.Path) field.ErrorList {
	allErrs := field.ErrorList{}
	for k, v := range labels {
		allErrs = append(allErrs, ValidateLabelName(k, fldPath)...)
		for _, msg := range validation.IsValidLabelValue(v) {
			allErrs = append(allErrs, field.Invalid(fldPath, v, msg))
		}
	}
	return allErrs
}
825452
func (o *LabelOptions) Validate() error {
	if o.all && len(o.selector) > 0 {
		return fmt.Errorf("cannot set --all and --selector at the same time")
	}
	if o.all && len(o.fieldSelector) > 0 {
		return fmt.Errorf("cannot set --all and --field-selector at the same time")
	}
	if len(o.resources) < 1 && cmdutil.IsFilenameSliceEmpty(o.FilenameOptions.Filenames, o.FilenameOptions.Kustomize) {
		return fmt.Errorf("one or more resources must be specified as <resource> <name> or <resource>/<name>")
	}
	if len(o.newLabels) < 1 && len(o.removeLabels) < 1 && !o.list {
		return fmt.Errorf("at least one label update is required")
	}
	return nil
}
916020
func MakeMapper(t TokenMapperFn, a AmountMapperFn) MapperFn {
	return func(r request.Request) (string, int64, error) {
		token, err := t(r)
		if err != nil {
			return "", -1, err
		}
		amount, err := a(r)
		if err != nil {
			return "", -1, err
		}
		return token, amount, nil
	}
}
1032555
func RegisterValidator(name string, cb ValidatorCallback) error {
	if _, exists := validators[name]; exists {
		return ErrDuplicateValidator
	}

	validators[name] = cb
	return nil
}
1101126
func SelectorHasLabel(selector *LabelSelector, labelKey string) bool {
	return len(selector.MatchLabels[labelKey]) > 0
}
466949
func NewValidator() *Validator {
	v := &Validator{}
	v.SetTag("validate")
	v.SetValidationFunc("req", ReqValidator)
	v.SetValidationFunc("d", DefaultValidator)
	v.SetValidationFunc("min", MinValidator)
	v.SetValidationFunc("max", MaxValidator)
	v.SetValidationFunc("minLen", MinLenValidator)
	v.SetValidationFunc("maxLen", MaxLenValidator)
	v.SetValidationFunc("email", EmailValidator)
	v.SetValidationFunc("enum", EnumValidator)
	v.SetValidationFunc("regexp", RegExpValidator)
	return v
}
880106
func (p *Pod) AddLabel(key, value string) *Pod {
	p.Labels[key] = value
	return p
}
706722
func AddLabelToSelector(selector *metav1.LabelSelector, labelKey, labelValue string) *metav1.LabelSelector {
	if labelKey == "" {
		// Don't need to add a label.
		return selector
	}
	if selector.MatchLabels == nil {
		selector.MatchLabels = make(map[string]string)
	}
	selector.MatchLabels[labelKey] = labelValue
	return selector
}
974384
func MakeHandler(validpath *regexp.Regexp, parser Json2dataConverter, handler HttpHandler, mustHaveInputData bool) http.HandlerFunc {

	return func(w http.ResponseWriter, r *http.Request) {

		// check path
		m := validpath.FindStringSubmatch(r.URL.Path)
		if m == nil {
			http.NotFound(w, r)
			return
		}

		// handle OPTIONS request
		if r.Method == "OPTIONS" {
			setDefaultHeaders(w)
			return
		}

		// skip other methods
		if r.Method != "POST" && r.Method != "GET" {
			return
		}

		// set access and return type
		origin := r.Header.Get("Origin")
		w.Header().Set("Access-Control-Allow-Origin", origin)
		w.Header().Set("Content-Type", "application/json")

		// handle POST
		var dat []byte
		var err error
		if r.Method == "POST" {
			dat, err = ioutil.ReadAll(r.Body) // parse 'body'
			if err != nil {
				http.Error(w, err.Error(), http.StatusInternalServerError)
				return
			}
		}

		// handle GET
		if r.Method == "GET" {
			err = r.ParseForm()
			if err != nil {
				http.Error(w, err.Error(), http.StatusInternalServerError)
				return
			}
			for str, _ := range r.Form {
				dat = []byte(str)
				break
			}
		}

		// parse json and call handler
		d := parser(dat)
		if d == nil && mustHaveInputData {
			http.Error(w, "handlermaker.go: parser failed: data is <nil>", http.StatusInternalServerError)
			return
		}
		res, err := handler(w, r, d)
		if err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
		}
		if res != nil {
			fmt.Fprintf(w, res.String())
		}
	}
}
516647
func (s *LabelService) CreateLabelMapping(ctx context.Context, m *platform.LabelMapping) error {
	return s.CreateLabelMappingFn(ctx, m)
}
1075026
func ValidatorFromMap(in map[string]interface{}) (FieldValidatorFunc, error) {
	validators := make([]FieldValidatorFunc, 0)

	for name, defn := range in {
		if validator, err := GetValidator(name, defn); err == nil {
			validators = append(validators, validator)
		} else {
			return nil, fmt.Errorf("Invalid validator configuration %v: %v", name, err)
		}
	}

	return ValidateAll(validators...), nil
}
405699
func makeLabels(labels, annotations map[string]string) map[string]string {
	merged := make(map[string]string)
	for k, v := range labels {
		merged[k] = v
	}
	for k, v := range annotations {
		// Assume there won't be conflict.
		merged[fmt.Sprintf("%s%s", annotationPrefix, k)] = v
	}
	return merged
}
149923
func (s *CirconusSink) flattenKeyLabels(parts []string, labels []metrics.Label) string {
	for _, label := range labels {
		parts = append(parts, label.Value)
	}
	return s.flattenKey(parts)
}