Skip to content

Commit

Permalink
fix(kube-api-rewriter): add rewrite ownerReferences
Browse files Browse the repository at this point in the history
- delete edits with patching

Signed-off-by: Dmitry Lopatin <[email protected]>
  • Loading branch information
LopatinDmitr committed May 28, 2024
1 parent 34b3250 commit 3b72081
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion images/kube-api-proxy/pkg/proxy/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
12 changes: 1 addition & 11 deletions images/kube-api-proxy/pkg/rewriter/rule_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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
Expand Down

0 comments on commit 3b72081

Please sign in to comment.