// LabelValue returns a string to use as a value for the Build
// label in a pod. If the length of the string parameter exceeds
// the maximum label length, the value will be truncated.
513395
func LabelValue(name string) string {
	if len(name) <= validation.DNS1123LabelMaxLength {
		return name
	}
	return name[:validation.DNS1123LabelMaxLength]
}
590557
func (c *Client) ValueDescriptorsByUomLabel(uomLabel string) (values []contract.ValueDescriptor, err error) {
	conn := c.Pool.Get()
	defer conn.Close()

	objects, err := getObjectsByRange(conn, db.ValueDescriptorCollection+":uomlabel:"+uomLabel, 0, -1)
	if err != nil {
		if err != redis.ErrNil {
			return values, err
		}
	}

	values = make([]contract.ValueDescriptor, len(objects))
	for i, in := range objects {
		err = unmarshalObject(in, &values[i])
		if err != nil {
			return values, err
		}
	}

	return values, nil
}
1308674
func stringValue(v reflect.Value) string {
	if v.CanInterface() {
		return fmt.Sprintf("%#v", v.Interface())
	} else {
		return v.String()
	}
}
1254803
func entityLabel(e compile.NamedEntity) string {
	anns := e.ThriftAnnotations()
	if val := anns[goLabelKey]; len(val) > 0 {
		return val
	}
	return e.ThriftName()
}
799487
func Label(k, v string) selector.Option {
	return func(o *selector.Options) {
		l, ok := o.Context.Value(labelKey{}).([]label)
		if !ok {
			l = []label{}
		}
		l = append(l, label{k, v})
		o.Context = context.WithValue(o.Context, labelKey{}, l)
	}
}
167908
func LabelLimitValueSize(size int) Option {
	return func(r *Ringpop) error {
		r.config.LabelLimits.ValueSize = size
		return nil
	}
}
1234678
func (n *PodNetwork) Label(key, value string) *PodNetwork {
	n.Labels[key] = value
	return n
}
921695
func label(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	if len(args) == 0 {
		return errAtLeastOneArgument("LABEL")
	}
	if len(args)%2 != 0 {
		// should never get here, but just in case
		return errTooManyArguments("LABEL")
	}

	if b.RunConfig.Labels == nil {
		b.RunConfig.Labels = map[string]string{}
	}

	for j := 0; j < len(args); j++ {
		// name  ==> args[j]
		// value ==> args[j+1]
		b.RunConfig.Labels[args[j]] = args[j+1]
		j++
	}
	return nil
}
156708
func (o *LabelOptions) RunLabel() error {
	b := o.builder.
		Unstructured().
		LocalParam(o.local).
		ContinueOnError().
		NamespaceParam(o.namespace).DefaultNamespace().
		FilenameParam(o.enforceNamespace, &o.FilenameOptions).
		Flatten()

	if !o.local {
		b = b.LabelSelectorParam(o.selector).
			FieldSelectorParam(o.fieldSelector).
			ResourceTypeOrNameArgs(o.all, o.resources...).
			Latest()
	}

	one := false
	r := b.Do().IntoSingleItemImplied(&one)
	if err := r.Err(); err != nil {
		return err
	}

	// only apply resource version locking on a single resource
	if !one && len(o.resourceVersion) > 0 {
		return fmt.Errorf("--resource-version may only be used with a single resource")
	}

	// TODO: support bulk generic output a la Get
	return r.Visit(func(info *resource.Info, err error) error {
		if err != nil {
			return err
		}

		var outputObj runtime.Object
		var dataChangeMsg string
		obj := info.Object
		oldData, err := json.Marshal(obj)
		if err != nil {
			return err
		}
		if o.dryrun || o.local || o.list {
			err = labelFunc(obj, o.overwrite, o.resourceVersion, o.newLabels, o.removeLabels)
			if err != nil {
				return err
			}
			newObj, err := json.Marshal(obj)
			if err != nil {
				return err
			}
			dataChangeMsg = updateDataChangeMsg(oldData, newObj)
			outputObj = info.Object
		} else {
			name, namespace := info.Name, info.Namespace
			if err != nil {
				return err
			}
			accessor, err := meta.Accessor(obj)
			if err != nil {
				return err
			}
			for _, label := range o.removeLabels {
				if _, ok := accessor.GetLabels()[label]; !ok {
					fmt.Fprintf(o.Out, "label %q not found.\n", label)
				}
			}

			if err := labelFunc(obj, o.overwrite, o.resourceVersion, o.newLabels, o.removeLabels); err != nil {
				return err
			}
			if err := o.Recorder.Record(obj); err != nil {
				klog.V(4).Infof("error recording current command: %v", err)
			}
			newObj, err := json.Marshal(obj)
			if err != nil {
				return err
			}
			dataChangeMsg = updateDataChangeMsg(oldData, newObj)
			patchBytes, err := jsonpatch.CreateMergePatch(oldData, newObj)
			createdPatch := err == nil
			if err != nil {
				klog.V(2).Infof("couldn't compute patch: %v", err)
			}

			mapping := info.ResourceMapping()
			client, err := o.unstructuredClientForMapping(mapping)
			if err != nil {
				return err
			}
			helper := resource.NewHelper(client, mapping)

			if createdPatch {
				outputObj, err = helper.Patch(namespace, name, types.MergePatchType, patchBytes, nil)
			} else {
				outputObj, err = helper.Replace(namespace, name, false, obj)
			}
			if err != nil {
				return err
			}
		}

		if o.list {
			accessor, err := meta.Accessor(outputObj)
			if err != nil {
				return err
			}

			indent := ""
			if !one {
				indent = " "
				gvks, _, err := unstructuredscheme.NewUnstructuredObjectTyper().ObjectKinds(info.Object)
				if err != nil {
					return err
				}
				fmt.Fprintf(o.ErrOut, "Listing labels for %s.%s/%s:\n", gvks[0].Kind, gvks[0].Group, info.Name)
			}
			for k, v := range accessor.GetLabels() {
				fmt.Fprintf(o.Out, "%s%s=%s\n", indent, k, v)
			}

			return nil
		}

		printer, err := o.ToPrinter(dataChangeMsg)
		if err != nil {
			return err
		}
		return printer.PrintObj(info.Object, o.Out)
	})
}
1084704
func (s *Scheme) ConvertFieldLabel(gvk schema.GroupVersionKind, label, value string) (string, string, error) {
	conversionFunc, ok := s.fieldLabelConversionFuncs[gvk]
	if !ok {
		return DefaultMetaV1FieldSelectorConversion(label, value)
	}
	return conversionFunc(label, value)
}
234658
func (q *Quantity) ScaledValue(scale Scale) int64 {
	if q.d.Dec == nil {
		i, _ := q.i.AsScaledInt64(scale)
		return i
	}
	dec := q.d.Dec
	return scaledValue(dec.UnscaledBig(), int(dec.Scale()), int(scale.infScale()))
}
205335
func (k *Apk) Label(resConfig *androidbinary.ResTableConfig) (s string, err error) {
	s = k.getResource(k.manifest.App.Label, resConfig)
	if androidbinary.IsResID(s) {
		err = errors.New("unable to convert label-id to string")
	}
	return
}
249732
func (win *Window) LabelWrap(str string) {
	win.LabelWrapColored(str, win.ctx.Style.Text.Color)
}
955707
func KeyValue(label string) (key string, value string) {
	if kv := strings.SplitN(label, "=", 2); len(kv) > 0 {
		key = kv[0]
		if len(kv) > 1 {
			value = kv[1]
		}
	}
	return
}
888322
func getStringValue(labels map[string]string, labelName string, defaultValue string) string {
	if value, ok := labels[labelName]; ok && len(value) > 0 {
		return value
	}
	return defaultValue
}
894491
func getLabel(image *api.Image, name string) string {
	if value, ok := image.Config.Labels[name]; ok {
		return value
	}
	return ""
}
22019
func ValueFunc(ctx context.Context, label string) Func {
	if metadata := ctx.Value(key{}); metadata != nil {
		if m, ok := metadata.(md); ok {
			return m[label]
		}
	}
	return nil
}