Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConflictsWith deprecation warning #727

Open
dak1n1 opened this issue Mar 18, 2021 · 2 comments · May be fixed by #745
Open

ConflictsWith deprecation warning #727

dak1n1 opened this issue Mar 18, 2021 · 2 comments · May be fixed by #745
Labels
enhancement New feature or request terraform-plugin-framework Resolved in terraform-plugin-framework

Comments

@dak1n1
Copy link

dak1n1 commented Mar 18, 2021

SDK version

github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.4

Use-cases

Summary:

Warn users prior to the breaking change of enabling ConflictsWith on provider configuration attributes.

Details:

In the Kubernetes and Helm providers, we're currently considering enabling ConflictsWith on some mutually-exclusive authentication options in the provider config. However, to do so would be a breaking change, since the provider has supported setting multiple authentication methods since it was first created.

In the past, the provider would intake all configuration options (even ones that cannot be used together) and it would assemble a Kubernetes client config from it. The actual options being used to authenticate to a cluster could be much different from what the user expects, and there was a fairly widespread problem of users accidentally connecting to the wrong cluster. To mitigate this, we want to make the configuration process more straightforward and explicit, so that users know exactly which of their options are actually being used.

Attempted Solutions

As far as I could tell, the only way to send a warning to users (without using debug logging) would be to use the Deprecated field on the schema attribute. I tried this, but I couldn't find a way to conditionally set Deprecated, since I only want to warn them when multiple options are used together (simulating ConflictsWith, but with a deprecation warning instead of a fatal error).

Proposal

I want to be careful not to disrupt the users' CI pipelines that would come to a halt if I were to enable ConflictsWith without warning. My proposal is to create a new field that we could set on the schema, similar to Deprecated, where we could give it a warning string and also pass in the names of the conflicting attributes.

"client_key": {
	Type:        schema.TypeString,
	Optional:    true,
	Description: "PEM-encoded client certificate key for TLS authentication.",
	Type:          schema.TypeString,
	Optional:      true,
	DefaultFunc:   schema.EnvDefaultFunc("KUBE_CLIENT_KEY_DATA", nil),
	ConflictsWithWarning: "`client_key` is incompatible with one or more of the configured options. The provider will choose one  and continue, but this feature will be removed in a future version. Please update your configuration to choose only one of the following:", []string{"config_path", "config_paths", "username", "password", "exec", "insecure"},
},

References

@dak1n1 dak1n1 added the enhancement New feature or request label Mar 18, 2021
@bflad
Copy link
Contributor

bflad commented Mar 18, 2021

It may be possible to return a diagnostic warning using schema.Provider.ConfigureContextFunc, although warnings themselves can cause strange behavior before Terraform CLI version 0.15 releases.

@dak1n1
Copy link
Author

dak1n1 commented Apr 16, 2021

FYI, I talked with Paddy about this feature request and he gave me some direction about how I can implement it in the SDK. I'll have a PR for it soon.

@dak1n1 dak1n1 linked a pull request Apr 21, 2021 that will close this issue
@bflad bflad added the terraform-plugin-framework Resolved in terraform-plugin-framework label Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request terraform-plugin-framework Resolved in terraform-plugin-framework
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants