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

Only check project if it's not present on the resource. #1125

Merged
merged 2 commits into from
Feb 22, 2018

Conversation

nat-henderson
Copy link
Contributor

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:

TF_ACC=1 go test ./google -v -run=TestAccStorageBucket -timeout 120m
=== RUN   TestAccStorageBucket_basic
=== RUN   TestAccStorageBucket_lowercaseLocation
=== RUN   TestAccStorageBucket_customAttributes
=== RUN   TestAccStorageBucket_lifecycleRules
=== RUN   TestAccStorageBucket_storageClass
=== RUN   TestAccStorageBucket_update
=== RUN   TestAccStorageBucket_forceDestroy
=== RUN   TestAccStorageBucket_versioning
=== RUN   TestAccStorageBucket_logging
=== RUN   TestAccStorageBucket_cors
=== RUN   TestAccStorageBucket_labels
--- PASS: TestAccStorageBucket_basic (1.90s)
--- PASS: TestAccStorageBucket_storageClass (5.11s)
--- PASS: TestAccStorageBucket_customAttributes (4.95s)
--- PASS: TestAccStorageBucket_lifecycleRules (2.01s)
--- PASS: TestAccStorageBucket_lowercaseLocation (4.98s)
--- PASS: TestAccStorageBucket_forceDestroy (12.89s)
--- PASS: TestAccStorageBucket_update (22.06s)
--- PASS: TestAccStorageBucket_cors (10.57s)
--- PASS: TestAccStorageBucket_versioning (10.82s)
--- PASS: TestAccStorageBucket_logging (5.50s)
--- PASS: TestAccStorageBucket_labels (22.60s)
PASS
ok      github.com/terraform-providers/terraform-provider-google/google 29.731s

// 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 != "" {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@nat-henderson
Copy link
Contributor Author

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)
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, done.

@nat-henderson nat-henderson merged commit 151e83a into hashicorp:master Feb 22, 2018
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this pull request Sep 27, 2019
@ghost
Copy link

ghost commented Mar 29, 2020

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!

@ghost ghost locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating a storage bucket require Compute API
2 participants