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

Function resolveMathMultiply

transforms.go:125–136  ·  view source on GitHub ↗

resolveMathMultiply resolves a multiply transform, returning an error if the input is not a number. If the input is a float, the result will be a float64, otherwise it will be an int64.

(t *v1beta1.MathTransform, input any)

Source from the content-addressed store, hash-verified

123// input is not a number. If the input is a float, the result will be a float64, otherwise
124// it will be an int64.
125func resolveMathMultiply(t *v1beta1.MathTransform, input any) (any, error) {
126 switch i := input.(type) {
127 case int:
128 return int64(i) * *t.Multiply, nil
129 case int64:
130 return i * *t.Multiply, nil
131 case float64:
132 return i * float64(*t.Multiply), nil
133 default:
134 return nil, errors.Errorf(errFmtMathInputNonNumber, input)
135 }
136}
137
138// resolveMathClamp resolves a clamp transform, returning an error if the input
139// is not a number. depending on the type of clamp, the result will be either

Callers 1

ResolveMathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected