Skip to content

Commit 9b85668

Browse files
authored
feat(gateway): add Addresses list to upcloud.Gateway (#254)
1 parent 1bccfc3 commit 9b85668

5 files changed

Lines changed: 42 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
77

88
### Added
99
- kubernetes: `control_plane_ip_filter` field to cluster for configuring and reading IP addresses and ranges allowed to access cluster control-plane
10+
- gateway: `addresses` list to provide IP addresses assigned to the gateway
1011

1112
## [6.5.0]
1213

upcloud/gateway.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ type Gateway struct {
4545
Routers []GatewayRouter `json:"routers,omitempty"`
4646
CreatedAt time.Time `json:"created_at,omitempty"`
4747
UpdatedAt time.Time `json:"updated_at,omitempty"`
48+
Addresses []GatewayAddress `json:"addresses,omitempty"`
49+
}
50+
51+
type GatewayAddress struct {
52+
Address string `json:"address,omitempty"`
53+
Name string `json:"name,omitempty"`
4854
}
4955

5056
type GatewayRouter struct {

upcloud/gateway_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ func TestGateway(t *testing.T) {
99

1010
jsonStr := `
1111
{
12+
"addresses": [
13+
{
14+
"address": "192.0.2.96",
15+
"name": "public-ip-1"
16+
}
17+
],
1218
"configured_status": "started",
1319
"created_at": "2022-12-01T09:04:08.529138Z",
1420
"features": [
@@ -35,6 +41,10 @@ func TestGateway(t *testing.T) {
3541
`
3642

3743
gateway := &Gateway{
44+
Addresses: []GatewayAddress{{
45+
Address: "192.0.2.96",
46+
Name: "public-ip-1",
47+
}},
3848
ConfiguredStatus: GatewayConfiguredStatusStarted,
3949
CreatedAt: timeParse("2022-12-01T09:04:08.529138Z"),
4050
Features: []GatewayFeature{

upcloud/service/fixtures/gateway.yaml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interactions:
1010
Content-Type:
1111
- application/json
1212
User-Agent:
13-
- upcloud-go-api/5.4.0
13+
- upcloud-go-api/6.5.0
1414
url: https://api.upcloud.com/1.3/router
1515
method: POST
1616
response:
@@ -24,7 +24,7 @@ interactions:
2424
"name" : "test-router",
2525
"static_routes" : [],
2626
"type" : "normal",
27-
"uuid" : "0436b532-00b5-4980-8f52-5e1e767b3f7e"
27+
"uuid" : "048b6f79-d4b8-4633-bd6e-96b49cda20db"
2828
}
2929
}
3030
headers:
@@ -33,7 +33,7 @@ interactions:
3333
Content-Type:
3434
- application/json; charset=UTF-8
3535
Date:
36-
- Mon, 27 Feb 2023 12:16:57 GMT
36+
- Wed, 02 Aug 2023 14:06:46 GMT
3737
Server:
3838
- Apache
3939
Strict-Transport-Security:
@@ -42,26 +42,26 @@ interactions:
4242
code: 201
4343
duration: ""
4444
- request:
45-
body: '{"name":"test","zone":"pl-waw1","features":["nat"],"routers":[{"uuid":"0436b532-00b5-4980-8f52-5e1e767b3f7e"}],"configured_status":"started"}'
45+
body: '{"name":"test","zone":"pl-waw1","features":["nat"],"routers":[{"uuid":"048b6f79-d4b8-4633-bd6e-96b49cda20db"}],"configured_status":"started"}'
4646
form: {}
4747
headers:
4848
Accept:
4949
- application/json
5050
Content-Type:
5151
- application/json
5252
User-Agent:
53-
- upcloud-go-api/5.4.0
53+
- upcloud-go-api/6.5.0
5454
url: https://api.upcloud.com/1.3/gateway
5555
method: POST
5656
response:
57-
body: '{"configured_status":"started","created_at":"2023-02-27T12:16:57.817751Z","features":["nat"],"labels":[],"name":"test","operational_state":"pending","routers":[{"created_at":"2023-02-27T12:16:57.817751Z","uuid":"0436b532-00b5-4980-8f52-5e1e767b3f7e"}],"updated_at":"2023-02-27T12:16:57.817751Z","uuid":"10d30045-3e66-4343-a0d9-aa5afdc0b9ba","zone":"pl-waw1"}'
57+
body: '{"addresses":[],"configured_status":"started","created_at":"2023-08-02T14:06:47.307493Z","features":["nat"],"labels":[],"name":"test","operational_state":"pending","routers":[{"created_at":"2023-08-02T14:06:47.307493Z","uuid":"048b6f79-d4b8-4633-bd6e-96b49cda20db"}],"updated_at":"2023-08-02T14:06:47.307493Z","uuid":"1050e056-6396-4150-869b-f654a75fe42a","zone":"pl-waw1"}'
5858
headers:
5959
Content-Length:
60-
- "358"
60+
- "373"
6161
Content-Type:
6262
- application/json
6363
Date:
64-
- Mon, 27 Feb 2023 12:16:57 GMT
64+
- Wed, 02 Aug 2023 14:06:47 GMT
6565
Strict-Transport-Security:
6666
- max-age=63072000
6767
status: 201 Created
@@ -76,18 +76,18 @@ interactions:
7676
Content-Type:
7777
- application/json
7878
User-Agent:
79-
- upcloud-go-api/5.4.0
80-
url: https://api.upcloud.com/1.3/gateway/10d30045-3e66-4343-a0d9-aa5afdc0b9ba
79+
- upcloud-go-api/6.5.0
80+
url: https://api.upcloud.com/1.3/gateway/1050e056-6396-4150-869b-f654a75fe42a
8181
method: GET
8282
response:
83-
body: '{"configured_status":"started","created_at":"2023-02-27T12:16:57.817751Z","features":["nat"],"labels":[],"name":"test","operational_state":"running","routers":[{"created_at":"2023-02-27T12:16:57.817751Z","uuid":"0436b532-00b5-4980-8f52-5e1e767b3f7e"}],"updated_at":"2023-02-27T12:19:48.766285Z","uuid":"10d30045-3e66-4343-a0d9-aa5afdc0b9ba","zone":"pl-waw1"}'
83+
body: '{"addresses":[{"address":"5.22.223.254","name":"public-ip-1"}],"configured_status":"started","created_at":"2023-08-02T14:06:47.307493Z","features":["nat"],"labels":[],"name":"test","operational_state":"running","routers":[{"created_at":"2023-08-02T14:06:47.307493Z","uuid":"048b6f79-d4b8-4633-bd6e-96b49cda20db"}],"updated_at":"2023-08-02T14:10:42.836847Z","uuid":"1050e056-6396-4150-869b-f654a75fe42a","zone":"pl-waw1"}'
8484
headers:
8585
Content-Length:
86-
- "358"
86+
- "420"
8787
Content-Type:
8888
- application/json
8989
Date:
90-
- Mon, 27 Feb 2023 12:19:53 GMT
90+
- Wed, 02 Aug 2023 14:10:45 GMT
9191
Strict-Transport-Security:
9292
- max-age=63072000
9393
status: 200 OK
@@ -102,18 +102,18 @@ interactions:
102102
Content-Type:
103103
- application/json
104104
User-Agent:
105-
- upcloud-go-api/5.4.0
106-
url: https://api.upcloud.com/1.3/gateway/10d30045-3e66-4343-a0d9-aa5afdc0b9ba
105+
- upcloud-go-api/6.5.0
106+
url: https://api.upcloud.com/1.3/gateway/1050e056-6396-4150-869b-f654a75fe42a
107107
method: PATCH
108108
response:
109-
body: '{"configured_status":"stopped","created_at":"2023-02-27T12:16:57.817751Z","features":["nat"],"labels":[],"name":"new-name","operational_state":"pending","routers":[{"created_at":"2023-02-27T12:16:57.817751Z","uuid":"0436b532-00b5-4980-8f52-5e1e767b3f7e"}],"updated_at":"2023-02-27T12:19:53.156823Z","uuid":"10d30045-3e66-4343-a0d9-aa5afdc0b9ba","zone":"pl-waw1"}'
109+
body: '{"addresses":[{"address":"5.22.223.254","name":"public-ip-1"}],"configured_status":"stopped","created_at":"2023-08-02T14:06:47.307493Z","features":["nat"],"labels":[],"name":"new-name","operational_state":"pending","routers":[{"created_at":"2023-08-02T14:06:47.307493Z","uuid":"048b6f79-d4b8-4633-bd6e-96b49cda20db"}],"updated_at":"2023-08-02T14:10:45.779957Z","uuid":"1050e056-6396-4150-869b-f654a75fe42a","zone":"pl-waw1"}'
110110
headers:
111111
Content-Length:
112-
- "362"
112+
- "424"
113113
Content-Type:
114114
- application/json
115115
Date:
116-
- Mon, 27 Feb 2023 12:19:53 GMT
116+
- Wed, 02 Aug 2023 14:10:45 GMT
117117
Strict-Transport-Security:
118118
- max-age=63072000
119119
status: 200 OK
@@ -128,14 +128,14 @@ interactions:
128128
Content-Type:
129129
- application/json
130130
User-Agent:
131-
- upcloud-go-api/5.4.0
132-
url: https://api.upcloud.com/1.3/gateway/10d30045-3e66-4343-a0d9-aa5afdc0b9ba
131+
- upcloud-go-api/6.5.0
132+
url: https://api.upcloud.com/1.3/gateway/1050e056-6396-4150-869b-f654a75fe42a
133133
method: DELETE
134134
response:
135135
body: ""
136136
headers:
137137
Date:
138-
- Mon, 27 Feb 2023 12:19:53 GMT
138+
- Wed, 02 Aug 2023 14:10:45 GMT
139139
Strict-Transport-Security:
140140
- max-age=63072000
141141
status: 204 No Content
@@ -150,14 +150,14 @@ interactions:
150150
Content-Type:
151151
- application/json
152152
User-Agent:
153-
- upcloud-go-api/5.4.0
154-
url: https://api.upcloud.com/1.3/router/0436b532-00b5-4980-8f52-5e1e767b3f7e
153+
- upcloud-go-api/6.5.0
154+
url: https://api.upcloud.com/1.3/router/048b6f79-d4b8-4633-bd6e-96b49cda20db
155155
method: DELETE
156156
response:
157157
body: ""
158158
headers:
159159
Date:
160-
- Mon, 27 Feb 2023 12:20:19 GMT
160+
- Wed, 02 Aug 2023 14:11:11 GMT
161161
Server:
162162
- Apache
163163
Strict-Transport-Security:

upcloud/service/gateway_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func TestGateway(t *testing.T) {
5757
if assert.Len(t, gw.Routers, 1) {
5858
assert.Equal(t, router.UUID, gw.Routers[0].UUID)
5959
}
60+
assert.Len(t, gw.Addresses, 1)
6061
gw, err = svc.ModifyGateway(ctx, &request.ModifyGatewayRequest{
6162
UUID: gw.UUID,
6263
Name: "new-name",

0 commit comments

Comments
 (0)