-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add new resource google_folder_iam_audit_config. #3698
Conversation
Hello! I am a robot who works on Magic Modules PRs. I have detected that you are a community contributor, so your PR will be assigned to someone with a commit-bit on this repo for initial review. Thanks for your contribution! A human will be with you soon. @slevenick, please review this PR or find an appropriate assignee. |
07b6b4e
to
91167ee
Compare
I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=122254" |
) | ||
|
||
func folderIamAuditConfigImportStep(t *testing.T, resourceName, fname, service string) resource.TestStep { | ||
name, err := getFolderNameByParentAndDisplayName("organizations/"+getTestOrgFromEnv(t), fname, googleProviderConfig(t)) |
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.
It's complaining the *Config returned by googleProviderConfig(t) is {}, but I'm not sure why or how I can get the *Config and use it to retrieve the folder ID and use it in the Import check.
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.
Ok, so what is happening here is that there is a little confusion on the context that this is being evaluated in.
Generally googleProviderConfig(t)
gives you the *Config that is being used for the test context that you are in. If you call it outside of a go test it will return {} because the *Config is only instantiated at the beginning of the test run, when vcrTest(...)
is called. So you'll notice that all of the uses of googleProviderConfig(t)
only exist in functions that are called from within the terraform process under test.
The call to googleProviderConfig(t)
is within a resource.TestCheckFunc
, so it gets evaluated within the vcrTest
call.
In your code, folderIamAuditConfigImportStep
is evaluated before vcrTest
is called, and passed as an argument to it. This causes an issue because:
The config doesn't exist
The folder doesn't exist, as no steps have run yet
I don't believe creating the import steps like this will work because of these issues.
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.
Do you have any recommendation around how to test this? I was trying to getting the folder ID from the display name and parent as for folder, the folder ID is needed in the terraform import. It seems it's not easy to get that piece of information.
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.
I removed the import state check for now. @slevenick
I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=122254" |
I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=122254" |
I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=122254" |
I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=122669" |
I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=122671" |
@slevenick could you take another look? Thanks! |
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.
Thanks for the addition!
Release Note Template for Downstream PRs (will be copied)