From e78d05daec30a757b3817bbdc78f5ea0c1c7ea17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arda=20G=C3=BC=C3=A7l=C3=BC?= Date: Fri, 3 Mar 2023 13:04:03 +0300 Subject: [PATCH] Skip hasSupport check for List type Currently, when user applies a List type resource, there is an unnecessary request to customresourcedefinitions endpoint by validation. The reason of this request is that validation can not find List type in OpenAPI schema and behaves this type as CRD. This PR returns unsupported when List type is applied. In terms of functionality, there is no bug or any issue, because eventually `schemaValidation` detects this List and executes `validateList` function. Only issue is unnecessary CRD enpoint request. --- .../k8s.io/cli-runtime/pkg/resource/query_param_verifier.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/cli-runtime/pkg/resource/query_param_verifier.go b/staging/src/k8s.io/cli-runtime/pkg/resource/query_param_verifier.go index bc0769530fe..d933b89d8b1 100644 --- a/staging/src/k8s.io/cli-runtime/pkg/resource/query_param_verifier.go +++ b/staging/src/k8s.io/cli-runtime/pkg/resource/query_param_verifier.go @@ -19,7 +19,6 @@ package resource import ( "errors" "fmt" - openapi_v2 "github.com/google/gnostic/openapiv2" yaml "gopkg.in/yaml.v2" "k8s.io/apimachinery/pkg/runtime/schema" @@ -72,6 +71,10 @@ const ( // HasSupport checks if the given gvk supports the query param configured on v func (v *QueryParamVerifier) HasSupport(gvk schema.GroupVersionKind) error { + if (gvk == schema.GroupVersionKind{Version: "v1", Kind: "List"}) { + return NewParamUnsupportedError(gvk, v.queryParam) + } + oapi, err := v.openAPIGetter.OpenAPISchema() if err != nil { return fmt.Errorf("failed to download openapi: %v", err)