Skip to content

Commit

Permalink
++ fix CRD patching: patch metadata before patching /spec, fix proble…
Browse files Browse the repository at this point in the history
…m with finalizers on CRDs

Signed-off-by: Ivan Mikheykin <[email protected]>
  • Loading branch information
diafour committed Jul 15, 2024
1 parent f6d37bb commit b538072
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion images/kube-api-proxy/pkg/rewriter/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ func renameCRDSpec(rules *RewriteRules, resourceRule *ResourceRule, spec []byte)
func RenameCRDPatch(rules *RewriteRules, resourceRule *ResourceRule, obj []byte) ([]byte, error) {
var err error

obj, err = RenameMetadataPatch(rules, obj)
if err != nil {
return nil, fmt.Errorf("rename metadata patches for CRD: %w", err)
}

patches := gjson.ParseBytes(obj).Array()
if len(patches) == 0 {
return obj, nil
Expand Down Expand Up @@ -260,5 +265,5 @@ func RenameCRDPatch(rules *RewriteRules, resourceRule *ResourceRule, obj []byte)
return obj, nil
}

return RenameMetadataPatch(rules, newPatches)
return newPatches, nil
}

0 comments on commit b538072

Please sign in to comment.