toMergeOption returns the MergeOptions from the PatchPolicy's ToFieldPathPolicy, if defined.
(p PatchInterface)
| 116 | |
| 117 | // toMergeOption returns the MergeOptions from the PatchPolicy's ToFieldPathPolicy, if defined. |
| 118 | func toMergeOption(p PatchInterface) (mo *xpv1.MergeOptions, err error) { |
| 119 | if p == nil { |
| 120 | return nil, nil |
| 121 | } |
| 122 | pp := p.GetPolicy() |
| 123 | if pp == nil { |
| 124 | return nil, nil |
| 125 | } |
| 126 | switch pp.GetToFieldPathPolicy() { |
| 127 | case v1beta1.ToFieldPathPolicyReplace: |
| 128 | // nothing to do, this is the default |
| 129 | case v1beta1.ToFieldPathPolicyMergeObjects, v1beta1.ToFieldPathPolicyMergeObject: //nolint:staticcheck // MergeObject is deprecated but we must still support it. |
| 130 | mo = &xpv1.MergeOptions{KeepMapValues: ptr.To(true)} |
| 131 | case v1beta1.ToFieldPathPolicyMergeObjectsAppendArrays: |
| 132 | mo = &xpv1.MergeOptions{KeepMapValues: ptr.To(true), AppendSlice: ptr.To(true)} |
| 133 | case v1beta1.ToFieldPathPolicyForceMergeObjects: |
| 134 | mo = &xpv1.MergeOptions{KeepMapValues: ptr.To(false)} |
| 135 | case v1beta1.ToFieldPathPolicyForceMergeObjectsAppendArrays, v1beta1.ToFieldPathPolicyAppendArray: //nolint:staticcheck // AppendArray is deprecated but we must still support it. |
| 136 | mo = &xpv1.MergeOptions{AppendSlice: ptr.To(true)} |
| 137 | default: |
| 138 | // should never happen |
| 139 | return nil, errors.Errorf(errFmtInvalidPatchPolicy, pp.GetToFieldPathPolicy()) |
| 140 | } |
| 141 | return mo, nil |
| 142 | } |
| 143 | |
| 144 | // ApplyCombineFromVariablesPatch patches the "to" resource, taking a list of |
| 145 | // input variables and combining them into a single output value. The single |
no test coverage detected