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

Validate removed attributes before required ones #263

Closed
QuentinBrosse opened this issue Nov 27, 2019 · 2 comments
Closed

Validate removed attributes before required ones #263

QuentinBrosse opened this issue Nov 27, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@QuentinBrosse
Copy link

Hi,

Validate the removed attributes before the required ones would allow a better UX.

Example

Here is the first version of a test schema:

&schema.Resource{
	Schema: map[string]*schema.Schema{
		"offer_id": {
			Type:     schema.TypeString,
			Required: true,
			ForceNew: true,
		},
	},
}

A bit later, we decide to replace the offer_id by offer (to handle offer name and UUID in the same attribute). After depreciating the offer_id field during some releases, we decide to remove it with the Schema.Removed field:

&schema.Resource{
	Schema: map[string]*schema.Schema{
		"offer": {
			Type:     schema.TypeString,
			Required: true,
			ForceNew: true,
		},
		"offer_id": {
			Type:     schema.TypeString,
			Optional: true,
			Removed:  "Please use offer attribute instead",
		},
	},
}

After the provider update, the user will still have this old configuration:

resource "scaleway_test" "test" {
  offer_id = "11111111-1111-1111-1111-111111111111"
}

The terraform [validate|plan] command will throw this error:

Error: Missing required argument

  on example.tf line 15, in resource "scaleway_bla" "bla":
  15: resource "scaleway_test" "test" {

The argument "offer" is required, but no definition was found.

The user does not understand why the offer attribute is required, he already has an offer_id attribute. If the removed validation was done before the required one, the user would have this error:

Error: "offer_id": [REMOVED] Please use offer attribute instead

  on example.tf line 15, in resource "scaleway_bla" "bla":
  15: resource "scaleway_test" "test" {

In this way, the user will understand easily that the offer_id attribute has been replaced by the offer one.

@radeksimko radeksimko added the enhancement New feature or request label Dec 6, 2019
@paultyng
Copy link
Contributor

paultyng commented Apr 27, 2020

We are planning to drop support for Removed in v2, so this issue will no longer be relevant I believe.

See #320 for tracking the removal.

@ghost
Copy link

ghost commented May 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators May 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants