MCPcopy Create free account
hub / github.com/devfile/devworkspace-operator / updateObjectGeneric

Function updateObjectGeneric

pkg/provision/sync/sync.go:154–178  ·  view source on GitHub ↗
(specObj, clusterObj crclient.Object, api ClusterAPI)

Source from the content-addressed store, hash-verified

152}
153
154func updateObjectGeneric(specObj, clusterObj crclient.Object, api ClusterAPI) error {
155 updateFunc := getUpdateFunc(specObj)
156 updatedObj, err := updateFunc(specObj, clusterObj)
157 if err != nil {
158 if err := api.Client.Delete(api.Ctx, specObj); err != nil {
159 return err
160 }
161 api.Logger.Info("Deleted object", "kind", reflect.TypeOf(specObj).Elem().String(), "name", specObj.GetName())
162 return NewNotInSync(specObj, DeletedObjectReason)
163 }
164
165 err = api.Client.Update(api.Ctx, updatedObj)
166 switch {
167 case err == nil:
168 api.Logger.Info("Updated object", "kind", reflect.TypeOf(specObj).Elem().String(), "name", specObj.GetName())
169 return NewNotInSync(specObj, UpdatedObjectReason)
170 case k8sErrors.IsConflict(err), k8sErrors.IsNotFound(err):
171 // Need to catch IsNotFound here because we attempt to update when creation fails with AlreadyExists
172 return NewNotInSync(specObj, NeedRetryReason)
173 case k8sErrors.IsInvalid(err), k8sErrors.IsForbidden(err):
174 return &UnrecoverableSyncError{err}
175 default:
176 return err
177 }
178}
179
180func isMutableObject(obj crclient.Object) bool {
181 switch obj.(type) {

Callers 2

SyncObjectWithClusterFunction · 0.85
createObjectGenericFunction · 0.85

Calls 4

getUpdateFuncFunction · 0.85
updateFuncFuncType · 0.85
NewNotInSyncFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected