Skip to content

Commit

Permalink
compute: add numeric_id to google_compute_network data source
Browse files Browse the repository at this point in the history
Add `numeric_id` to `google_compute_network` data source, matching the
resource.

Switch `numeric_id` to to be an integer internally within the
`google_compute_network` resource for consistency with the API and with
`google_compute_subnetwork`.

Followup to GoogleCloudPlatform#12285
Part of hashicorp/terraform-provider-google#20223
  • Loading branch information
wyardley committed Nov 15, 2024
1 parent acda2f0 commit a207c00
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mmv1/products/compute/Network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ properties:
validation:
function: 'verify.ValidateGCEName'
- name: 'numericId'
type: String
type: Integer
description: |
The unique identifier for the resource. This identifier is defined by the server.
output: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ func DataSourceGoogleComputeNetwork() *schema.Resource {
Computed: true,
},

"numeric_id": {
Type: schema.TypeInt,
Computed: true,
},

"gateway_ipv4": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -83,6 +88,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("numeric_id", network.Id); err != nil {
return fmt.Errorf("Error setting numeric_id: %s", err)
}
if err := d.Set("subnetworks_self_links", network.Subnetworks); err != nil {
return fmt.Errorf("Error setting subnetworks_self_links: %s", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func testAccDataSourceGoogleNetworkCheck(data_source_name string, resource_name
network_attrs_to_test := []string{
"id",
"name",
"numeric_id",
"description",
"internal_ipv6_range",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func TestAccComputeNetwork_numericId(t *testing.T) {
{
Config: testAccComputeNetwork_basic(networkName),
Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("google_compute_network.bar", "numeric_id",regexp.MustCompile("^\\d{1,}$")),
resource.TestMatchResourceAttr("google_compute_network.bar", "numeric_id",regexp.MustCompile("^\\d{16,48}$")),
resource.TestCheckResourceAttr("google_compute_network.bar", "id", networkId),
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ 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.

* `gateway_ipv4` - The IP address of the gateway.

* `internal_ipv6_range` - The ula internal ipv6 range assigned to this network.
Expand Down

0 comments on commit a207c00

Please sign in to comment.