Skip to content

Commit

Permalink
fix: handle external change of secret type (#3141)
Browse files Browse the repository at this point in the history
<!-- Feel free to delete comments as you fill this in -->

<!-- summary of changes -->
## Changes
* Added secret_type computed filed to secret resources
* Added CustomDiff for handling external change of secret_type
* Refactored show_and_describe_handlers for flat describe_output and
show_output
* Tested external change of secret type for each resource

## Test Plan
<!-- detail ways in which this PR has been tested or needs to be tested
-->
* [x] acceptance tests


## References
<!-- issues documentation links, etc  -->
*
#3110 (comment)
*
#3110 (comment)
  • Loading branch information
sfc-gh-fbudzynski authored Oct 24, 2024
1 parent 4391473 commit 649b839
Show file tree
Hide file tree
Showing 41 changed files with 984 additions and 169 deletions.
1 change: 1 addition & 0 deletions docs/resources/secret_with_authorization_code_grant.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ resource "snowflake_secret_with_authorization_code_grant" "test" {
- `describe_output` (List of Object) Outputs the result of `DESCRIBE SECRET` for the given secret. (see [below for nested schema](#nestedatt--describe_output))
- `fully_qualified_name` (String) Fully qualified name of the resource. For more information, see [object name resolution](https://docs.snowflake.com/en/sql-reference/name-resolution).
- `id` (String) The ID of this resource.
- `secret_type` (String) Specifies a type for the secret. This field is used for checking external changes and recreating the resources if needed.
- `show_output` (List of Object) Outputs the result of `SHOW SECRETS` for the given secret. (see [below for nested schema](#nestedatt--show_output))

<a id="nestedatt--describe_output"></a>
Expand Down
1 change: 1 addition & 0 deletions docs/resources/secret_with_basic_authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ resource "snowflake_secret_with_basic_authentication" "test" {
- `describe_output` (List of Object) Outputs the result of `DESCRIBE SECRET` for the given secret. (see [below for nested schema](#nestedatt--describe_output))
- `fully_qualified_name` (String) Fully qualified name of the resource. For more information, see [object name resolution](https://docs.snowflake.com/en/sql-reference/name-resolution).
- `id` (String) The ID of this resource.
- `secret_type` (String) Specifies a type for the secret. This field is used for checking external changes and recreating the resources if needed.
- `show_output` (List of Object) Outputs the result of `SHOW SECRETS` for the given secret. (see [below for nested schema](#nestedatt--show_output))

<a id="nestedatt--describe_output"></a>
Expand Down
1 change: 1 addition & 0 deletions docs/resources/secret_with_client_credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ resource "snowflake_secret_with_client_credentials" "test" {
- `describe_output` (List of Object) Outputs the result of `DESCRIBE SECRET` for the given secret. (see [below for nested schema](#nestedatt--describe_output))
- `fully_qualified_name` (String) Fully qualified name of the resource. For more information, see [object name resolution](https://docs.snowflake.com/en/sql-reference/name-resolution).
- `id` (String) The ID of this resource.
- `secret_type` (String) Specifies a type for the secret. This field is used for checking external changes and recreating the resources if needed.
- `show_output` (List of Object) Outputs the result of `SHOW SECRETS` for the given secret. (see [below for nested schema](#nestedatt--show_output))

<a id="nestedatt--describe_output"></a>
Expand Down
1 change: 1 addition & 0 deletions docs/resources/secret_with_generic_string.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ resource "snowflake_secret_with_generic_string" "test" {
- `describe_output` (List of Object) Outputs the result of `DESCRIBE SECRET` for the given secret. (see [below for nested schema](#nestedatt--describe_output))
- `fully_qualified_name` (String) Fully qualified name of the resource. For more information, see [object name resolution](https://docs.snowflake.com/en/sql-reference/name-resolution).
- `id` (String) The ID of this resource.
- `secret_type` (String) Specifies a type for the secret. This field is used for checking external changes and recreating the resources if needed.
- `show_output` (List of Object) Outputs the result of `SHOW SECRETS` for the given secret. (see [below for nested schema](#nestedatt--show_output))

<a id="nestedatt--describe_output"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ var allResourceSchemaDefs = []ResourceSchemaDef{
name: "StreamOnExternalTable",
schema: resources.StreamOnExternalTable().Schema,
},
{
name: "SecretWithAuthorizationCodeGrant",
schema: resources.SecretWithAuthorizationCodeGrant().Schema,
},
{
name: "SecretWithBasicAuthentication",
schema: resources.SecretWithBasicAuthentication().Schema,
},
{
name: "SecretWithClientCredentials",
schema: resources.SecretWithClientCredentials().Schema,
},
{
name: "SecretWithGenericString",
schema: resources.SecretWithGenericString().Schema,
},
{
name: "StreamOnDirectoryTable",
schema: resources.StreamOnDirectoryTable().Schema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert"
)

func (s *SecretWithAuthorizationCodeResourceAssert) HasOauthRefreshTokenExpiryTimeNotEmpty() *SecretWithAuthorizationCodeResourceAssert {
func (s *SecretWithAuthorizationCodeGrantResourceAssert) HasOauthRefreshTokenExpiryTimeNotEmpty() *SecretWithAuthorizationCodeGrantResourceAssert {
s.AddAssertion(assert.ValuePresent("oauth_refresh_token_expiry_time"))
return s
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package model

import tfconfig "github.com/hashicorp/terraform-plugin-testing/config"

func (s *SecretWithClientCredentialsModel) WithOauthScopes(oauthScopes []string) *SecretWithClientCredentialsModel {
oauthScopesStringVariables := make([]tfconfig.Variable, len(oauthScopes))
for i, v := range oauthScopes {
oauthScopesStringVariables[i] = tfconfig.StringVariable(v)
}

s.OauthScopes = tfconfig.SetVariable(oauthScopesStringVariables...)
return s
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 649b839

Please sign in to comment.