From 9580ee27f978ad19b7473a9699ec4c90308f1ddd Mon Sep 17 00:00:00 2001 From: Mark DeCrane Date: Wed, 28 Feb 2024 17:43:36 -0500 Subject: [PATCH] chore: add remote backend specfic warnings to dev override warning --- internal/command/apply.go | 3 ++- internal/command/meta_providers.go | 5 ++++- internal/command/plan.go | 4 ++-- internal/command/validate.go | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/command/apply.go b/internal/command/apply.go index e3ea24c869..8d7e57f4f0 100644 --- a/internal/command/apply.go +++ b/internal/command/apply.go @@ -260,7 +260,8 @@ func (c *ApplyCommand) OperationRequest( // Applying changes with dev overrides in effect could make it impossible // to switch back to a release version if the schema isn't compatible, // so we'll warn about it. - diags = diags.Append(c.providerDevOverrideRuntimeWarnings()) + _, isRemoteBackend := be.(BackendWithRemoteTerraformVersion) + diags = diags.Append(c.providerDevOverrideRuntimeWarnings(isRemoteBackend)) // Build the operation opReq := c.Operation(be, viewType) diff --git a/internal/command/meta_providers.go b/internal/command/meta_providers.go index 64c98f966c..f48f320d5b 100644 --- a/internal/command/meta_providers.go +++ b/internal/command/meta_providers.go @@ -198,7 +198,7 @@ func (m *Meta) providerDevOverrideInitWarnings() tfdiags.Diagnostics { // // See providerDevOverrideInitWarnings for warnings specific to the init // command. -func (m *Meta) providerDevOverrideRuntimeWarnings() tfdiags.Diagnostics { +func (m *Meta) providerDevOverrideRuntimeWarnings(backendIsRemote bool) tfdiags.Diagnostics { if len(m.ProviderDevOverrides) == 0 { return nil } @@ -208,6 +208,9 @@ func (m *Meta) providerDevOverrideRuntimeWarnings() tfdiags.Diagnostics { detailMsg.WriteString(fmt.Sprintf(" - %s in %s\n", addr.ForDisplay(), path)) } detailMsg.WriteString("\nThe behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.") + if backendIsRemote { + detailMsg.WriteString("\n\nNote that provider development overrides have only been configured locally and the remote operation won't be affected by them") + } return tfdiags.Diagnostics{ tfdiags.Sourceless( tfdiags.Warning, diff --git a/internal/command/plan.go b/internal/command/plan.go index 162e819f8c..ca5979e523 100644 --- a/internal/command/plan.go +++ b/internal/command/plan.go @@ -64,10 +64,10 @@ func (c *PlanCommand) Run(rawArgs []string) int { // object state for now. c.Meta.parallelism = args.Operation.Parallelism - diags = diags.Append(c.providerDevOverrideRuntimeWarnings()) - // Prepare the backend with the backend-specific arguments be, beDiags := c.PrepareBackend(args.State, args.ViewType) + _, isRemoteBackend := be.(BackendWithRemoteTerraformVersion) + diags = diags.Append(c.providerDevOverrideRuntimeWarnings(isRemoteBackend)) diags = diags.Append(beDiags) if diags.HasErrors() { view.Diagnostics(diags) diff --git a/internal/command/validate.go b/internal/command/validate.go index a574f00c0f..58aee99132 100644 --- a/internal/command/validate.go +++ b/internal/command/validate.go @@ -61,7 +61,7 @@ func (c *ValidateCommand) Run(rawArgs []string) int { // not be valid for a stable release, so we'll warn about that in case // the user is trying to use "terraform validate" as a sort of pre-flight // check before submitting a change. - diags = diags.Append(c.providerDevOverrideRuntimeWarnings()) + diags = diags.Append(c.providerDevOverrideRuntimeWarnings(false)) return view.Results(diags) }