-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Adding google_compute_service_attachment data source #9887
Conversation
Hello! I am a robot. It looks like you are a: Community Contributor @NickElliot, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
Tests analyticsTotal tests: Click here to see the affected service packages
Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected testsTestAccDataSourceGoogleServiceAttachment |
|
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, the test is having an issue due to conflicting resource names. I suggested a broad formatting adjustment that should resolve this. Thanks!
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
Show resolved
Hide resolved
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
Outdated
Show resolved
Hide resolved
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
Outdated
Show resolved
Hide resolved
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
Outdated
Show resolved
Hide resolved
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
Outdated
Show resolved
Hide resolved
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
Outdated
Show resolved
Hide resolved
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
Outdated
Show resolved
Hide resolved
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
Outdated
Show resolved
Hide resolved
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
Outdated
Show resolved
Hide resolved
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
Outdated
Show resolved
Hide resolved
Yes, I understood what i should do next. I was just busy with some other
work. I will make these changes
thank you so much.
…On Thu, Feb 1, 2024 at 1:48 PM Nick Elliot ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Hi, the test is having an issue due to conflicting resource names. I
suggested a broad formatting adjustment that should resolve this. Thanks!
------------------------------
In
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
<#9887 (comment)>
:
> +// Copyright (c) HashiCorp, Inc.
+// SPDX-License-Identifier: MPL-2.0
+package compute_test
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-provider-google/google/acctest"
+ "github.com/hashicorp/terraform-provider-google/google/tpgresource"
+)
+
+func TestAccDataSourceGoogleServiceAttachment(t *testing.T) {
+ t.Parallel()
⬇️ Suggested change
- t.Parallel()
+ t.Parallel()
+
+ context := map[string]interface{}{
+ "random_suffix": acctest.RandString(t, 10),
+ }
------------------------------
In
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
<#9887 (comment)>
:
> +package compute_test
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-provider-google/google/acctest"
+ "github.com/hashicorp/terraform-provider-google/google/tpgresource"
+)
+
+func TestAccDataSourceGoogleServiceAttachment(t *testing.T) {
+ t.Parallel()
+
+ serviceAttachmentName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
⬇️ Suggested change
- serviceAttachmentName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
------------------------------
In
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
<#9887 (comment)>
:
> + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+ "github.com/hashicorp/terraform-provider-google/google/acctest"
+ "github.com/hashicorp/terraform-provider-google/google/tpgresource"
+)
+
+func TestAccDataSourceGoogleServiceAttachment(t *testing.T) {
+ t.Parallel()
+
+ serviceAttachmentName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
+ acctest.VcrTest(t, resource.TestCase{
+ PreCheck: func() { acctest.AccTestPreCheck(t) },
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
+ Steps: []resource.TestStep{
+ {
+ Config: testAccDataSourceGoogleServiceAttachmentConfig(serviceAttachmentName),
⬇️ Suggested change
- Config: testAccDataSourceGoogleServiceAttachmentConfig(serviceAttachmentName),
+ Config: testAccDataSourceGoogleServiceAttachmentConfig(context),
------------------------------
In
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
<#9887 (comment)>
:
> + attr_to_check,
+ ds_attr[attr_to_check],
+ rs_attr[attr_to_check],
+ )
+ }
+ }
+
+ if !tpgresource.CompareSelfLinkOrResourceName("", ds_attr["self_link"], rs_attr["self_link"], nil) && ds_attr["self_link"] != rs_attr["self_link"] {
+ return fmt.Errorf("self link does not match: %s vs %s", ds_attr["self_link"], rs_attr["self_link"])
+ }
+
+ return nil
+ }
+}
+
+func testAccDataSourceGoogleServiceAttachmentConfig(name string) string {
⬇️ Suggested change
-func testAccDataSourceGoogleServiceAttachmentConfig(name string) string {
+func testAccDataSourceGoogleServiceAttachmentConfig(context map[string]interface{}) string {
------------------------------
In
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
<#9887 (comment)>
:
> + load_balancing_scheme = "INTERNAL"
+ backend_service = google_compute_region_backend_service.producer_service_backend.id
+ all_ports = true
+ network = google_compute_network.psc_ilb_network.name
+ subnetwork = google_compute_subnetwork.psc_ilb_producer_subnetwork.name
+ }
+
+ resource "google_compute_region_backend_service" "producer_service_backend" {
+ name = "producer-service"
+ region = "us-west1"
+
+ health_checks = [google_compute_health_check.producer_service_health_check.id]
+ }
+
+ resource "google_compute_health_check" "producer_service_health_check" {
+ name = "producer-service-health-check"
⬇️ Suggested change
- name = "producer-service-health-check"
+ name = "producer-service-health-check%{random_suffix}"
------------------------------
In
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
<#9887 (comment)>
:
> + ip_cidr_range = "10.0.0.0/16"
+ }
+
+ resource "google_compute_subnetwork" "psc_ilb_nat" {
+ name = "psc-ilb-nat"
+ region = "us-west1"
+
+ network = google_compute_network.psc_ilb_network.id
+ purpose = "PRIVATE_SERVICE_CONNECT"
+ ip_cidr_range = "10.1.0.0/16"
+ }
+data "google_compute_service_attachment" "my_attachment" {
+ name = google_compute_service_attachment.foobar.name
+ region = google_compute_service_attachment.foobar.region
+}
+`, name)
⬇️ Suggested change
-`, name)
+`, context)
------------------------------
In
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
<#9887 (comment)>
:
> + ds_attr[attr_to_check],
+ rs_attr[attr_to_check],
+ )
+ }
+ }
+
+ if !tpgresource.CompareSelfLinkOrResourceName("", ds_attr["self_link"], rs_attr["self_link"], nil) && ds_attr["self_link"] != rs_attr["self_link"] {
+ return fmt.Errorf("self link does not match: %s vs %s", ds_attr["self_link"], rs_attr["self_link"])
+ }
+
+ return nil
+ }
+}
+
+func testAccDataSourceGoogleServiceAttachmentConfig(name string) string {
+ return fmt.Sprintf(`
⬇️ Suggested change
- return fmt.Sprintf(`
+ return acctest.Nprintf(`
------------------------------
In
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
<#9887 (comment)>
:
> +}
+
+func testAccDataSourceGoogleServiceAttachmentConfig(name string) string {
+ return fmt.Sprintf(`
+resource "google_compute_service_attachment" "foobar" {
+ name = "%s"
+ description = "my-description"
+ region = "us-west1"
+ enable_proxy_protocol = true
+ connection_preference = "ACCEPT_AUTOMATIC"
+ nat_subnets = [google_compute_subnetwork.psc_ilb_nat.id]
+ target_service = google_compute_forwarding_rule.psc_ilb_target_service.id
+}
+
+resource "google_compute_forwarding_rule" "psc_ilb_target_service" {
+ name = "producer-forwarding-rule"
⬇️ Suggested change
- name = "producer-forwarding-rule"
+ name = "producer-forwarding-rule%{random_suffix}"
------------------------------
In
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
<#9887 (comment)>
:
> + )
+ }
+ }
+
+ if !tpgresource.CompareSelfLinkOrResourceName("", ds_attr["self_link"], rs_attr["self_link"], nil) && ds_attr["self_link"] != rs_attr["self_link"] {
+ return fmt.Errorf("self link does not match: %s vs %s", ds_attr["self_link"], rs_attr["self_link"])
+ }
+
+ return nil
+ }
+}
+
+func testAccDataSourceGoogleServiceAttachmentConfig(name string) string {
+ return fmt.Sprintf(`
+resource "google_compute_service_attachment" "foobar" {
+ name = "%s"
⬇️ Suggested change
- name = "%s"
+ name = "tf-test%{random_suffix}"
------------------------------
In
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
<#9887 (comment)>
:
> + region = "us-west1"
+
+ health_checks = [google_compute_health_check.producer_service_health_check.id]
+ }
+
+ resource "google_compute_health_check" "producer_service_health_check" {
+ name = "producer-service-health-check"
+
+ check_interval_sec = 1
+ timeout_sec = 1
+ tcp_health_check {
+ port = "80"
+ }
+ }
+ resource "google_compute_network" "psc_ilb_network" {
+ name = "psc-ilb-network"
⬇️ Suggested change
- name = "psc-ilb-network"
+ name = "psc-ilb-network%{random_suffix}"
------------------------------
In
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
<#9887 (comment)>
:
> + resource "google_compute_health_check" "producer_service_health_check" {
+ name = "producer-service-health-check"
+
+ check_interval_sec = 1
+ timeout_sec = 1
+ tcp_health_check {
+ port = "80"
+ }
+ }
+ resource "google_compute_network" "psc_ilb_network" {
+ name = "psc-ilb-network"
+ auto_create_subnetworks = false
+ }
+
+ resource "google_compute_subnetwork" "psc_ilb_producer_subnetwork" {
+ name = "psc-ilb-producer-subnetwork"
⬇️ Suggested change
- name = "psc-ilb-producer-subnetwork"
+ name = "psc-ilb-producer-subnetwork%{random_suffix}"
------------------------------
In
mmv1/third_party/terraform/services/compute/data_source_compute_service_attachment_test.go
<#9887 (comment)>
:
> + }
+ resource "google_compute_network" "psc_ilb_network" {
+ name = "psc-ilb-network"
+ auto_create_subnetworks = false
+ }
+
+ resource "google_compute_subnetwork" "psc_ilb_producer_subnetwork" {
+ name = "psc-ilb-producer-subnetwork"
+ region = "us-west1"
+
+ network = google_compute_network.psc_ilb_network.id
+ ip_cidr_range = "10.0.0.0/16"
+ }
+
+ resource "google_compute_subnetwork" "psc_ilb_nat" {
+ name = "psc-ilb-nat"
⬇️ Suggested change
- name = "psc-ilb-nat"
+ name = "psc-ilb-nat%{random_suffix}"
—
Reply to this email directly, view it on GitHub
<#9887 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYIACZSMEAFI6KFG3PVXTELYRQERRAVCNFSM6AAAAABCNDZKUGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQNJXGY4TOMZZGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_service_attachment_test.go Co-authored-by: Nick Elliot <[email protected]>
…e_compute_service_attachment_test.go" This reverts commit 957fc42.
cd tpgtools; This error is still remaining |
/gcbrun |
please rebase your changes on top of head again or cherry pick your changes to a fresh branch, your pr is very broken now, having combined in a mix of existing main branch commits/your own |
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.
see above
@sanmaym, this PR is waiting for action from you. Please address any comments or change requests, or re-request review from a core reviewer if no action is required. If no action is taken, this PR will be closed in 14 days. This notification can be disabled with the |
@sanmaym, this PR is waiting for action from you. Please address any comments or change requests, or re-request review from a core reviewer if no action is required. If no action is taken, this PR will be closed in 2 weekdays. This notification can be disabled with the |
@sanmaym, this PR is being closed due to inactivity. |
This PR is for a new data resource that obtains the URI for a service attachment. Its based of this google api
[Issue is tracked here] (hashicorp/terraform-provider-google#17122)
Release Note Template for Downstream PRs (will be copied)