Remove unused selflink parameters from ContextBasedNaming

This commit is contained in:
Wojciech Tyczyński 2022-01-14 10:00:04 +01:00
parent 0ad588b27b
commit 1e0b9c6e20
3 changed files with 10 additions and 32 deletions

View File

@ -19,7 +19,6 @@ package apiserver
import ( import (
"fmt" "fmt"
"net/http" "net/http"
"path"
"sort" "sort"
"strings" "strings"
"sync" "sync"
@ -814,14 +813,6 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
replicasPathInCustomResource, replicasPathInCustomResource,
) )
selfLinkPrefix := ""
switch crd.Spec.Scope {
case apiextensionsv1.ClusterScoped:
selfLinkPrefix = "/" + path.Join("apis", crd.Spec.Group, v.Name) + "/" + crd.Status.AcceptedNames.Plural + "/"
case apiextensionsv1.NamespaceScoped:
selfLinkPrefix = "/" + path.Join("apis", crd.Spec.Group, v.Name, "namespaces") + "/"
}
clusterScoped := crd.Spec.Scope == apiextensionsv1.ClusterScoped clusterScoped := crd.Spec.Scope == apiextensionsv1.ClusterScoped
// CRDs explicitly do not support protobuf, but some objects returned by the API server do // CRDs explicitly do not support protobuf, but some objects returned by the API server do
@ -843,9 +834,8 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
requestScopes[v.Name] = &handlers.RequestScope{ requestScopes[v.Name] = &handlers.RequestScope{
Namer: handlers.ContextBasedNaming{ Namer: handlers.ContextBasedNaming{
Namer: meta.NewAccessor(), Namer: meta.NewAccessor(),
ClusterScoped: clusterScoped, ClusterScoped: clusterScoped,
SelfLinkPathPrefix: selfLinkPrefix,
}, },
Serializer: negotiatedSerializer, Serializer: negotiatedSerializer,
ParameterCodec: parameterCodec, ParameterCodec: parameterCodec,
@ -896,10 +886,8 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
scaleScope.Serializer = serializer.NewCodecFactory(scaleConverter.Scheme()) scaleScope.Serializer = serializer.NewCodecFactory(scaleConverter.Scheme())
scaleScope.Kind = autoscalingv1.SchemeGroupVersion.WithKind("Scale") scaleScope.Kind = autoscalingv1.SchemeGroupVersion.WithKind("Scale")
scaleScope.Namer = handlers.ContextBasedNaming{ scaleScope.Namer = handlers.ContextBasedNaming{
Namer: meta.NewAccessor(), Namer: meta.NewAccessor(),
ClusterScoped: clusterScoped, ClusterScoped: clusterScoped,
SelfLinkPathPrefix: selfLinkPrefix,
SelfLinkPathSuffix: "/scale",
} }
if utilfeature.DefaultFeatureGate.Enabled(features.ServerSideApply) && subresources != nil && subresources.Scale != nil { if utilfeature.DefaultFeatureGate.Enabled(features.ServerSideApply) && subresources != nil && subresources.Scale != nil {
@ -921,10 +909,8 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
statusScope := *requestScopes[v.Name] statusScope := *requestScopes[v.Name]
statusScope.Subresource = "status" statusScope.Subresource = "status"
statusScope.Namer = handlers.ContextBasedNaming{ statusScope.Namer = handlers.ContextBasedNaming{
Namer: meta.NewAccessor(), Namer: meta.NewAccessor(),
ClusterScoped: clusterScoped, ClusterScoped: clusterScoped,
SelfLinkPathPrefix: selfLinkPrefix,
SelfLinkPathSuffix: "/status",
} }
if utilfeature.DefaultFeatureGate.Enabled(features.ServerSideApply) && subresources != nil && subresources.Status != nil { if utilfeature.DefaultFeatureGate.Enabled(features.ServerSideApply) && subresources != nil && subresources.Status != nil {

View File

@ -41,9 +41,6 @@ type ScopeNamer interface {
type ContextBasedNaming struct { type ContextBasedNaming struct {
Namer runtime.Namer Namer runtime.Namer
ClusterScoped bool ClusterScoped bool
SelfLinkPathPrefix string
SelfLinkPathSuffix string
} }
// ContextBasedNaming implements ScopeNamer // ContextBasedNaming implements ScopeNamer

View File

@ -19,7 +19,6 @@ package endpoints
import ( import (
"fmt" "fmt"
"net/http" "net/http"
gpath "path"
"reflect" "reflect"
"sort" "sort"
"strings" "strings"
@ -428,10 +427,8 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
apiResource.Namespaced = false apiResource.Namespaced = false
apiResource.Kind = resourceKind apiResource.Kind = resourceKind
namer := handlers.ContextBasedNaming{ namer := handlers.ContextBasedNaming{
Namer: a.group.Namer, Namer: a.group.Namer,
ClusterScoped: true, ClusterScoped: true,
SelfLinkPathPrefix: gpath.Join(a.prefix, resource) + "/",
SelfLinkPathSuffix: suffix,
} }
// Handler for standard REST verbs (GET, PUT, POST and DELETE). // Handler for standard REST verbs (GET, PUT, POST and DELETE).
@ -477,10 +474,8 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
apiResource.Namespaced = true apiResource.Namespaced = true
apiResource.Kind = resourceKind apiResource.Kind = resourceKind
namer := handlers.ContextBasedNaming{ namer := handlers.ContextBasedNaming{
Namer: a.group.Namer, Namer: a.group.Namer,
ClusterScoped: false, ClusterScoped: false,
SelfLinkPathPrefix: gpath.Join(a.prefix, namespaceParamName) + "/",
SelfLinkPathSuffix: itemPathSuffix,
} }
actions = appendIf(actions, action{"LIST", resourcePath, resourceParams, namer, false}, isLister) actions = appendIf(actions, action{"LIST", resourcePath, resourceParams, namer, false}, isLister)