Skip to content

Commit 1636fb3

Browse files
🌱 Allow all values for HCloudMachine type (#1694)
allow all values for HCloudMachine type The list of valid machine types gets changed by the Hetzner from time to time. CAPH no longer validates this string. It is up to the user to use a valid type as not all types are available in all the locations. Signed-off-by: Dhairya Arora <[email protected]>
1 parent 89adce8 commit 1636fb3

File tree

4 files changed

+44
-83
lines changed

4 files changed

+44
-83
lines changed

api/v1beta1/hcloudmachine_types.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,18 @@ type HCloudMachineSpec struct {
3939
// +optional
4040
ProviderID *string `json:"providerID,omitempty"`
4141

42-
// Type is the HCloud Machine Type for this machine. It defines the desired server type of server in Hetzner's Cloud API. Example: cpx11.
43-
// +kubebuilder:validation:Enum=cpx11;cx21;cpx21;cx31;cpx31;cx41;cpx41;cx51;cpx51;ccx11;ccx12;ccx13;ccx21;ccx22;ccx23;ccx31;ccx32;ccx33;ccx41;ccx42;ccx43;ccx51;ccx52;ccx53;ccx62;ccx63;cax11;cax21;cax31;cax41;cx22;cx32;cx42;cx52
42+
// Type is the HCloud Machine Type for this machine. It defines the desired server type of
43+
// server in Hetzner's Cloud API. You can use the hcloud CLI to get server names (`hcloud
44+
// server-type list`) or on https://www.hetzner.com/cloud
45+
//
46+
// The types follow this pattern: cxNV (shared, cheap), cpxNV (shared, performance), ccxNV
47+
// (dedicated), caxNV (ARM)
48+
//
49+
// N is a number, and V is the version of this machine type. Example: cpx32.
50+
//
51+
// The list of valid machine types gets changed by Hetzner from time to time. CAPH no longer
52+
// validates this string. It is up to you to use a valid type. Not all types are available in all
53+
// locations.
4454
Type HCloudMachineType `json:"type"`
4555

4656
// ImageName is the reference to the Machine Image from which to create the machine instance.

config/crd/bases/infrastructure.cluster.x-k8s.io_hcloudmachines.yaml

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -117,44 +117,22 @@ spec:
117117
type: object
118118
type: array
119119
type:
120-
description: 'Type is the HCloud Machine Type for this machine. It
121-
defines the desired server type of server in Hetzner''s Cloud API.
122-
Example: cpx11.'
123-
enum:
124-
- cpx11
125-
- cx21
126-
- cpx21
127-
- cx31
128-
- cpx31
129-
- cx41
130-
- cpx41
131-
- cx51
132-
- cpx51
133-
- ccx11
134-
- ccx12
135-
- ccx13
136-
- ccx21
137-
- ccx22
138-
- ccx23
139-
- ccx31
140-
- ccx32
141-
- ccx33
142-
- ccx41
143-
- ccx42
144-
- ccx43
145-
- ccx51
146-
- ccx52
147-
- ccx53
148-
- ccx62
149-
- ccx63
150-
- cax11
151-
- cax21
152-
- cax31
153-
- cax41
154-
- cx22
155-
- cx32
156-
- cx42
157-
- cx52
120+
description: |-
121+
Type is the HCloud Machine Type for this machine. It defines the desired server type of
122+
server in Hetzner's Cloud API. You can use the hcloud CLI to get server names (`hcloud
123+
server-type list`) or on https://www.hetzner.com/cloud
124+
125+
126+
The types follow this pattern: cxNV (shared, cheap), cpxNV (shared, performance), ccxNV
127+
(dedicated), caxNV (ARM)
128+
129+
130+
N is a number, and V is the version of this machine type. Example: cpx32.
131+
132+
133+
The list of valid machine types gets changed by Hetzner from time to time. CAPH no longer
134+
validates this string. It is up to you to use a valid type. Not all types are available in all
135+
locations.
158136
type: string
159137
required:
160138
- imageName

config/crd/bases/infrastructure.cluster.x-k8s.io_hcloudmachinetemplates.yaml

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -144,44 +144,22 @@ spec:
144144
type: object
145145
type: array
146146
type:
147-
description: 'Type is the HCloud Machine Type for this machine.
148-
It defines the desired server type of server in Hetzner''s
149-
Cloud API. Example: cpx11.'
150-
enum:
151-
- cpx11
152-
- cx21
153-
- cpx21
154-
- cx31
155-
- cpx31
156-
- cx41
157-
- cpx41
158-
- cx51
159-
- cpx51
160-
- ccx11
161-
- ccx12
162-
- ccx13
163-
- ccx21
164-
- ccx22
165-
- ccx23
166-
- ccx31
167-
- ccx32
168-
- ccx33
169-
- ccx41
170-
- ccx42
171-
- ccx43
172-
- ccx51
173-
- ccx52
174-
- ccx53
175-
- ccx62
176-
- ccx63
177-
- cax11
178-
- cax21
179-
- cax31
180-
- cax41
181-
- cx22
182-
- cx32
183-
- cx42
184-
- cx52
147+
description: |-
148+
Type is the HCloud Machine Type for this machine. It defines the desired server type of
149+
server in Hetzner's Cloud API. You can use the hcloud CLI to get server names (`hcloud
150+
server-type list`) or on https://www.hetzner.com/cloud
151+
152+
153+
The types follow this pattern: cxNV (shared, cheap), cpxNV (shared, performance), ccxNV
154+
(dedicated), caxNV (ARM)
155+
156+
157+
N is a number, and V is the version of this machine type. Example: cpx32.
158+
159+
160+
The list of valid machine types gets changed by Hetzner from time to time. CAPH no longer
161+
validates this string. It is up to you to use a valid type. Not all types are available in all
162+
locations.
185163
type: string
186164
required:
187165
- imageName

controllers/hcloudmachine_controller_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -808,11 +808,6 @@ var _ = Describe("HCloudMachine validation", func() {
808808
Expect(testEnv.Cleanup(ctx, testNs, hcloudMachine)).To(Succeed())
809809
})
810810

811-
It("should fail with wrong type", func() {
812-
hcloudMachine.Spec.Type = "wrong-type"
813-
Expect(testEnv.Create(ctx, hcloudMachine)).ToNot(Succeed())
814-
})
815-
816811
It("should fail without imageName", func() {
817812
hcloudMachine.Spec.ImageName = ""
818813
Expect(testEnv.Create(ctx, hcloudMachine)).ToNot(Succeed())

0 commit comments

Comments
 (0)