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

helper/schema: Do not collapse TypeSet hash values when configuration block contains only Computed attributes #22719

Closed
wants to merge 1 commit into from

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Sep 6, 2019

Reference: hashicorp/terraform-provider-aws#7198

When a resource schema contains the following:

"config_block_attribute": {
	Type:     schema.TypeSet,
	Computed: true,
	Elem: &schema.Resource{
		Schema: map[string]*schema.Schema{
			"attribute1": {
				Type:     schema.TypeBool,
				Computed: true,
			},
			"attribute2": {
				Type:     schema.TypeString,
				Computed: true,
			},
		},
	},
},

The TypeSet hash values were previously all collapsed to the zero-value, which meant that multiple set entries were lost. Here we check that all of the attributes are not just Computed: true. If they are all Computed: true attributes, ignore the check for user-defined attributes to compute the hash value.

… block contains only Computed attributes

Reference: hashicorp/terraform-provider-aws#7198

When a resource schema contains the following:

```go
"config_block_attribute": {
	Type:     schema.TypeSet,
	Computed: true,
	Elem: &schema.Resource{
		Schema: map[string]*schema.Schema{
			"attribute1": {
				Type:     schema.TypeBool,
				Computed: true,
			},
			"attribute2": {
				Type:     schema.TypeString,
				Computed: true,
			},
		},
	},
},
```

The TypeSet hash values were previously all collapsed to the zero-value, which meant that multiple set entries were lost. Here we check that all of the attributes are not just `Computed: true`. If they are all `Computed: true` attributes, ignore the check for user-defined attributes to compute the hash value.
@apparentlymart
Copy link
Contributor

Hi @bflad! What's your sense of the urgency of this? My preference would be to wait until the SDK split is complete and then reopen this in the separate SDK repository, just to minimize migration friction this might otherwise cause.

@bflad
Copy link
Contributor Author

bflad commented Sep 10, 2019

Hey @apparentlymart 👋 I believe low urgency in at least in the AWS Provider as the amount/places where this is currently affecting things is not high/critical in nature. I’m okay duplicating this pull request over although there is a plan to automatically migrate commits as well. 👍 Either which way works well though in this case. Thanks!

@radeksimko
Copy link
Member

Thanks for the PR @bflad

I agree with the sentiment here - unless it's really burning I'd prefer to keep this open at least until we publish the SDK 1.0.0 and make this part of 1.x.x. That way if this introduces any (other) bugs (hopefully not) we have much better chance of a) pinpointing it to a release, and b) people can still migrate to 1.0.0 without having to consume any other (potentially risky) changes.

@radeksimko radeksimko removed the request for review from a team September 12, 2019 07:50
bflad added a commit to hashicorp/terraform-plugin-sdk that referenced this pull request Oct 8, 2019
… block contains only Computed attributes

Reference: hashicorp/terraform-provider-aws#7198
Reference: hashicorp/terraform-provider-aws#10045
Reference: hashicorp/terraform-provider-aws#10339
Reference: hashicorp/terraform#22719

When a resource schema contains the following:

```go
"config_block_attribute": {
	Type:     schema.TypeSet,
	Computed: true,
	Elem: &schema.Resource{
		Schema: map[string]*schema.Schema{
			"attribute1": {
				Type:     schema.TypeBool,
				Computed: true,
			},
			"attribute2": {
				Type:     schema.TypeString,
				Computed: true,
			},
		},
	},
},
```

The TypeSet hash values were previously all collapsed to the zero-value, which meant that multiple set entries were lost. Here we check that all of the attributes are not just `Computed: true`. If they are all `Computed: true` attributes, ignore the check for user-defined attributes to compute the hash value.
@bflad
Copy link
Contributor Author

bflad commented Oct 8, 2019

Closing in preference of hashicorp/terraform-plugin-sdk#197

@bflad bflad closed this Oct 8, 2019
@bflad bflad deleted the b-helper-schema-TypeSet-hash-all-computed branch October 8, 2019 15:41
@appilon appilon removed the sdkv1 [PRs only] Marks changes that may potentially need to be ported to the plugi nSDK label Oct 23, 2019
@ghost
Copy link

ghost commented Nov 8, 2019

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 Nov 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants