Skip to content

Commit 8c64fa1

Browse files
committed
feat(datacenter, server-type): Move available and recommended to server_type
1 parent c4d60b3 commit 8c64fa1

10 files changed

Lines changed: 23 additions & 29 deletions

File tree

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ linters:
6565
text: var-naming
6666
- linters:
6767
- staticcheck
68-
text: Datacenter is deprecated
68+
text: (Datacenter is deprecated|\[Datacenter.ServerTypes\] is deprecated)
6969

7070
formatters:
7171
enable:

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@ require (
6363
google.golang.org/protobuf v1.36.8 // indirect
6464
gopkg.in/yaml.v3 v3.0.1 // indirect
6565
)
66+
67+
replace github.com/hetznercloud/hcloud-go/v2 => github.com/hetznercloud/hcloud-go/v2 v2.37.1-0.20260410081632-85dd7f3232b8

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
3737
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
3838
github.com/guptarohit/asciigraph v0.9.0 h1:MvCSRRVkT2XvU1IO6n92o7l7zqx1DiFaoszOUZQztbY=
3939
github.com/guptarohit/asciigraph v0.9.0/go.mod h1:dYl5wwK4gNsnFf9Zp+l06rFiDZ5YtXM6x7SRWZ3KGag=
40-
github.com/hetznercloud/hcloud-go/v2 v2.37.0 h1:PMnuOA8pL8aHLLPp6nnnCTo2Xk2tqu4dAfYsC3bWdT0=
41-
github.com/hetznercloud/hcloud-go/v2 v2.37.0/go.mod h1:zaDOCKmpnI86ftoCpUpaiYaw9Wew1ib1AcXTh96deYI=
40+
github.com/hetznercloud/hcloud-go/v2 v2.37.1-0.20260410081632-85dd7f3232b8 h1:nRdcWLhKcYLnHdi0zl0BdIUpcuAWdB722r6yk0K+ki8=
41+
github.com/hetznercloud/hcloud-go/v2 v2.37.1-0.20260410081632-85dd7f3232b8/go.mod h1:qLL/i7AERTum2JPTXf4Og+hrodL/d8pAnqhgRHeKEXg=
4242
github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc=
4343
github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE=
4444
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=

internal/cmd/datacenter/describe.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ func DescribeDatacenter(client hcapi2.Client, datacenter *hcloud.Datacenter, sho
4949
fmt.Fprintf(&sb, "Location:\n")
5050
fmt.Fprint(&sb, util.PrefixLines(location.DescribeLocation(datacenter.Location), " "))
5151

52+
// datacenter.ServerTypes will not be populated anymore after 2026-10-01
53+
if dst := datacenter.ServerTypes; dst.Available == nil && dst.Supported == nil && dst.AvailableForMigration == nil {
54+
return sb.String()
55+
}
56+
5257
type ServerTypeStatus struct {
5358
ID int64
5459
Available bool

internal/cmd/datacenter/describe_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ Location:
4343
City:
4444
Latitude: 0.000000
4545
Longitude: 0.000000
46-
47-
Server Types:
48-
No Server Types
4946
`
5047

5148
require.NoError(t, err)

internal/cmd/datacenter/list_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ func TestListJSON(t *testing.T) {
9595
"latitude": 0,
9696
"longitude": 0,
9797
"network_zone": ""
98-
},
99-
"server_types": {
100-
"supported": null,
101-
"available_for_migration": null,
102-
"available": null
10398
}
10499
}
105100
]`, out)

internal/cmd/primaryip/testdata/create_response.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@
2828
"name": "fsn1",
2929
"network_zone": ""
3030
},
31-
"name": "fsn1-dc14",
32-
"server_types": {
33-
"available": null,
34-
"available_for_migration": null,
35-
"supported": null
36-
}
31+
"name": "fsn1-dc14"
3732
},
3833
"dns_ptr": [],
3934
"id": 1,

internal/cmd/server/testdata/create_response.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@
2626
"name": "fsn1",
2727
"network_zone": ""
2828
},
29-
"name": "fsn1-dc14",
30-
"server_types": {
31-
"available": null,
32-
"available_for_migration": null,
33-
"supported": null
34-
}
29+
"name": "fsn1-dc14"
3530
},
3631
"id": 1234,
3732
"image": {
@@ -111,8 +106,8 @@
111106
"prices": null,
112107
"storage_type": "local",
113108
"locations": [
114-
{ "id": 1, "name": "fsn1", "deprecation": null },
115-
{ "id": 2, "name": "nbg1", "deprecation": null }
109+
{ "id": 1, "name": "fsn1", "deprecation": null, "available": false, "recommended": false },
110+
{ "id": 2, "name": "nbg1", "deprecation": null, "available": false, "recommended": false }
116111
]
117112
},
118113
"status": "running",

internal/cmd/servertype/describe.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ func DescribeServerType(s state.State, serverType *hcloud.ServerType, short bool
6565
for _, info := range locations {
6666

6767
fmt.Fprintf(&sb, " - Location:\t%s\n", info.Location.Name)
68+
fmt.Fprintf(&sb, " Available:\t%s\n", util.YesNo(info.Available))
69+
fmt.Fprintf(&sb, " Recommended:\t%s\n", util.YesNo(info.Recommended))
6870

6971
if deprecationText := util.DescribeDeprecation(info); deprecationText != "" {
7072
fmt.Fprint(&sb, util.PrefixLines(deprecationText, " "))
@@ -97,16 +99,15 @@ func fullPricingInfo(s state.State, serverType *hcloud.ServerType) ([]hcloud.Ser
9799
}
98100

99101
type locationInfo struct {
100-
Location *hcloud.Location
101-
hcloud.DeprecatableResource
102+
*hcloud.ServerTypeLocation
102103
Pricing hcloud.ServerTypeLocationPricing
103104
}
104105

105106
func joinLocationInfo(serverType *hcloud.ServerType, pricings []hcloud.ServerTypeLocationPricing) []locationInfo {
106107
locations := make([]locationInfo, 0, len(serverType.Locations))
107108

108109
for _, location := range serverType.Locations {
109-
info := locationInfo{Location: location.Location, DeprecatableResource: location.DeprecatableResource}
110+
info := locationInfo{ServerTypeLocation: &location}
110111

111112
for _, pricing := range pricings {
112113
// Pricing endpoint only sets the location name

internal/cmd/servertype/describe_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ func TestDescribe(t *testing.T) {
4444
{
4545
Location: &hcloud.Location{Name: "fsn1"},
4646
DeprecatableResource: deprecation,
47+
Available: true,
48+
Recommended: false,
4749
},
4850
},
4951
}, nil, nil)
@@ -112,7 +114,9 @@ Disk: 40 GB
112114
Storage Type: local
113115
114116
Locations:
115-
- Location: fsn1
117+
- Location: fsn1
118+
Available: yes
119+
Recommended: no
116120
Deprecation:
117121
Announced: %s (%s)
118122
Unavailable After: %s (%s)

0 commit comments

Comments
 (0)