mirror of
https://github.com/kubernetes/kubectl.git
synced 2026-05-28 04:35:50 -04:00
Remove KUBECTL_OPENAPIV3_PATCH feature gate as the feature is stable
Kubernetes-commit: 9382fa8b70be73b0df83d7c2793cf8efd95ec773
This commit is contained in:
parent
c88fdcad7d
commit
a06bba9d57
4 changed files with 11 additions and 78 deletions
|
|
@ -284,13 +284,11 @@ func (flags *ApplyFlags) ToOptions(f cmdutil.Factory, cmd *cobra.Command, baseNa
|
|||
}
|
||||
|
||||
var openAPIV3Root openapi3.Root
|
||||
if !cmdutil.OpenAPIV3Patch.IsDisabled() {
|
||||
openAPIV3Client, err := f.OpenAPIV3Client()
|
||||
if err == nil {
|
||||
openAPIV3Root = openapi3.NewRoot(openAPIV3Client)
|
||||
} else {
|
||||
klog.V(4).Infof("warning: OpenAPI V3 Patch is enabled but is unable to be loaded. Will fall back to OpenAPI V2")
|
||||
}
|
||||
openAPIV3Client, err := f.OpenAPIV3Client()
|
||||
if err == nil {
|
||||
openAPIV3Root = openapi3.NewRoot(openAPIV3Client)
|
||||
} else {
|
||||
klog.V(4).Infof("warning: OpenAPI V3 Patch is enabled but is unable to be loaded. Will fall back to OpenAPI V2")
|
||||
}
|
||||
|
||||
validationDirective, err := cmdutil.GetValidationDirective(cmd)
|
||||
|
|
|
|||
|
|
@ -114,11 +114,8 @@ func (o *OpenAPIV3ClientAlwaysPanic) Paths() (map[string]openapiclient.GroupVers
|
|||
func noopOpenAPIV3Patch(t *testing.T, f func(t *testing.T)) {
|
||||
f(t)
|
||||
}
|
||||
func disableOpenAPIV3Patch(t *testing.T, f func(t *testing.T)) {
|
||||
cmdtesting.WithAlphaEnvsDisabled([]cmdutil.FeatureGate{cmdutil.OpenAPIV3Patch}, t, f)
|
||||
}
|
||||
|
||||
var applyFeatureToggles = []func(*testing.T, func(t *testing.T)){noopOpenAPIV3Patch, disableOpenAPIV3Patch}
|
||||
var applyFeatureToggles = []func(*testing.T, func(t *testing.T)){noopOpenAPIV3Patch}
|
||||
|
||||
type testOpenAPISchema struct {
|
||||
OpenAPISchemaFn func() (openapi.Resources, error)
|
||||
|
|
@ -742,60 +739,6 @@ func TestApplyObjectWithoutAnnotation(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestOpenAPIV3PatchFeatureFlag(t *testing.T) {
|
||||
// OpenAPIV3 smp apply is on by default.
|
||||
// Test that users can disable it to use OpenAPI V2 smp
|
||||
// An OpenAPI V3 root that always panics is used to ensure
|
||||
// the v3 code path is never exercised when the feature is disabled
|
||||
cmdtesting.InitTestErrorHandler(t)
|
||||
nameRC, currentRC := readAndAnnotateReplicationController(t, filenameRC)
|
||||
pathRC := "/namespaces/test/replicationcontrollers/" + nameRC
|
||||
|
||||
t.Run("test apply when a local object is specified - openapi v2 smp", func(t *testing.T) {
|
||||
disableOpenAPIV3Patch(t, func(t *testing.T) {
|
||||
tf := cmdtesting.NewTestFactory().WithNamespace("test")
|
||||
defer tf.Cleanup()
|
||||
|
||||
tf.UnstructuredClient = &fake.RESTClient{
|
||||
NegotiatedSerializer: resource.UnstructuredPlusDefaultContentConfig().NegotiatedSerializer,
|
||||
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
|
||||
switch p, m := req.URL.Path, req.Method; {
|
||||
case p == pathRC && m == "GET":
|
||||
bodyRC := io.NopCloser(bytes.NewReader(currentRC))
|
||||
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, nil
|
||||
case p == pathRC && m == "PATCH":
|
||||
validatePatchApplication(t, req, types.StrategicMergePatchType)
|
||||
bodyRC := io.NopCloser(bytes.NewReader(currentRC))
|
||||
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: bodyRC}, nil
|
||||
default:
|
||||
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
|
||||
return nil, nil
|
||||
}
|
||||
}),
|
||||
}
|
||||
tf.OpenAPISchemaFunc = FakeOpenAPISchema.OpenAPISchemaFn
|
||||
tf.OpenAPIV3ClientFunc = AlwaysPanicSchema.OpenAPIV3ClientFunc
|
||||
tf.ClientConfigVal = cmdtesting.DefaultClientConfig()
|
||||
|
||||
ioStreams, _, buf, errBuf := genericiooptions.NewTestIOStreams()
|
||||
cmd := NewCmdApply("kubectl", tf, ioStreams)
|
||||
cmd.Flags().Set("filename", filenameRC)
|
||||
cmd.Flags().Set("output", "name")
|
||||
cmd.Run(cmd, []string{})
|
||||
|
||||
// uses the name from the file, not the response
|
||||
expectRC := "replicationcontroller/" + nameRC + "\n"
|
||||
if buf.String() != expectRC {
|
||||
t.Fatalf("unexpected output: %s\nexpected: %s", buf.String(), expectRC)
|
||||
}
|
||||
if errBuf.String() != "" {
|
||||
t.Fatalf("unexpected error output: %s", errBuf.String())
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func TestOpenAPIV3DoesNotLoadV2(t *testing.T) {
|
||||
cmdtesting.InitTestErrorHandler(t)
|
||||
nameRC, currentRC := readAndAnnotateReplicationController(t, filenameRC)
|
||||
|
|
|
|||
|
|
@ -642,13 +642,11 @@ func (o *DiffOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []str
|
|||
|
||||
if !o.ServerSideApply {
|
||||
o.OpenAPIGetter = f
|
||||
if !cmdutil.OpenAPIV3Patch.IsDisabled() {
|
||||
openAPIV3Client, err := f.OpenAPIV3Client()
|
||||
if err == nil {
|
||||
o.OpenAPIV3Root = openapi3.NewRoot(openAPIV3Client)
|
||||
} else {
|
||||
klog.V(4).Infof("warning: OpenAPI V3 Patch is enabled but is unable to be loaded. Will fall back to OpenAPI V2")
|
||||
}
|
||||
openAPIV3Client, err := f.OpenAPIV3Client()
|
||||
if err == nil {
|
||||
o.OpenAPIV3Root = openapi3.NewRoot(openAPIV3Client)
|
||||
} else {
|
||||
klog.V(4).Infof("warning: OpenAPI V3 Patch is enabled but is unable to be loaded. Will fall back to OpenAPI V2")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -437,12 +437,6 @@ const (
|
|||
// Separate kubectl user preferences.
|
||||
KubeRC FeatureGate = "KUBECTL_KUBERC"
|
||||
|
||||
// owner: @soltysh
|
||||
// kep: https://kep.k8s.io/3515
|
||||
//
|
||||
// Improved kubectl apply --prune behavior.
|
||||
OpenAPIV3Patch FeatureGate = "KUBECTL_OPENAPIV3_PATCH"
|
||||
|
||||
// owner: @justinb
|
||||
// kep: https://kep.k8s.io/3659
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in a new issue