Commit c7ba05ea authored by Antoine Pelisse's avatar Antoine Pelisse Committed by Antoine Pelisse

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.
parent c2130030
...@@ -343,6 +343,13 @@ func (o *ApplyOptions) Run() error { ...@@ -343,6 +343,13 @@ func (o *ApplyOptions) Run() error {
return err 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() { if info.Namespaced() {
visitedNamespaces.Insert(info.Namespace) visitedNamespaces.Insert(info.Namespace)
} }
...@@ -366,12 +373,6 @@ func (o *ApplyOptions) Run() error { ...@@ -366,12 +373,6 @@ func (o *ApplyOptions) Run() error {
if !errors.IsNotFound(err) { if !errors.IsNotFound(err) {
return cmdutil.AddSourceToErr(fmt.Sprintf("retrieving current configuration of:\n%s\nfrom server for:", info.String()), info.Source, 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 // Create the resource if it doesn't exist
// First, update the annotation used by kubectl apply // First, update the annotation used by kubectl apply
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment