From f9ca4aafc6fd55b8c4b4ddc51863abcfefc65a85 Mon Sep 17 00:00:00 2001 From: Antoine Pelisse Date: Fri, 7 Dec 2018 09:46:09 -0800 Subject: [PATCH] apply: fix detection of non-dry-run enabled servers Apply only checks that the server supports dry-run in the create path, not the update path, which is pretty bad. --- pkg/kubectl/cmd/apply/apply.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/kubectl/cmd/apply/apply.go b/pkg/kubectl/cmd/apply/apply.go index 4fe80c433b..30053e2d48 100644 --- a/pkg/kubectl/cmd/apply/apply.go +++ b/pkg/kubectl/cmd/apply/apply.go @@ -344,6 +344,13 @@ func (o *ApplyOptions) Run() error { return err } + // If server-dry-run is requested but the type doesn't support it, fail right away. + if o.ServerDryRun { + if err := dryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil { + return err + } + } + if info.Namespaced() { visitedNamespaces.Insert(info.Namespace) } @@ -367,12 +374,6 @@ func (o *ApplyOptions) Run() error { if !errors.IsNotFound(err) { return cmdutil.AddSourceToErr(fmt.Sprintf("retrieving current configuration of:\n%s\nfrom server for:", info.String()), info.Source, err) } - // If server-dry-run is requested but the type doesn't support it, fail right away. - if o.ServerDryRun { - if err := dryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil { - return err - } - } // Create the resource if it doesn't exist // First, update the annotation used by kubectl apply