MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / SetField

Method SetField

app/controlplane/pkg/data/ent/mutation.go:4510–4563  ·  view source on GitHub ↗

SetField sets the value of a field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

(name string, value ent.Value)

Source from the content-addressed store, hash-verified

4508// the field is not defined in the schema, or if the type mismatched the field
4509// type.
4510func (m *GroupMutation) SetField(name string, value ent.Value) error {
4511 switch name {
4512 case group.FieldName:
4513 v, ok := value.(string)
4514 if !ok {
4515 return fmt.Errorf("unexpected type %T for field %s", value, name)
4516 }
4517 m.SetName(v)
4518 return nil
4519 case group.FieldDescription:
4520 v, ok := value.(string)
4521 if !ok {
4522 return fmt.Errorf("unexpected type %T for field %s", value, name)
4523 }
4524 m.SetDescription(v)
4525 return nil
4526 case group.FieldOrganizationID:
4527 v, ok := value.(uuid.UUID)
4528 if !ok {
4529 return fmt.Errorf("unexpected type %T for field %s", value, name)
4530 }
4531 m.SetOrganizationID(v)
4532 return nil
4533 case group.FieldCreatedAt:
4534 v, ok := value.(time.Time)
4535 if !ok {
4536 return fmt.Errorf("unexpected type %T for field %s", value, name)
4537 }
4538 m.SetCreatedAt(v)
4539 return nil
4540 case group.FieldUpdatedAt:
4541 v, ok := value.(time.Time)
4542 if !ok {
4543 return fmt.Errorf("unexpected type %T for field %s", value, name)
4544 }
4545 m.SetUpdatedAt(v)
4546 return nil
4547 case group.FieldDeletedAt:
4548 v, ok := value.(time.Time)
4549 if !ok {
4550 return fmt.Errorf("unexpected type %T for field %s", value, name)
4551 }
4552 m.SetDeletedAt(v)
4553 return nil
4554 case group.FieldMemberCount:
4555 v, ok := value.(int)
4556 if !ok {
4557 return fmt.Errorf("unexpected type %T for field %s", value, name)
4558 }
4559 m.SetMemberCount(v)
4560 return nil
4561 }
4562 return fmt.Errorf("unknown Group field %s", name)
4563}
4564
4565// AddedFields returns all numeric fields that were incremented/decremented during
4566// this mutation.

Callers

nothing calls this directly

Calls 7

SetNameMethod · 0.95
SetDescriptionMethod · 0.95
SetOrganizationIDMethod · 0.95
SetCreatedAtMethod · 0.95
SetUpdatedAtMethod · 0.95
SetDeletedAtMethod · 0.95
SetMemberCountMethod · 0.95

Tested by

no test coverage detected