// Create a new label
966939
func (m *GormLabelRepository) Create(ctx context.Context, u *Label) error {
	defer goa.MeasureSince([]string{"goa", "db", "label", "create"}, time.Now())
	u.ID = uuid.NewV4()
	if strings.TrimSpace(u.Name) == "" {
		return errors.NewBadParameterError("label name cannot be empty string", u.Name).Expected("non empty string")
	}
	err := m.db.Create(u).Error
	if err != nil {
		// combination of name and space ID should be unique
		if gormsupport.IsUniqueViolation(err, "labels_name_space_id_unique_idx") {
			log.Error(ctx, map[string]interface{}{
				"err":      err,
				"name":     u.Name,
				"space_id": u.SpaceID,
			}, "unable to create label because a label with same already exists in the space")
			return errors.NewDataConflictError(fmt.Sprintf("label already exists with name = %s , space_id = %s", u.Name, u.SpaceID.String()))
		}
		log.Error(ctx, map[string]interface{}{}, "error adding Label: %s", err.Error())
		return err
	}
	return nil
}
911688
func newLabelResponse(l *plat.Label) *labelResponse {
	return &labelResponse{
		Links: map[string]string{
			"resource": fmt.Sprintf("/api/v2/%ss/%s", "dashboard", l.ResourceID),
		},
		Label: *l,
	}
}
1070614
func (d *DropDown) SetLabel(label string) *DropDown {
	d.label = label
	return d
}
1254233
func (service *Service) CreateCollection(label string) (*Collection, error) {
  properties := make(map[string]dbus.Variant)
  properties["org.freedesktop.Secret.Collection.Label"] = dbus.MakeVariant(label)

  var path   dbus.ObjectPath
  var prompt dbus.ObjectPath

  err := service.dbus.Call("org.freedesktop.Secret.Service.CreateCollection", 0, properties, "").Store(&path, &prompt)
  if err != nil {
    return &Collection{}, err
  }

  if isPrompt(prompt) {
    prompt := NewPrompt(service.conn, prompt)

    result, err := prompt.Prompt()
    if err != nil {
      return &Collection{}, err
    }

    path = result.Value().(dbus.ObjectPath)
  }

  return NewCollection(service.conn, path), nil
}
507542
func (f Form) Label(value string, opts tags.Options) *tags.Tag {
	opts["body"] = value
	return tags.New("label", opts)
}
625710
func NewIssueLabel(issue *Issue, label *Label) (err error) {
	if HasIssueLabel(issue.ID, label.ID) {
		return nil
	}

	sess := x.NewSession()
	defer sess.Close()
	if err = sess.Begin(); err != nil {
		return err
	}

	if err = newIssueLabel(sess, issue, label); err != nil {
		return err
	}

	return sess.Commit()
}
689786
func (h *Event) Label(label string) *Event {
	h.label = label
	h.labelSet = true
	return h
}
832813
func (b *Broadcast) Label() string {
	if b.label == "" {
		b.label = fmt.Sprintf("%s:%d:%d",
			b.origin.ip.String(),
			b.origin.port,
			b.index)
	}

	return b.label
}
890030
func (b *Button) SetLabel(label string) *Button {
	b.label = label
	return b
}
571535
func newContainerLabels(container *v1.Container, pod *v1.Pod) map[string]string {
	labels := map[string]string{}
	labels[types.KubernetesPodNameLabel] = pod.Name
	labels[types.KubernetesPodNamespaceLabel] = pod.Namespace
	labels[types.KubernetesPodUIDLabel] = string(pod.UID)
	labels[types.KubernetesContainerNameLabel] = container.Name

	return labels
}
1191063
func (s *Service) CreateLabelMapping(ctx context.Context, m *influxdb.LabelMapping) error {
	_, err := s.FindLabelByID(ctx, m.LabelID)
	if err != nil {
		return &influxdb.Error{
			Err: err,
			Op:  influxdb.OpCreateLabel,
		}
	}

	s.labelMappingKV.Store(encodeLabelMappingKey(m), *m)
	return nil
}
1341602
func (r *Application) AddLabel(name, value string) *Application {
	if r.Labels == nil {
		r.EmptyLabels()
	}
	(*r.Labels)[name] = value

	return r
}
626290
func ReleaseLabel(label string) {
	if len(label) != 0 {
		con := strings.SplitN(label, ":", 4)
		if len(con) > 3 {
			mcsDelete(con[3])
		}
	}
}
1124489
func (jf openTracingService) New(parent Span, label string) Span {
	var innerSpan opentracing.Span
	if parent == nil {
		innerSpan = jf.Tracer.StartSpan(label)
	} else {
		jaegerParent := parent.(openTracingSpan)
		span := jaegerParent.otSpan
		innerSpan = jf.Tracer.StartSpan(label, opentracing.ChildOf(span.Context()))
	}
	return openTracingSpan{otSpan: innerSpan}
}
944752
func (s *Service) createLabelMapping(ctx context.Context, tx Tx, m *influxdb.LabelMapping) error {
	if _, err := s.findLabelByID(ctx, tx, m.LabelID); err != nil {
		return err
	}

	if err := s.putLabelMapping(ctx, tx, m); err != nil {
		return err
	}

	return nil
}
1092348
func NewLabel(prefix string, offset uint64, k uint) (*Label, error) {
	if len(prefix) > 0 && !(strings.HasSuffix(prefix, ":") || strings.HasSuffix(prefix, ",")) {
		prefix = prefix + ":"
	}
	return &Label{
		Prefix:     prefix,
		Categories: categoriesForOffset(offset, maxCategories, k),
	}, nil
}
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
}