Skip to content

Commit e6326dc

Browse files
authored
feat(vpcgw): set type & status fields (#2219)
1 parent 9954056 commit e6326dc

File tree

4 files changed

+223
-214
lines changed

4 files changed

+223
-214
lines changed

docs/resources/vpc_public_gateway.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ In addition to all above arguments, the following attributes are exported:
4444
- `organization_id` - The organization ID the public gateway is associated with.
4545
- `created_at` - The date and time of the creation of the public gateway.
4646
- `updated_at` - The date and time of the last update of the public gateway.
47+
- `status` - The status of the public gateway.
4748

4849
## Import
4950

scaleway/resource_vpc_public_gateway.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ func resourceScalewayVPCPublicGateway() *schema.Resource {
9595
Computed: true,
9696
Description: "The date and time of the last update of the public gateway",
9797
},
98+
"status": {
99+
Type: schema.TypeString,
100+
Computed: true,
101+
Description: "The status of the public gateway",
102+
},
98103
},
99104
}
100105
}
@@ -156,6 +161,8 @@ func resourceScalewayVPCPublicGatewayRead(ctx context.Context, d *schema.Resourc
156161
}
157162

158163
_ = d.Set("name", gateway.Name)
164+
_ = d.Set("type", gateway.Type.Name)
165+
_ = d.Set("status", gateway.Status.String())
159166
_ = d.Set("organization_id", gateway.OrganizationID)
160167
_ = d.Set("project_id", gateway.ProjectID)
161168
_ = d.Set("created_at", gateway.CreatedAt.Format(time.RFC3339))

scaleway/resource_vpc_public_gateway_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,10 @@ func TestAccScalewayVPCPublicGateway_Basic(t *testing.T) {
5959
}
6060
`, publicGatewayName),
6161
Check: resource.ComposeTestCheckFunc(
62-
testAccCheckScalewayVPCPublicGatewayExists(
63-
tt,
64-
"scaleway_vpc_public_gateway.main",
65-
),
66-
resource.TestCheckResourceAttr(
67-
"scaleway_vpc_public_gateway.main",
68-
"name",
69-
publicGatewayName,
70-
),
62+
testAccCheckScalewayVPCPublicGatewayExists(tt, "scaleway_vpc_public_gateway.main"),
63+
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "name", publicGatewayName),
64+
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "type", "VPC-GW-S"),
65+
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "status", vpcgw.GatewayStatusRunning.String()),
7166
),
7267
},
7368
{
@@ -82,6 +77,8 @@ func TestAccScalewayVPCPublicGateway_Basic(t *testing.T) {
8277
Check: resource.ComposeTestCheckFunc(
8378
testAccCheckScalewayVPCPublicGatewayExists(tt, "scaleway_vpc_public_gateway.main"),
8479
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "name", publicGatewayName+"-new"),
80+
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "type", "VPC-GW-S"),
81+
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "status", vpcgw.GatewayStatusRunning.String()),
8582
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "tags.0", "tag0"),
8683
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "tags.1", "tag1"),
8784
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "upstream_dns_servers.0", "1.2.3.4"),
@@ -99,6 +96,8 @@ func TestAccScalewayVPCPublicGateway_Basic(t *testing.T) {
9996
Check: resource.ComposeTestCheckFunc(
10097
testAccCheckScalewayVPCPublicGatewayExists(tt, "scaleway_vpc_public_gateway.main"),
10198
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "name", publicGatewayName+"-zone"),
99+
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "type", "VPC-GW-S"),
100+
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "status", vpcgw.GatewayStatusRunning.String()),
102101
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "zone", "nl-ams-1"),
103102
),
104103
},
@@ -113,6 +112,8 @@ func TestAccScalewayVPCPublicGateway_Basic(t *testing.T) {
113112
Check: resource.ComposeTestCheckFunc(
114113
testAccCheckScalewayVPCPublicGatewayExists(tt, "scaleway_vpc_public_gateway.main"),
115114
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "name", publicGatewayName+"-zone-to-update"),
115+
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "type", "VPC-GW-S"),
116+
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "status", vpcgw.GatewayStatusRunning.String()),
116117
resource.TestCheckResourceAttr("scaleway_vpc_public_gateway.main", "zone", "nl-ams-1"),
117118
),
118119
},

0 commit comments

Comments
 (0)