// WithAnnotations appends or replaces the annotations on the spec with the
// provided annotations
533
func WithAnnotations(annotations map[string]string) SpecOpts {
	return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
		if s.Annotations == nil {
			s.Annotations = make(map[string]string)
		}
		for k, v := range annotations {
			s.Annotations[k] = v
		}
		return nil
	}
}
555859
func (m *Model) Annotations(entity GlobalEntity) (map[string]string, error) {
	doc := new(annotatorDoc)
	annotations, closer := m.st.db().GetCollection(annotationsC)
	defer closer()
	err := annotations.FindId(entity.globalKey()).One(doc)
	if err == mgo.ErrNotFound {
		// Returning an empty map if there are no annotations.
		return make(map[string]string), nil
	}
	if err != nil {
		return nil, errors.Trace(err)
	}
	return doc.Annotations, nil
}
762755
func (opts *ListOpts) WithValidator(validator ValidatorFctType) *ListOpts {
	opts.validator = validator
	return opts
}
988371
func WithTags(tags []string) Option {
	return func(o *Options) error {
		o.Tags = tags
		return nil
	}
}
459116
func WithServices(c context.Context, s Services) context.Context {
	return context.WithValue(c, &servicesKey, s)
}
790882
func WithFields(ctx context.Context, fields logrus.Fields) context.Context {
	logger := ctx.Value(loggerKey{})

	if logger == nil {
		logger = L
	}
	return WithLogger(ctx, logger.(*logrus.Entry).WithFields(fields))
}
30967
func (h *bundleHandler) setAnnotations(change *bundlechanges.SetAnnotationsChange) error {
	p := change.Params
	h.ctx.Verbosef("  setting annotations:")
	for key, value := range p.Annotations {
		h.ctx.Verbosef("    %s: %q", key, value)
	}
	if h.dryRun {
		return nil
	}
	eid := resolve(p.Id, h.results)
	var tag string
	switch p.EntityType {
	case bundlechanges.MachineType:
		tag = names.NewMachineTag(eid).String()
	case bundlechanges.ApplicationType:
		tag = names.NewApplicationTag(eid).String()
	default:
		return errors.Errorf("unexpected annotation entity type %q", p.EntityType)
	}
	result, err := h.api.SetAnnotation(map[string]map[string]string{tag: p.Annotations})
	if err == nil && len(result) > 0 {
		err = result[0].Error
	}
	if err != nil {
		return errors.Annotatef(err, "cannot set annotations for %s %q", p.EntityType, eid)
	}
	return nil
}
818763
func WithHeaders(headers map[string]interface{}) PrepareDecorator {
	h := ensureValueStrings(headers)
	return func(p Preparer) Preparer {
		return PreparerFunc(func(r *http.Request) (*http.Request, error) {
			r, err := p.Prepare(r)
			if err == nil {
				if r.Header == nil {
					r.Header = make(http.Header)
				}

				for name, value := range h {
					r.Header.Set(http.CanonicalHeaderKey(name), value)
				}
			}
			return r, err
		})
	}
}
75205
func (o AnnotateOptions) updateAnnotations(obj runtime.Object) error {
	accessor, err := meta.Accessor(obj)
	if err != nil {
		return err
	}
	if !o.overwrite {
		if err := validateNoAnnotationOverwrites(accessor, o.newAnnotations); err != nil {
			return err
		}
	}

	annotations := accessor.GetAnnotations()
	if annotations == nil {
		annotations = make(map[string]string)
	}

	for key, value := range o.newAnnotations {
		annotations[key] = value
	}
	for _, annotation := range o.removeAnnotations {
		delete(annotations, annotation)
	}
	accessor.SetAnnotations(annotations)

	if len(o.resourceVersion) != 0 {
		accessor.SetResourceVersion(o.resourceVersion)
	}
	return nil
}
805101
func (c *statsClient) WithTags(tags ...string) stats.StatsClient {
	return &statsClient{
		client: c.client,
		tags:   unionStringSlice(c.tags, tags),
		logger: c.logger,
	}
}
370287
func WithTags(logger *logging.Logger, tags []common.KVPair) *logging.Logger {
	keyvals := make([]interface{}, len(tags)*2)
	for i, kvp := range tags {
		keyvals[i] = string(kvp.Key)
		keyvals[i+1] = string(kvp.Value)
	}
	return logger.With(keyvals...)
}
719048
func WriteAnnotations(bkt *bolt.Bucket, labels map[string]string) error {
	return writeMap(bkt, bucketKeyAnnotations, labels)
}
781033
func SaveAnnotations(services ServiceUpdater, svc *v1.Service, leaseMap *leases.Map) error {
	annos, err := leaseMap.ToAnnotations()
	if err != nil {
		return err
	}
	svc.Annotations = annos
	if _, err := services.Update(svc); err != nil {
		return err
	}
	return nil
}
1260223
func (networkOfferingApi *NetworkOfferingApi) ListWithOptions(options map[string]string) ([]NetworkOffering, error) {
	data, err := networkOfferingApi.entityService.List(options)
	if err != nil {
		return nil, err
	}
	return parseNetworkOfferingList(data), nil
}
933132
func WithTags(tags map[string]string) TracerOption {
	return func(o *Tracer) error {
		for k, v := range tags {
			o.defaultTags[k] = v
		}
		return nil
	}
}
491765
func oldAnnotations(in map[AnnotationKey]interface{}) (out map[string]interface{}) {
	if len(in) == 0 {
		return nil
	}
	out = make(map[string]interface{})
	for k, v := range in {
		out[k.String()] = v
	}
	return
}
196388
func WithLabels(labels map[string]string) Opt {
	return func(c *Config) error {
		c.Labels = labels
		return nil
	}
}