MCPcopy Create free account
hub / github.com/crossplane-contrib/function-patch-and-transform / ToComposedResource

Function ToComposedResource

patches.go:274–295  ·  view source on GitHub ↗

ToComposedResource returns true if the supplied patch is to a composed resource, not from it.

(p *v1beta1.ComposedPatch)

Source from the content-addressed store, hash-verified

272// ToComposedResource returns true if the supplied patch is to a composed
273// resource, not from it.
274func ToComposedResource(p *v1beta1.ComposedPatch) bool {
275 switch p.GetType() {
276 // From observed XR to desired composed resource.
277 case v1beta1.PatchTypeFromCompositeFieldPath, v1beta1.PatchTypeCombineFromComposite:
278 return true
279 // From environment to desired composed resource.
280 case v1beta1.PatchTypeFromEnvironmentFieldPath, v1beta1.PatchTypeCombineFromEnvironment:
281 return true
282
283 // From composed resource to composite.
284 case v1beta1.PatchTypeToCompositeFieldPath, v1beta1.PatchTypeCombineToComposite:
285 return false
286 // From composed resource to environment.
287 case v1beta1.PatchTypeToEnvironmentFieldPath, v1beta1.PatchTypeCombineToEnvironment:
288 return false
289 // We can ignore patchsets; they're inlined.
290 case v1beta1.PatchTypePatchSet:
291 return false
292 }
293
294 return false
295}
296
297// Combine calls the appropriate combiner.
298func Combine(c v1beta1.Combine, vars []any) (any, error) {

Callers 2

RunFunctionMethod · 0.85
ApplyComposedPatchFunction · 0.85

Calls 1

GetTypeMethod · 0.65

Tested by

no test coverage detected