-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Only check project if it's not present on the resource. #1125
Only check project if it's not present on the resource. #1125
Conversation
google/resource_storage_bucket.go
Outdated
// we will not try to fetch the project name. If it is not, either because | ||
// the user intends to use the default provider project, or because the resource | ||
// is currently being imported, we will read it from the API. | ||
if p, ok := d.GetOk("project"); ok && p != "" { |
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.
No need to check that p != "", that's what ok means.
Also shouldn't this be checking that project isn't set?
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.
Oof, the fact that that made the tests pass makes me nervous. Adding a new test.
Added the test! Still passes. |
// the user intends to use the default provider project, or because the resource | ||
// is currently being imported, we will read it from the API. | ||
if _, ok := d.GetOk("project"); !ok { | ||
log.Printf("[DEBUG] Read bucket %v at location %v\n\n", res.Name, res.SelfLink) |
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 think this log statement should stay where it was since it's useful regardless of whether we fetch the project
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.
You're right, done.
Signed-off-by: Modular Magician <[email protected]>
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Fixes #1089 by not requiring compute API unless the project needs to be read. A bucket / project mapping can't be changed after the fact, so it should be safe, and tests (which cover imports) still pass: