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

Function createObjectGeneric

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

Source from the content-addressed store, hash-verified

135}
136
137func createObjectGeneric(specObj crclient.Object, api ClusterAPI) error {
138 err := api.Client.Create(api.Ctx, specObj)
139 switch {
140 case err == nil:
141 api.Logger.Info("Created object", "kind", reflect.TypeOf(specObj).Elem().String(), "name", specObj.GetName())
142 return NewNotInSync(specObj, CreatedObjectReason)
143 case k8sErrors.IsAlreadyExists(err):
144 // Need to try to update the object to address an edge case where removing a labelselector
145 // results in the object not being tracked by the controller's cache.
146 return updateObjectGeneric(specObj, nil, api)
147 case k8sErrors.IsInvalid(err), k8sErrors.IsForbidden(err):
148 return &UnrecoverableSyncError{err}
149 default:
150 return err
151 }
152}
153
154func updateObjectGeneric(specObj, clusterObj crclient.Object, api ClusterAPI) error {
155 updateFunc := getUpdateFunc(specObj)

Callers 2

SyncObjectWithClusterFunction · 0.85

Calls 3

NewNotInSyncFunction · 0.85
updateObjectGenericFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected