github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/commit.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package mono_models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 "strconv" 11 12 "github.com/go-openapi/errors" 13 "github.com/go-openapi/strfmt" 14 "github.com/go-openapi/swag" 15 "github.com/go-openapi/validate" 16 ) 17 18 // Commit commit 19 // 20 // swagger:model Commit 21 type Commit struct { 22 23 // The date and time at which this commit was created. 24 // Format: date-time 25 Added strfmt.DateTime `json:"added,omitempty"` 26 27 // An anonymous id used to help track the creator of headless commits. 28 AnonID string `json:"anonID,omitempty"` 29 30 // When resolving dependencies, updates made after this time will be ignored. 31 // Format: date-time 32 AtTime strfmt.DateTime `json:"atTime,omitempty"` 33 34 // The id of the user that authored this commit. 35 // Format: uuid 36 Author *strfmt.UUID `json:"author,omitempty"` 37 38 // What changed in this commit. 39 Changeset []*CommitChange `json:"changeset"` 40 41 // commit ID 42 // Read Only: true 43 // Format: uuid 44 CommitID strfmt.UUID `json:"commitID,omitempty"` 45 46 // A message that describes what was changed in this commit. 47 Message string `json:"message,omitempty"` 48 49 // The parent commit that this one came from (empty if this is the first commit). 50 // Read Only: true 51 // Format: uuid 52 ParentCommitID strfmt.UUID `json:"parentCommitID,omitempty"` 53 54 // An id populated by the state tool. 55 UniqueDeviceID string `json:"uniqueDeviceID,omitempty"` 56 57 // The name of the user that authored this commit. 58 Username *string `json:"username,omitempty"` 59 } 60 61 // Validate validates this commit 62 func (m *Commit) Validate(formats strfmt.Registry) error { 63 var res []error 64 65 if err := m.validateAdded(formats); err != nil { 66 res = append(res, err) 67 } 68 69 if err := m.validateAtTime(formats); err != nil { 70 res = append(res, err) 71 } 72 73 if err := m.validateAuthor(formats); err != nil { 74 res = append(res, err) 75 } 76 77 if err := m.validateChangeset(formats); err != nil { 78 res = append(res, err) 79 } 80 81 if err := m.validateCommitID(formats); err != nil { 82 res = append(res, err) 83 } 84 85 if err := m.validateParentCommitID(formats); err != nil { 86 res = append(res, err) 87 } 88 89 if len(res) > 0 { 90 return errors.CompositeValidationError(res...) 91 } 92 return nil 93 } 94 95 func (m *Commit) validateAdded(formats strfmt.Registry) error { 96 if swag.IsZero(m.Added) { // not required 97 return nil 98 } 99 100 if err := validate.FormatOf("added", "body", "date-time", m.Added.String(), formats); err != nil { 101 return err 102 } 103 104 return nil 105 } 106 107 func (m *Commit) validateAtTime(formats strfmt.Registry) error { 108 if swag.IsZero(m.AtTime) { // not required 109 return nil 110 } 111 112 if err := validate.FormatOf("atTime", "body", "date-time", m.AtTime.String(), formats); err != nil { 113 return err 114 } 115 116 return nil 117 } 118 119 func (m *Commit) validateAuthor(formats strfmt.Registry) error { 120 if swag.IsZero(m.Author) { // not required 121 return nil 122 } 123 124 if err := validate.FormatOf("author", "body", "uuid", m.Author.String(), formats); err != nil { 125 return err 126 } 127 128 return nil 129 } 130 131 func (m *Commit) validateChangeset(formats strfmt.Registry) error { 132 if swag.IsZero(m.Changeset) { // not required 133 return nil 134 } 135 136 for i := 0; i < len(m.Changeset); i++ { 137 if swag.IsZero(m.Changeset[i]) { // not required 138 continue 139 } 140 141 if m.Changeset[i] != nil { 142 if err := m.Changeset[i].Validate(formats); err != nil { 143 if ve, ok := err.(*errors.Validation); ok { 144 return ve.ValidateName("changeset" + "." + strconv.Itoa(i)) 145 } 146 return err 147 } 148 } 149 150 } 151 152 return nil 153 } 154 155 func (m *Commit) validateCommitID(formats strfmt.Registry) error { 156 if swag.IsZero(m.CommitID) { // not required 157 return nil 158 } 159 160 if err := validate.FormatOf("commitID", "body", "uuid", m.CommitID.String(), formats); err != nil { 161 return err 162 } 163 164 return nil 165 } 166 167 func (m *Commit) validateParentCommitID(formats strfmt.Registry) error { 168 if swag.IsZero(m.ParentCommitID) { // not required 169 return nil 170 } 171 172 if err := validate.FormatOf("parentCommitID", "body", "uuid", m.ParentCommitID.String(), formats); err != nil { 173 return err 174 } 175 176 return nil 177 } 178 179 // ContextValidate validate this commit based on the context it is used 180 func (m *Commit) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 181 var res []error 182 183 if err := m.contextValidateChangeset(ctx, formats); err != nil { 184 res = append(res, err) 185 } 186 187 if err := m.contextValidateCommitID(ctx, formats); err != nil { 188 res = append(res, err) 189 } 190 191 if err := m.contextValidateParentCommitID(ctx, formats); err != nil { 192 res = append(res, err) 193 } 194 195 if len(res) > 0 { 196 return errors.CompositeValidationError(res...) 197 } 198 return nil 199 } 200 201 func (m *Commit) contextValidateChangeset(ctx context.Context, formats strfmt.Registry) error { 202 203 for i := 0; i < len(m.Changeset); i++ { 204 205 if m.Changeset[i] != nil { 206 if err := m.Changeset[i].ContextValidate(ctx, formats); err != nil { 207 if ve, ok := err.(*errors.Validation); ok { 208 return ve.ValidateName("changeset" + "." + strconv.Itoa(i)) 209 } 210 return err 211 } 212 } 213 214 } 215 216 return nil 217 } 218 219 func (m *Commit) contextValidateCommitID(ctx context.Context, formats strfmt.Registry) error { 220 221 if err := validate.ReadOnly(ctx, "commitID", "body", strfmt.UUID(m.CommitID)); err != nil { 222 return err 223 } 224 225 return nil 226 } 227 228 func (m *Commit) contextValidateParentCommitID(ctx context.Context, formats strfmt.Registry) error { 229 230 if err := validate.ReadOnly(ctx, "parentCommitID", "body", strfmt.UUID(m.ParentCommitID)); err != nil { 231 return err 232 } 233 234 return nil 235 } 236 237 // MarshalBinary interface implementation 238 func (m *Commit) MarshalBinary() ([]byte, error) { 239 if m == nil { 240 return nil, nil 241 } 242 return swag.WriteJSON(m) 243 } 244 245 // UnmarshalBinary interface implementation 246 func (m *Commit) UnmarshalBinary(b []byte) error { 247 var res Commit 248 if err := swag.ReadJSON(b, &res); err != nil { 249 return err 250 } 251 *m = res 252 return nil 253 }