From d16c33e8259799d7ef3d9729fe2b2f86a391745d Mon Sep 17 00:00:00 2001 From: Will Yardley Date: Sun, 15 Dec 2024 17:11:25 -0800 Subject: [PATCH] compute: added `network_id` to `google_compute_network` (#12504) --- mmv1/products/compute/Network.yaml | 6 ++++++ .../data_source_google_compute_network.go.tmpl | 13 ++++++++++--- .../data_source_google_compute_network_test.go | 1 + .../compute/resource_compute_network_test.go.tmpl | 1 + .../website/docs/d/compute_network.html.markdown | 4 +++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/mmv1/products/compute/Network.yaml b/mmv1/products/compute/Network.yaml index d67d4c02fdb9..4e1032b0fbd8 100644 --- a/mmv1/products/compute/Network.yaml +++ b/mmv1/products/compute/Network.yaml @@ -116,10 +116,16 @@ properties: immutable: true validation: function: 'verify.ValidateGCEName' + - name: 'networkId' + description: | + The unique identifier for the resource. This identifier is defined by the server. + api_name: id + output: true - name: 'numericId' type: String description: | The unique identifier for the resource. This identifier is defined by the server. + deprecation_message: '`numeric_id` is deprecated and will be removed in a future major release. Use `network_id` instead.' output: true - name: 'autoCreateSubnetworks' type: Boolean diff --git a/mmv1/third_party/terraform/services/compute/data_source_google_compute_network.go.tmpl b/mmv1/third_party/terraform/services/compute/data_source_google_compute_network.go.tmpl index da19428452ad..c3d9b9645f12 100644 --- a/mmv1/third_party/terraform/services/compute/data_source_google_compute_network.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/data_source_google_compute_network.go.tmpl @@ -24,12 +24,16 @@ func DataSourceGoogleComputeNetwork() *schema.Resource { Computed: true, }, - // TODO: this should eventually be TypeInt, but leaving as - // string for now to match the resource and to avoid a - // breaking change. + "network_id": { + Type: schema.TypeInt, + Computed: true, + }, + + // Deprecated in favor of network_id "numeric_id": { Type: schema.TypeString, Computed: true, + Deprecated: "`numeric_id` is deprecated and will be removed in a future major release. Use `network_id` instead.", }, "gateway_ipv4": { @@ -104,6 +108,9 @@ func dataSourceGoogleComputeNetworkRead(d *schema.ResourceData, meta interface{} if err := d.Set("description", network.Description); err != nil { return fmt.Errorf("Error setting description: %s", err) } + if err := d.Set("network_id", network.Id); err != nil { + return fmt.Errorf("Error setting network_id: %s", err) + } if err := d.Set("numeric_id", strconv.Itoa(int(network.Id))); err != nil { return fmt.Errorf("Error setting numeric_id: %s", err) } diff --git a/mmv1/third_party/terraform/services/compute/data_source_google_compute_network_test.go b/mmv1/third_party/terraform/services/compute/data_source_google_compute_network_test.go index d54970e576a7..71e6d4f0caa5 100644 --- a/mmv1/third_party/terraform/services/compute/data_source_google_compute_network_test.go +++ b/mmv1/third_party/terraform/services/compute/data_source_google_compute_network_test.go @@ -45,6 +45,7 @@ func testAccDataSourceGoogleNetworkCheck(data_source_name string, resource_name network_attrs_to_test := []string{ "id", "name", + "network_id", "numeric_id", "description", "internal_ipv6_range", diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_network_test.go.tmpl b/mmv1/third_party/terraform/services/compute/resource_compute_network_test.go.tmpl index 079c80455819..6fe55a31bfae 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_network_test.go.tmpl +++ b/mmv1/third_party/terraform/services/compute/resource_compute_network_test.go.tmpl @@ -262,6 +262,7 @@ func TestAccComputeNetwork_numericId(t *testing.T) { { Config: testAccComputeNetwork_basic(networkName), Check: resource.ComposeTestCheckFunc( + resource.TestMatchResourceAttr("google_compute_network.bar", "network_id",regexp.MustCompile("^\\d{16,48}$")), resource.TestMatchResourceAttr("google_compute_network.bar", "numeric_id",regexp.MustCompile("^\\d{16,48}$")), resource.TestCheckResourceAttr("google_compute_network.bar", "id", networkId), ), diff --git a/mmv1/third_party/terraform/website/docs/d/compute_network.html.markdown b/mmv1/third_party/terraform/website/docs/d/compute_network.html.markdown index dfe8b1f4cb35..52de13d65ff5 100644 --- a/mmv1/third_party/terraform/website/docs/d/compute_network.html.markdown +++ b/mmv1/third_party/terraform/website/docs/d/compute_network.html.markdown @@ -36,7 +36,9 @@ In addition to the arguments listed above, the following attributes are exported * `description` - Description of this network. -* `numeric_id` - The numeric unique identifier for the resource. +* `network_id` - The numeric unique identifier for the resource. + +* `numeric_id` - (Deprecated) The numeric unique identifier for the resource. `numeric_id` is deprecated and will be removed in a future major release. Use `network_id` instead. * `gateway_ipv4` - The IP address of the gateway.