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)
| 407 | // ResolveConvert resolves a Convert transform by looking up the appropriate |
| 408 | // conversion function for the given input type and invoking it. |
| 409 | func 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 | |
| 425 | type conversionPair struct { |
| 426 | from v1beta1.TransformIOType |