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

Fix: env0_gcp_credentials - apply after import will delete+create #380

Merged
merged 2 commits into from
May 17, 2022

Conversation

TomerHeber
Copy link
Collaborator

Issue & Steps to Reproduce / Feature Request

fixes #99
The last part of the effort to add import to all credential types (Azure and AWS is complete).

Solution

  1. Added import.
  2. Fixed some bugs.
  3. Added acceptance tests.
  4. Added examples.

@@ -23,7 +26,7 @@ func TestUnitGcpCredentialsResource(t *testing.T) {
}

updateGcpCredentialResource := map[string]interface{}{
"name": "testUpdate",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bug in test.

Copy link
Contributor

@razbensimon razbensimon left a comment

Choose a reason for hiding this comment

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

👏🏼

Comment on lines +80 to +82
if err := writeResourceData(&credentials, d); err != nil {
return diag.Errorf("schema resource data serialization failed: %v", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just asking, what changed that we now need it than before?
Is import flow will not work without it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@razbensimon ,

The writeResourceData (and readReasourceData) is a utility function that reads all the fields in the interface and updates the schema via set calls.
This is future proof: in case you add more fields to the schema/api - no additional coding is needed (other than updating the schema).

There is a potential bug here that drifting is not detected (E.g., if someone changes the name in the UX). Once I added this code, it caught a bug in the tests as well (so I fixed the tests as well).
Import flow will work without it, and I just fixed bugs I encountered on the way.

@github-actions github-actions bot added ready to merge PR approved - can be merged once the PR owner is ready and removed pending final review labels May 17, 2022
@TomerHeber TomerHeber merged commit c683c74 into main May 17, 2022
@TomerHeber TomerHeber deleted the fix-apply-will-delete-create-#99 branch May 17, 2022 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples fix provider ready to merge PR approved - can be merged once the PR owner is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

env0_aws_credentials - apply after import will delete+create
2 participants