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

various framework validators #29292

Merged
merged 9 commits into from
Feb 8, 2023
Merged

various framework validators #29292

merged 9 commits into from
Feb 8, 2023

Conversation

johnsonaj
Copy link
Contributor

@johnsonaj johnsonaj commented Feb 7, 2023

Description

add common validators for Framework

Relations

Relates #29135

References

Output from Acceptance Testing

$ make test TEST='./internal/flex/... -v' TESTARGS='-count=1'

==> Checking that code complies with gofmt requirements...
go test ./internal/flex/... -v -count=1 -timeout=5m
--- PASS: TestExpandStringList (0.00s)
--- PASS: TestFlattenResourceIdSinglePart (0.00s)
--- PASS: TestFlattenResourceIdIncorrectPartCount (0.00s)
--- PASS: TestFlattenResourceIdEmptyPart (0.00s)
--- PASS: TestFlattenResourceId (0.00s)
--- PASS: TestExpandResourceIdSinglePart (0.00s)
--- PASS: TestExpandResourceIdIncorrectPartCount (0.00s)
--- PASS: TestExpandResourceIdEmptyPart (0.00s)
--- PASS: TestExpandResourceId (0.00s)
--- PASS: TestExpandStringListEmptyItems (0.00s)
--- PASS: TestInt64ToFrameworkLegacy (0.00s)
    --- PASS: TestInt64ToFrameworkLegacy/valid_int64 (0.00s)
    --- PASS: TestInt64ToFrameworkLegacy/zero_int64 (0.00s)
    --- PASS: TestInt64ToFrameworkLegacy/nil_int64 (0.00s)
--- PASS: TestBoolToFramework (0.00s)
    --- PASS: TestBoolToFramework/valid_bool (0.00s)
    --- PASS: TestBoolToFramework/nil_bool (0.00s)
--- PASS: TestFloat64ToFrameworkLegacy (0.00s)
    --- PASS: TestFloat64ToFrameworkLegacy/valid_int64 (0.00s)
    --- PASS: TestFloat64ToFrameworkLegacy/zero_int64 (0.00s)
    --- PASS: TestFloat64ToFrameworkLegacy/nil_int64 (0.00s)
--- PASS: TestBoolToFrameworkLegacy (0.00s)
    --- PASS: TestBoolToFrameworkLegacy/valid_bool (0.00s)
    --- PASS: TestBoolToFrameworkLegacy/nil_bool (0.00s)
--- PASS: TestStringToFramework (0.00s)
    --- PASS: TestStringToFramework/valid_string (0.00s)
    --- PASS: TestStringToFramework/nil_string (0.00s)
    --- PASS: TestStringToFramework/empty_string (0.00s)
--- PASS: TestBoolFromFramework (0.00s)
    --- PASS: TestBoolFromFramework/valid_bool (0.00s)
    --- PASS: TestBoolFromFramework/unknown_bool (0.00s)
    --- PASS: TestBoolFromFramework/null_bool (0.00s)
--- PASS: TestInt64FromFramework (0.00s)
    --- PASS: TestInt64FromFramework/valid_int64 (0.00s)
    --- PASS: TestInt64FromFramework/null_int64 (0.00s)
    --- PASS: TestInt64FromFramework/unknown_int64 (0.00s)
    --- PASS: TestInt64FromFramework/zero_int64 (0.00s)
--- PASS: TestStringValueToFrameworkLegacy (0.00s)
    --- PASS: TestStringValueToFrameworkLegacy/valid (0.00s)
    --- PASS: TestStringValueToFrameworkLegacy/empty (0.00s)
--- PASS: TestStringFromFramework (0.00s)
    --- PASS: TestStringFromFramework/null_string (0.00s)
    --- PASS: TestStringFromFramework/empty_string (0.00s)
    --- PASS: TestStringFromFramework/unknown_string (0.00s)
    --- PASS: TestStringFromFramework/valid_string (0.00s)
--- PASS: TestStringToFrameworkLegacy (0.00s)
    --- PASS: TestStringToFrameworkLegacy/empty_string (0.00s)
    --- PASS: TestStringToFrameworkLegacy/nil_string (0.00s)
    --- PASS: TestStringToFrameworkLegacy/valid_string (0.00s)
--- PASS: TestStringToFrameworkWithTransform (0.00s)
    --- PASS: TestStringToFrameworkWithTransform/valid_string (0.00s)
    --- PASS: TestStringToFrameworkWithTransform/nil_string (0.00s)
    --- PASS: TestStringToFrameworkWithTransform/empty_string (0.00s)
--- PASS: TestFlattenFrameworkStringListLegacy (0.00s)
    --- PASS: TestFlattenFrameworkStringListLegacy/two_elements (0.00s)
    --- PASS: TestFlattenFrameworkStringListLegacy/nil_array (0.00s)
    --- PASS: TestFlattenFrameworkStringListLegacy/zero_elements (0.00s)
--- PASS: TestFloat64ToFramework (0.00s)
    --- PASS: TestFloat64ToFramework/valid_float64 (0.00s)
    --- PASS: TestFloat64ToFramework/nil_float64 (0.00s)
    --- PASS: TestFloat64ToFramework/zero_float64 (0.00s)
--- PASS: TestFlattenFrameworkStringValueSet (0.00s)
    --- PASS: TestFlattenFrameworkStringValueSet/zero_elements (0.00s)
    --- PASS: TestFlattenFrameworkStringValueSet/two_elements (0.00s)
    --- PASS: TestFlattenFrameworkStringValueSet/nil_array (0.00s)
--- PASS: TestInt64ToFramework (0.00s)
    --- PASS: TestInt64ToFramework/valid_int64 (0.00s)
    --- PASS: TestInt64ToFramework/nil_int64 (0.00s)
    --- PASS: TestInt64ToFramework/zero_int64 (0.00s)
--- PASS: TestFlattenFrameworkStringList (0.00s)
    --- PASS: TestFlattenFrameworkStringList/zero_elements (0.00s)
    --- PASS: TestFlattenFrameworkStringList/two_elements (0.00s)
    --- PASS: TestFlattenFrameworkStringList/nil_array (0.00s)
--- PASS: TestFlattenFrameworkStringValueMapLegacy (0.00s)
    --- PASS: TestFlattenFrameworkStringValueMapLegacy/zero_elements (0.00s)
    --- PASS: TestFlattenFrameworkStringValueMapLegacy/nil_map (0.00s)
    --- PASS: TestFlattenFrameworkStringValueMapLegacy/two_elements (0.00s)
--- PASS: TestSet_Difference_strings (0.00s)
    --- PASS: TestSet_Difference_strings/nil (0.00s)
    --- PASS: TestSet_Difference_strings/difference_remove (0.00s)
    --- PASS: TestSet_Difference_strings/equal (0.00s)
    --- PASS: TestSet_Difference_strings/difference (0.00s)
--- PASS: TestFlattenFrameworkStringValueListLegacy (0.00s)
    --- PASS: TestFlattenFrameworkStringValueListLegacy/two_elements (0.00s)
    --- PASS: TestFlattenFrameworkStringValueListLegacy/nil_array (0.00s)
    --- PASS: TestFlattenFrameworkStringValueListLegacy/zero_elements (0.00s)
--- PASS: TestExpandFrameworkStringValueMap (0.00s)
    --- PASS: TestExpandFrameworkStringValueMap/null (0.00s)
    --- PASS: TestExpandFrameworkStringValueMap/unknown (0.00s)
    --- PASS: TestExpandFrameworkStringValueMap/zero_elements (0.00s)
    --- PASS: TestExpandFrameworkStringValueMap/invalid_element_type (0.00s)
    --- PASS: TestExpandFrameworkStringValueMap/two_elements (0.00s)
--- PASS: TestExpandFrameworkStringValueSet (0.00s)
    --- PASS: TestExpandFrameworkStringValueSet/null (0.00s)
    --- PASS: TestExpandFrameworkStringValueSet/unknown (0.00s)
    --- PASS: TestExpandFrameworkStringValueSet/two_elements (0.00s)
    --- PASS: TestExpandFrameworkStringValueSet/zero_elements (0.00s)
    --- PASS: TestExpandFrameworkStringValueSet/invalid_element_type (0.00s)
--- PASS: TestFlattenFrameworkStringValueSetLegacy (0.00s)
    --- PASS: TestFlattenFrameworkStringValueSetLegacy/two_elements (0.00s)
    --- PASS: TestFlattenFrameworkStringValueSetLegacy/zero_elements (0.00s)
    --- PASS: TestFlattenFrameworkStringValueSetLegacy/nil_array (0.00s)
--- PASS: TestFlattenFrameworkStringValueList (0.00s)
    --- PASS: TestFlattenFrameworkStringValueList/nil_array (0.00s)
    --- PASS: TestFlattenFrameworkStringValueList/zero_elements (0.00s)
    --- PASS: TestFlattenFrameworkStringValueList/two_elements (0.00s)
--- PASS: TestExpandFrameworkStringList (0.00s)
    --- PASS: TestExpandFrameworkStringList/unknown (0.00s)
    --- PASS: TestExpandFrameworkStringList/zero_elements (0.00s)
    --- PASS: TestExpandFrameworkStringList/two_elements (0.00s)
    --- PASS: TestExpandFrameworkStringList/null (0.00s)
    --- PASS: TestExpandFrameworkStringList/invalid_element_type (0.00s)
--- PASS: TestStringValueToFramework (0.00s)
    --- PASS: TestStringValueToFramework/empty (0.00s)
    --- PASS: TestStringValueToFramework/valid (0.00s)
--- PASS: TestExpandFrameworkStringSet (0.00s)
    --- PASS: TestExpandFrameworkStringSet/unknown (0.00s)
    --- PASS: TestExpandFrameworkStringSet/zero_elements (0.00s)
    --- PASS: TestExpandFrameworkStringSet/two_elements (0.00s)
    --- PASS: TestExpandFrameworkStringSet/null (0.00s)
    --- PASS: TestExpandFrameworkStringSet/invalid_element_type (0.00s)
--- PASS: TestExpandFrameworkStringValueList (0.00s)
    --- PASS: TestExpandFrameworkStringValueList/unknown (0.00s)
    --- PASS: TestExpandFrameworkStringValueList/null (0.00s)
    --- PASS: TestExpandFrameworkStringValueList/two_elements (0.00s)
    --- PASS: TestExpandFrameworkStringValueList/invalid_element_type (0.00s)
    --- PASS: TestExpandFrameworkStringValueList/zero_elements (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/flex	0.240s

...

@github-actions
Copy link

github-actions bot commented Feb 7, 2023

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added flex Pertains to FLatteners and EXpanders. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XL Managed by automation to categorize the size of a PR. and removed tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. flex Pertains to FLatteners and EXpanders. labels Feb 7, 2023
@github-actions github-actions bot added flex Pertains to FLatteners and EXpanders. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Feb 7, 2023
@johnsonaj
Copy link
Contributor Author

Tests for framework validators

$ make test TEST='./internal/framework/... -v' TESTARGS='-count=1'

==> Checking that code complies with gofmt requirements...
go test ./internal/framework/... -v -count=1 -timeout=5m
--- PASS: TestAttributeTypes (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/framework	0.398s
--- PASS: TestDefaultValue (0.00s)
   --- PASS: TestDefaultValue/default_bool (0.00s)
   --- PASS: TestDefaultValue/default_bool_on_create (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/framework/boolplanmodifier	0.417s
--- PASS: TestDefaultValue (0.00s)
   --- PASS: TestDefaultValue/default_int64 (0.00s)
   --- PASS: TestDefaultValue/default_int64_on_create (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/framework/int64planmodifier	0.307s
--- PASS: TestDefaultValue (0.00s)
   --- PASS: TestDefaultValue/non-default_non-Null_string (0.00s)
   --- PASS: TestDefaultValue/default_string (0.00s)
   --- PASS: TestDefaultValue/non-default_non-Null_string,_current_Null (0.00s)
   --- PASS: TestDefaultValue/default_string_on_create (0.00s)
   --- PASS: TestDefaultValue/non-default_Null_string,_current_Null (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/framework/stringplanmodifier	0.479s
--- PASS: TestARNTypeValidate (0.00s)
   --- PASS: TestARNTypeValidate/invalid_string (0.00s)
   --- PASS: TestARNTypeValidate/valid_string (0.00s)
   --- PASS: TestARNTypeValidate/null_string (0.00s)
   --- PASS: TestARNTypeValidate/unknown_string (0.00s)
   --- PASS: TestARNTypeValidate/not_a_string (0.00s)
--- PASS: TestDurationTypeValidate (0.00s)
   --- PASS: TestDurationTypeValidate/invalid_string (0.00s)
   --- PASS: TestDurationTypeValidate/unknown_string (0.00s)
   --- PASS: TestDurationTypeValidate/not_a_string (0.00s)
   --- PASS: TestDurationTypeValidate/valid_string (0.00s)
   --- PASS: TestDurationTypeValidate/null_string (0.00s)
--- PASS: TestDurationTypeValueFromTerraform (0.00s)
   --- PASS: TestDurationTypeValueFromTerraform/invalid_duration (0.00s)
   --- PASS: TestDurationTypeValueFromTerraform/null_value (0.00s)
   --- PASS: TestDurationTypeValueFromTerraform/valid_duration (0.00s)
   --- PASS: TestDurationTypeValueFromTerraform/unknown_value (0.00s)
--- PASS: TestARNTypeValueFromTerraform (0.00s)
   --- PASS: TestARNTypeValueFromTerraform/invalid_duration (0.00s)
   --- PASS: TestARNTypeValueFromTerraform/null_value (0.00s)
   --- PASS: TestARNTypeValueFromTerraform/valid_ARN (0.00s)
   --- PASS: TestARNTypeValueFromTerraform/unknown_value (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/framework/types	0.360s
--- PASS: TestUTCTimestampValidator (0.00s)
   --- PASS: TestUTCTimestampValidator/unknown_String (0.00s)
   --- PASS: TestUTCTimestampValidator/null_String (0.00s)
   --- PASS: TestUTCTimestampValidator/valid_timestamp (0.00s)
   --- PASS: TestUTCTimestampValidator/invalid_timestamp (0.00s)
--- PASS: TestIPv4CIDRNetworkAddressValidator (0.00s)
   --- PASS: TestIPv4CIDRNetworkAddressValidator/unknown_String (0.00s)
   --- PASS: TestIPv4CIDRNetworkAddressValidator/invalid_String (0.00s)
   --- PASS: TestIPv4CIDRNetworkAddressValidator/invalid_IPv4_CIDR (0.00s)
   --- PASS: TestIPv4CIDRNetworkAddressValidator/null_String (0.00s)
   --- PASS: TestIPv4CIDRNetworkAddressValidator/valid_IPv6_CIDR (0.00s)
   --- PASS: TestIPv4CIDRNetworkAddressValidator/valid_IPv4_CIDR (0.00s)
--- PASS: TestClusterFinalSnapshotIdentifierValidator (0.00s)
   --- PASS: TestClusterFinalSnapshotIdentifierValidator/unknown_String (0.00s)
   --- PASS: TestClusterFinalSnapshotIdentifierValidator/null_String (0.00s)
   --- PASS: TestClusterFinalSnapshotIdentifierValidator/contains_consecutive_hyphens (0.00s)
   --- PASS: TestClusterFinalSnapshotIdentifierValidator/begins_with_number (0.00s)
   --- PASS: TestClusterFinalSnapshotIdentifierValidator/ends_with_hyphens (0.00s)
   --- PASS: TestClusterFinalSnapshotIdentifierValidator/valid_identifier (0.00s)
   --- PASS: TestClusterFinalSnapshotIdentifierValidator/contains_uppercase (0.00s)
   --- PASS: TestClusterFinalSnapshotIdentifierValidator/contains_special_character (0.00s)
--- PASS: TestIPv6CIDRNetworkAddressValidator (0.00s)
   --- PASS: TestIPv6CIDRNetworkAddressValidator/unknown_String (0.00s)
   --- PASS: TestIPv6CIDRNetworkAddressValidator/valid_IPv6_CIDR (0.00s)
   --- PASS: TestIPv6CIDRNetworkAddressValidator/null_String (0.00s)
   --- PASS: TestIPv6CIDRNetworkAddressValidator/valid_IPv4_CIDR (0.00s)
   --- PASS: TestIPv6CIDRNetworkAddressValidator/invalid_IPv6_CIDR (0.00s)
   --- PASS: TestIPv6CIDRNetworkAddressValidator/invalid_String (0.00s)
--- PASS: TestClusterIdentifierPrefixValidator (0.00s)
   --- PASS: TestClusterIdentifierPrefixValidator/unknown_String (0.00s)
   --- PASS: TestClusterIdentifierPrefixValidator/contains_special_character (0.00s)
   --- PASS: TestClusterIdentifierPrefixValidator/contains_consecutive_hyphens (0.00s)
   --- PASS: TestClusterIdentifierPrefixValidator/contains_uppercase (0.00s)
   --- PASS: TestClusterIdentifierPrefixValidator/valid_identifier (0.00s)
   --- PASS: TestClusterIdentifierPrefixValidator/null_String (0.00s)
--- PASS: TestClusterIdentifierValidator (0.00s)
   --- PASS: TestClusterIdentifierValidator/unknown_String (0.00s)
   --- PASS: TestClusterIdentifierValidator/begins_with_number (0.00s)
   --- PASS: TestClusterIdentifierValidator/contains_special_character (0.00s)
   --- PASS: TestClusterIdentifierValidator/null_String (0.00s)
   --- PASS: TestClusterIdentifierValidator/ends_with_hyphens (0.00s)
   --- PASS: TestClusterIdentifierValidator/contains_consecutive_hyphens (0.00s)
   --- PASS: TestClusterIdentifierValidator/contains_uppercase (0.00s)
   --- PASS: TestClusterIdentifierValidator/valid_identifier (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/framework/validators	0.608s

@johnsonaj johnsonaj marked this pull request as ready for review February 7, 2023 23:33
Copy link
Member

@jar-b jar-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

$ go test -count=1 ./internal/flex/...
ok      github.com/hashicorp/terraform-provider-aws/internal/flex       0.218s

internal/flex/framework_test.go Show resolved Hide resolved
@johnsonaj johnsonaj merged commit 8512fcf into main Feb 8, 2023
@johnsonaj johnsonaj deleted the f-framework-validators branch February 8, 2023 15:52
@github-actions github-actions bot added this to the v4.54.0 milestone Feb 8, 2023
@github-actions
Copy link

github-actions bot commented Feb 9, 2023

This functionality has been released in v4.54.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
flex Pertains to FLatteners and EXpanders. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants