-
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
Add Google Spanner Support (google_spanner_instance) #270
Add Google Spanner Support (google_spanner_instance) #270
Conversation
7ab852d
to
121e64b
Compare
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.
Hi Nicki,
Thank you so much for your contribution! Thanks also for splitting your change in twp PRs, it definitely makes it easier for me to review.
Overall very good. Good testing and thanks also for adding the import functionality :)
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
}, |
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.
Add the computed state
field.
google/resource_spanner_instance.go
Outdated
d.Set("labels", instance.Labels) | ||
d.Set("display_name", instance.DisplayName) | ||
d.Set("num_nodes", instance.NodeCount) | ||
d.SetId(id.terraformId()) |
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 set the id here. It will be set either in the import method or the create method.
google/resource_spanner_instance.go
Outdated
uir.FieldMask = strings.Join(fieldMask, ",") | ||
op, err := config.clientSpanner.Projects.Instances.Patch( | ||
id.instanceUri(), uir).Do() | ||
|
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.
Add a block to handle the error from calling .Patch(...).Do()
here.
google/resource_spanner_instance.go
Outdated
"labels": { | ||
Type: schema.TypeMap, | ||
Optional: true, | ||
ForceNew: true, |
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.
The patch API support labels updates. Remove this ForceNew
and add support for it in the update method below.
google/resource_spanner_instance.go
Outdated
fieldMask = append(fieldMask, "displayName") | ||
uir.Instance.DisplayName = d.Get("display_name").(string) | ||
} | ||
|
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.
Add a block for changes to labels
google/resource_spanner_instance.go
Outdated
}, nil | ||
} | ||
|
||
func extractInstanceConfigFromApi(nameUri string) string { |
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.
Consider renaming to extractInstanceConfigFromUri(configUri string) string
google/resource_spanner_instance.go
Outdated
return extractLastResourceFromUri(nameUri) | ||
} | ||
|
||
func extractInstanceNameFromApi(nameUri string) string { |
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.
Consider renaming to extractInstanceNameFromUri(nameUri string) string
|
||
// Unit Tests | ||
|
||
func TestExtractInstanceConfigFromApi_withFullPath(t *testing.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.
Renaming test accordingly if you change the method name.
|
||
## Attributes Reference | ||
|
||
No additional attributes are computed other than those defined above. |
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.
Don't forget to add the state
computed attribute in this section.
Thanks, aiming to try and get round to these changes some time in the next few days.
|
945b69e
to
76b2e6f
Compare
@rosbo thanks for review: Changes made as requested. Let me know if there is anything else that needs doing on this :) |
make testacc TESTARGS="-run TestAccGoogleSpannerInstance_" TEST="./google" make testacc TESTARGS="-run TestAccSpannerInstance_" TEST="./google" |
Thank you so much for adding Spanner support to Terraform! |
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 👉 hashibot-feedback@hashicorp.com. Thanks! |
This PR aims to addresses #67 which looks to add Google Spanner Support, specifically adding a new resource
google_spanner_instance
. CC @rileykarson @danawillowIn order to make these PR's easier to digest and review, instead of creating one big PR with all Spanner support in it, I have created one for each new resource to be added. This is the first which adds support for the foundational
google_spanner_instance
resource. A separate one (#271) adds support for creating the Database within the Instance, i.e. thegoogle_spanner_database
resource.