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

Add Google Spanner Support (google_spanner_instance) #270

Merged
merged 8 commits into from
Aug 14, 2017

Conversation

nickithewatt
Copy link
Contributor

@nickithewatt nickithewatt commented Jul 31, 2017

This PR aims to addresses #67 which looks to add Google Spanner Support, specifically adding a new resource google_spanner_instance. CC @rileykarson @danawillow

In 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. the google_spanner_database resource.

@nickithewatt nickithewatt force-pushed the spanner-support-instance branch from 7ab852d to 121e64b Compare August 4, 2017 08:00
@rosbo rosbo self-requested a review August 4, 2017 22:09
Copy link
Contributor

@rosbo rosbo left a 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,
},
Copy link
Contributor

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.

d.Set("labels", instance.Labels)
d.Set("display_name", instance.DisplayName)
d.Set("num_nodes", instance.NodeCount)
d.SetId(id.terraformId())
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 set the id here. It will be set either in the import method or the create method.

uir.FieldMask = strings.Join(fieldMask, ",")
op, err := config.clientSpanner.Projects.Instances.Patch(
id.instanceUri(), uir).Do()

Copy link
Contributor

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.

"labels": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Copy link
Contributor

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.

fieldMask = append(fieldMask, "displayName")
uir.Instance.DisplayName = d.Get("display_name").(string)
}

Copy link
Contributor

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

}, nil
}

func extractInstanceConfigFromApi(nameUri string) string {
Copy link
Contributor

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

return extractLastResourceFromUri(nameUri)
}

func extractInstanceNameFromApi(nameUri string) string {
Copy link
Contributor

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

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

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.

@nickithewatt
Copy link
Contributor Author

nickithewatt commented Aug 11, 2017 via email

@nickithewatt nickithewatt force-pushed the spanner-support-instance branch from 945b69e to 76b2e6f Compare August 12, 2017 01:40
@nickithewatt
Copy link
Contributor Author

nickithewatt commented Aug 12, 2017

@rosbo thanks for review: Changes made as requested. Let me know if there is anything else that needs doing on this :)

@rosbo
Copy link
Contributor

rosbo commented Aug 14, 2017

make testacc TESTARGS="-run TestAccGoogleSpannerInstance_" TEST="./google"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./google -v -run TestAccGoogleSpannerInstance_ -timeout 120m
=== RUN TestAccGoogleSpannerInstance_importInstance
--- PASS: TestAccGoogleSpannerInstance_importInstance (76.53s)
=== RUN TestAccGoogleSpannerInstance_importProjectInstance
--- PASS: TestAccGoogleSpannerInstance_importProjectInstance (25.50s)
PASS
ok github.com/terraform-providers/terraform-provider-google/google 102.157s

make testacc TESTARGS="-run TestAccSpannerInstance_" TEST="./google"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./google -v -run TestAccSpannerInstance_ -timeout 120m
=== RUN TestAccSpannerInstance_basic
--- PASS: TestAccSpannerInstance_basic (12.77s)
=== RUN TestAccSpannerInstance_basicWithAutogenName
--- PASS: TestAccSpannerInstance_basicWithAutogenName (11.35s)
=== RUN TestAccSpannerInstance_duplicateNameError
--- PASS: TestAccSpannerInstance_duplicateNameError (11.62s)
=== RUN TestAccSpannerInstance_update
--- PASS: TestAccSpannerInstance_update (21.88s)
PASS
ok github.com/terraform-providers/terraform-provider-google/google 57.754s

@rosbo
Copy link
Contributor

rosbo commented Aug 14, 2017

Thank you so much for adding Spanner support to Terraform!

@rosbo rosbo merged commit 04b3ffb into hashicorp:master Aug 14, 2017
z1nkum pushed a commit to z1nkum/terraform-provider-google that referenced this pull request Aug 15, 2017
@nickithewatt nickithewatt deleted the spanner-support-instance branch August 21, 2017 00:30
negz pushed a commit to negz/terraform-provider-google that referenced this pull request Oct 17, 2017
chrisst pushed a commit to chrisst/terraform-provider-google that referenced this pull request Nov 9, 2018
@ghost
Copy link

ghost commented Mar 31, 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 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 31, 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.

2 participants