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

Function ResolveConvert

transforms.go:409–423  ·  view source on GitHub ↗

ResolveConvert resolves a Convert transform by looking up the appropriate conversion function for the given input type and invoking it.

(t *v1beta1.ConvertTransform, input any)

Source from the content-addressed store, hash-verified

407// ResolveConvert resolves a Convert transform by looking up the appropriate
408// conversion function for the given input type and invoking it.
409func ResolveConvert(t *v1beta1.ConvertTransform, input any) (any, error) {
410 if err := ValidateConvertTransform(t); err != nil {
411 return nil, err
412 }
413
414 from := v1beta1.TransformIOType(fmt.Sprintf("%T", input))
415 if !from.IsValid() {
416 return nil, errors.Errorf(errFmtConvertInputTypeNotSupported, input)
417 }
418 f, err := GetConversionFunc(t, from)
419 if err != nil {
420 return nil, err
421 }
422 return f(input)
423}
424
425type conversionPair struct {
426 from v1beta1.TransformIOType

Callers 2

ResolveFunction · 0.85
TestConvertResolveFunction · 0.85

Calls 4

TransformIOTypeTypeAlias · 0.92
ValidateConvertTransformFunction · 0.85
GetConversionFuncFunction · 0.85
IsValidMethod · 0.45

Tested by 1

TestConvertResolveFunction · 0.68