From 3b7208117b508886f668cbb38b06fd3c4b421064 Mon Sep 17 00:00:00 2001 From: Dmitry Lopatin Date: Tue, 28 May 2024 14:37:58 +0300 Subject: [PATCH] fix(kube-api-rewriter): add rewrite ownerReferences - delete edits with patching Signed-off-by: Dmitry Lopatin --- images/kube-api-proxy/pkg/proxy/handler.go | 2 +- images/kube-api-proxy/pkg/rewriter/rule_rewriter.go | 12 +----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/images/kube-api-proxy/pkg/proxy/handler.go b/images/kube-api-proxy/pkg/proxy/handler.go index 8bdd170ac..8f43307be 100644 --- a/images/kube-api-proxy/pkg/proxy/handler.go +++ b/images/kube-api-proxy/pkg/proxy/handler.go @@ -239,7 +239,7 @@ func (h *Handler) transformRequest(targetReq *rewriter.TargetRequest, req *http. var newBody []byte switch req.Method { case http.MethodPatch: - newBody, err = h.Rewriter.RewritePatch(targetReq, bodyBytes, ToTargetAction(h.ProxyMode)) + newBody, err = h.Rewriter.RewritePatch(targetReq, bodyBytes) default: newBody, err = h.Rewriter.RewriteJSONPayload(targetReq, bodyBytes, ToTargetAction(h.ProxyMode)) } diff --git a/images/kube-api-proxy/pkg/rewriter/rule_rewriter.go b/images/kube-api-proxy/pkg/rewriter/rule_rewriter.go index 9314bbe8a..8fe8a6513 100644 --- a/images/kube-api-proxy/pkg/rewriter/rule_rewriter.go +++ b/images/kube-api-proxy/pkg/rewriter/rule_rewriter.go @@ -198,7 +198,7 @@ func (rw *RuleBasedRewriter) RewriteJSONPayload(targetReq *TargetRequest, obj [] // RewritePatch rewrites patches for some known objects. // Only rename action is required for patches. -func (rw *RuleBasedRewriter) RewritePatch(targetReq *TargetRequest, obj []byte, action Action) ([]byte, error) { +func (rw *RuleBasedRewriter) RewritePatch(targetReq *TargetRequest, obj []byte) ([]byte, error) { if targetReq.IsCRD() { // Check if CRD is known. _, resRule := rw.Rules.ResourceRules(targetReq.OrigGroup(), targetReq.OrigResourceType()) @@ -207,16 +207,6 @@ func (rw *RuleBasedRewriter) RewritePatch(targetReq *TargetRequest, obj []byte, } return RenameCRDPatch(rw.Rules, resRule, obj) - } else if targetReq.IsCore() { - fmt.Println("dlopatin-debug-out: exex RewritePatch( . . . ", string(obj)) - rwrBytes, err := RewriteOwnerReferences(rw.Rules, obj, action) - - // Return obj bytes as-is in case of the error. - if err != nil { - return obj, err - } - - return rwrBytes, nil } return obj, nil