From a55206c52b91aaeab7edc5328f13df573713b548 Mon Sep 17 00:00:00 2001 From: Chad Roberts Date: Thu, 16 Jan 2025 06:22:21 -0500 Subject: [PATCH] Change to not incorrectly override the patch link that is now returned by apiserver. --- go.mod | 1 + go.sum | 4 ++-- pkg/resources/common/formatter.go | 2 -- pkg/resources/common/formatter_test.go | 4 +++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 739f84a9..92a1a458 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ replace ( github.com/crewjam/saml => github.com/rancher/saml v0.2.0 github.com/knative/pkg => github.com/rancher/pkg v0.0.0-20181214184433-b04c0947ad2f github.com/matryer/moq => github.com/rancher/moq v0.0.0-20190404221404-ee5226d43009 + github.com/rancher/apiserver => github.com/crobby/apiserver v0.5.2-0.20250116110826-e76f13e6c0bd ) require ( diff --git a/go.sum b/go.sum index 3b37583b..e0697dcc 100644 --- a/go.sum +++ b/go.sum @@ -40,6 +40,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/crobby/apiserver v0.5.2-0.20250116110826-e76f13e6c0bd h1:h6r5uYWZM22kiDHHGEW06BLC1N+yMEvjWbVeXbEZKRQ= +github.com/crobby/apiserver v0.5.2-0.20250116110826-e76f13e6c0bd/go.mod h1:79I0nWWx1+D7lDwHrHxN5O+QzC2EPqJC46KfaMkd14w= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -224,8 +226,6 @@ github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= -github.com/rancher/apiserver v0.0.0-20241009200134-5a4ecca7b988 h1:e7wP0J4JQdG1FwsHt+FichFwH0ZUPTC93BI3ObmYBRU= -github.com/rancher/apiserver v0.0.0-20241009200134-5a4ecca7b988/go.mod h1:79I0nWWx1+D7lDwHrHxN5O+QzC2EPqJC46KfaMkd14w= github.com/rancher/dynamiclistener v0.6.1-rc.2 h1:PTKNKcYXZjc/lo40EivRcXuEbCXwjpnTVyhAl82lYzU= github.com/rancher/dynamiclistener v0.6.1-rc.2/go.mod h1:0KhUMHy3VcGMGavTY3i1/Mr8rVM02wFqNlUzjc+Cplg= github.com/rancher/kubernetes-provider-detector v0.1.5 h1:hWRAsWuJOemzGjz/XrbTlM7QmfO4OedvFE3QwXiH60I= diff --git a/pkg/resources/common/formatter.go b/pkg/resources/common/formatter.go index e2cdd352..7cc6da09 100644 --- a/pkg/resources/common/formatter.go +++ b/pkg/resources/common/formatter.go @@ -122,8 +122,6 @@ func formatter(summarycache *summarycache.SummaryCache, asl accesscontrol.Access if hasPatch { if attributes.DisallowMethods(resource.Schema)[http.MethodPatch] { resource.Links["patch"] = "blocked" - } else { - resource.Links["patch"] = u } } else { delete(resource.Links, "patch") diff --git a/pkg/resources/common/formatter_test.go b/pkg/resources/common/formatter_test.go index c301941b..be46fa0a 100644 --- a/pkg/resources/common/formatter_test.go +++ b/pkg/resources/common/formatter_test.go @@ -963,11 +963,12 @@ func Test_formatterLinks(t *testing.T) { }, currentLinks: map[string]string{ "default": "defaultVal", + "patch": "/v1/apps.deployments/example-ns/example-deployment", "view": "/apis/apps/v1/namespaces/example-ns/deployments/example-deployment", }, wantLinks: map[string]string{ "default": "defaultVal", - "patch": "/apis/apps/v1/namespaces/example-ns/deployments/example-deployment", + "patch": "/v1/apps.deployments/example-ns/example-deployment", "view": "/apis/apps/v1/namespaces/example-ns/deployments/example-deployment", }, }, @@ -1001,6 +1002,7 @@ func Test_formatterLinks(t *testing.T) { }, currentLinks: map[string]string{ "default": "defaultVal", + "patch": "/v1/apps.deployments/example-ns/example-deployment", "view": "/apis/apps/v1/namespaces/example-ns/deployments/example-deployment", }, wantLinks: map[string]string{