-
Notifications
You must be signed in to change notification settings - Fork 430
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
fix: account for null comment #3417
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...ces/manual_tests/handling_account_null_comment/handling_account_null_comment.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Handling account null comment | ||
|
||
This test shows that the problem from [this issue](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3402) | ||
sfc-gh-jmichalak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
is now handled by the provider. The issue occurs when importing an account that has `null` comment. | ||
Because of the limitations in the [terraform plugin testing framework](https://github.com/hashicorp/terraform-plugin-testing) | ||
we cannot create account externally and then import that account in the first step of the test. This can only be tested manually. | ||
|
||
## Snowflake setup | ||
|
||
Before running Terraform tests you have to create an account we would like to import. | ||
Run the following script to create an account: | ||
```snowflake | ||
CREATE ACCOUNT TESTING_ACCOUNT | ||
ADMIN_NAME = '<admin_name>' -- TODO: Replace | ||
ADMIN_PASSWORD = '<password>' -- TODO: Replace | ||
ADMIN_USER_TYPE = SERVICE | ||
EMAIL = '<email>' -- TODO: Replace | ||
EDITION = STANDARD | ||
COMMENT = NULL; | ||
``` | ||
|
||
## Test steps | ||
|
||
In this test, we'll make a use of building the provider locally and overriding it in the `~/.terraformrc`. | ||
For more details on that, please visit our [advanced debugging guide](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/CONTRIBUTING.md#advanced-debugging). | ||
|
||
1. Copy the Terraform code from `main.tf` and initialize the project by running `terraform init`. | ||
2. Run `terraform import snowflake_account.test_account '<organization_name>.<account_name>'`. | ||
3. Right now, you should get the same error as in [this issue](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3402). | ||
4. Modify your `~/.terraformrc` to use the locally built provider | ||
5. Run `terraform init -upgrade` to make sure the overridden plugin is used (you will be notified by warning logged by Terraform CLI) | ||
6. Run `terraform import snowflake_account.test_account '<organization_name>.<account_name>'`. | ||
7. The import should be passing now. Run `terraform plan` to make sure the Read operation is also passing. | ||
|
||
## Test cleanup | ||
|
||
To clean up the test either run `terraform apply -auto-approve -destroy` or in a case where import didn't work | ||
run the following Snowflake script: | ||
```snowflake | ||
DROP ACCOUNT TESTING_ACCOUNT GRACE_PERIOD_IN_DAYS = 3; | ||
``` |
23 changes: 23 additions & 0 deletions
23
pkg/resources/manual_tests/handling_account_null_comment/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
terraform { | ||
required_providers { | ||
snowflake = { | ||
source = "Snowflake-Labs/snowflake" | ||
version = "1.0.3" | ||
} | ||
} | ||
} | ||
|
||
provider "snowflake" { | ||
} | ||
|
||
resource "snowflake_account" "test_account" { | ||
grace_period_in_days = 3 | ||
name = "<name>" # TODO: Replace | ||
admin_name = "<admin_name>" # TODO: Replace | ||
admin_password = "<admin_password>" # TODO: Replace | ||
admin_user_type = "SERVICE" | ||
email = "<email>" # TODO: Replace | ||
edition = "STANDARD" | ||
region = "<region>" # TODO: Replace (if needed; can be filled after the import) | ||
comment = "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module tools | ||
|
||
go 1.22.10 | ||
go 1.23.6 | ||
|
||
require ( | ||
github.com/hashicorp/terraform-plugin-docs v0.20.1 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line is funny TBH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that we should make some adjustments to handle null pointers inside
handleExternalChangesToObjectInShow
instead of defining non-pointer values before the mappings. It would simplify the codebase for some of the resources.