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

Multi-attribute validation #233

Open
radeksimko opened this issue Nov 5, 2019 · 1 comment
Open

Multi-attribute validation #233

radeksimko opened this issue Nov 5, 2019 · 1 comment
Labels
enhancement New feature or request terraform-plugin-framework Resolved in terraform-plugin-framework

Comments

@radeksimko
Copy link
Member

radeksimko commented Nov 5, 2019

Problem Statement

Providers today are able to validate multiple attributes using customdiff's Validate* functions:

https://godoc.org/github.com/hashicorp/terraform-plugin-sdk/helper/customdiff#ValidateValue
https://godoc.org/github.com/hashicorp/terraform-plugin-sdk/helper/customdiff#ValidateChange

However - as the package name suggests - this package is not meant to deal with such validation and using it for simple multi-attribute plan-time validation can feel awkward.

Such validation also doesn't run during terraform validate, but "later" during terraform plan.

Examples

https://github.com/terraform-providers/terraform-provider-azurerm/blob/94cf18b287d634ee16aa5e37d3a73d3e8a356fa4/azurerm/resource_arm_cosmosdb_account.go#L384-L392

https://github.com/terraform-providers/terraform-provider-aws/blob/98b8b848ca94031b20c3e626c9d40484e3af80de/aws/resource_aws_lb_target_group.go#L684-L692

hashicorp/terraform-provider-aws#10963

Proposal

TODO

@Tensho
Copy link

Tensho commented Aug 18, 2020

Desperately would love to have it for terraform-provider-aws provider code simplification. Is there any plugin SDK design ossification on the way?

@bflad bflad added the terraform-plugin-framework Resolved in terraform-plugin-framework label Mar 30, 2022
sfc-gh-asawicki added a commit to Snowflake-Labs/terraform-provider-snowflake that referenced this issue Nov 8, 2024
Apply various fixes:
- Fix handling compute pool privileges (#2717)
- Fail to reproduce the problem with password policy user attachment
(#3005)
- Adapt user to BCR Bundle 2024_08 (#3125)
- Loosen identifier validations - parentheses (#3127) - check below
- Prove MANAGE SHARE TARGET works correctly (#3153)

On the identifier validation topic:
ParseIdentifierString should generally allow parentheses. It should
validate them for the identifiers for functions, procedures, etc.
Because of that:
- this validation was removed
- method usages were analyzed to check what consequences it has
throughout the provider
  - DecodeSnowflakeAccountIdentifier - OK, account level identifier
  - DecodeSnowflakeParameterID
- buildOptsForGrantsOn (grants datasource) - NOK, had to fix the logic
- ContainsIdentifierIgnoringQuotes - OK, transitively used only in
network policies
    - TestDecodeSnowflakeParameterID - OK
    - IsValidIdentifier - OK, used for other identifier types
- pkg/resource - OK, used in streams, table constraints and tag masking
policy associations
  - suppressIdentifierQuoting
- used in non-grant resources with non-argument identifier types - OK
- used in grant resources - OK, the validation will be relaxed for now,
diff suppression won't work correctly for the identifiers with
arguments, will be addressed with functions/procedures rework
(multi-field validation could be handled for such cases, issue added;
references:
hashicorp/terraform-plugin-sdk#354,
hashicorp/terraform-plugin-sdk#233)
- suppressIdentifierQuotingPartiallyQualifiedName - as above; currently
used only for streams
- parseIdentifier - used by other identifier types (type constraints
added)
- ParseObjectIdentifierString - OK, used for other identifier types
(ParseSchemaObjectIdentifierWithArguments is dedicated for identifier
with arguments)
- ParseSchemaObjectIdentifierWithArguments - OK, we split the input
string on first opening paren (so there are no other opening parens
there)
- Test_ParseIdentifierString - tests adjusted for the removed validation

Others:
- Remove unused privileges.go file
- Fix preview resources list for V1

References:
-
#2717
-
#3005
-
#3125
-
#3127
-
#3153
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

No branches or pull requests

4 participants