MCPcopy
hub / github.com/crowdsecurity/crowdsec / SetField

Method SetField

pkg/database/ent/mutation.go:9850–9973  ·  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

9848// the field is not defined in the schema, or if the type mismatched the field
9849// type.
9850func (m *MachineMutation) SetField(name string, value ent.Value) error {
9851 switch name {
9852 case machine.FieldCreatedAt:
9853 v, ok := value.(time.Time)
9854 if !ok {
9855 return fmt.Errorf("unexpected type %T for field %s", value, name)
9856 }
9857 m.SetCreatedAt(v)
9858 return nil
9859 case machine.FieldUpdatedAt:
9860 v, ok := value.(time.Time)
9861 if !ok {
9862 return fmt.Errorf("unexpected type %T for field %s", value, name)
9863 }
9864 m.SetUpdatedAt(v)
9865 return nil
9866 case machine.FieldLastPush:
9867 v, ok := value.(time.Time)
9868 if !ok {
9869 return fmt.Errorf("unexpected type %T for field %s", value, name)
9870 }
9871 m.SetLastPush(v)
9872 return nil
9873 case machine.FieldLastHeartbeat:
9874 v, ok := value.(time.Time)
9875 if !ok {
9876 return fmt.Errorf("unexpected type %T for field %s", value, name)
9877 }
9878 m.SetLastHeartbeat(v)
9879 return nil
9880 case machine.FieldMachineId:
9881 v, ok := value.(string)
9882 if !ok {
9883 return fmt.Errorf("unexpected type %T for field %s", value, name)
9884 }
9885 m.SetMachineId(v)
9886 return nil
9887 case machine.FieldPassword:
9888 v, ok := value.(string)
9889 if !ok {
9890 return fmt.Errorf("unexpected type %T for field %s", value, name)
9891 }
9892 m.SetPassword(v)
9893 return nil
9894 case machine.FieldIpAddress:
9895 v, ok := value.(string)
9896 if !ok {
9897 return fmt.Errorf("unexpected type %T for field %s", value, name)
9898 }
9899 m.SetIpAddress(v)
9900 return nil
9901 case machine.FieldScenarios:
9902 v, ok := value.(string)
9903 if !ok {
9904 return fmt.Errorf("unexpected type %T for field %s", value, name)
9905 }
9906 m.SetScenarios(v)
9907 return nil

Callers

nothing calls this directly

Calls 15

SetCreatedAtMethod · 0.95
SetUpdatedAtMethod · 0.95
SetLastPushMethod · 0.95
SetLastHeartbeatMethod · 0.95
SetMachineIdMethod · 0.95
SetPasswordMethod · 0.95
SetIpAddressMethod · 0.95
SetScenariosMethod · 0.95
SetVersionMethod · 0.95
SetIsValidatedMethod · 0.95
SetAuthTypeMethod · 0.95
SetOsnameMethod · 0.95

Tested by

no test coverage detected