Skip to content

Commit 5c17b15

Browse files
committed
VolumeType: implement API, controller and tests
1 parent c19c37c commit 5c17b15

32 files changed

+647
-70
lines changed

api/v1alpha1/volumetype_types.go

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ type VolumeTypeResourceSpec struct {
2929
// +optional
3030
Description *string `json:"description,omitempty"`
3131

32-
// TODO(scaffolding): Add more types.
33-
// To see what is supported, you can take inspiration from the CreateOpts stucture from
34-
// github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumetypes
35-
//
36-
// Until you have implemented mutability for the field, you must add a CEL validation
37-
// preventing the field being modified:
38-
// `// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="<fieldname> is immutable"`
32+
// extraSpecs is a map of key-value pairs that define extra specifications for the volume type.
33+
// +kubebuilder:validation:MaxItems:=32
34+
// +listType=atomic
35+
// +optional
36+
ExtraSpecs []VolumeTypeExtraSpec `json:"extraSpecs,omitempty"`
37+
38+
// isPublic indicates whether the volume type is public.
39+
// +optional
40+
IsPublic *bool `json:"isPublic,omitempty"`
3941
}
4042

4143
// VolumeTypeFilter defines an existing resource by its properties
@@ -51,9 +53,9 @@ type VolumeTypeFilter struct {
5153
// +optional
5254
Description *string `json:"description,omitempty"`
5355

54-
// TODO(scaffolding): Add more types.
55-
// To see what is supported, you can take inspiration from the ListOpts stucture from
56-
// github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumetypes
56+
// isPublic indicates whether the VolumeType is public.
57+
// +optional
58+
IsPublic *bool `json:"isPublic,omitempty"`
5759
}
5860

5961
// VolumeTypeResourceStatus represents the observed state of the resource.
@@ -68,7 +70,37 @@ type VolumeTypeResourceStatus struct {
6870
// +optional
6971
Description string `json:"description,omitempty"`
7072

71-
// TODO(scaffolding): Add more types.
72-
// To see what is supported, you can take inspiration from the VolumeType stucture from
73-
// github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/volumetypes
73+
// extraSpecs is a map of key-value pairs that define extra specifications for the volume type.
74+
// +kubebuilder:validation:MaxItems:=32
75+
// +listType=atomic
76+
// +optional
77+
ExtraSpecs []VolumeTypeExtraSpecStatus `json:"extraSpecs"`
78+
79+
// isPublic indicates whether the VolumeType is public.
80+
// +optional
81+
IsPublic *bool `json:"isPublic"`
82+
}
83+
84+
type VolumeTypeExtraSpec struct {
85+
// name is the name of the extraspec
86+
// +kubebuilder:validation:MaxLength:=255
87+
// +required
88+
Name string `json:"name"`
89+
90+
// value is the value of the extraspec
91+
// +kubebuilder:validation:MaxLength:=255
92+
// +required
93+
Value string `json:"value"`
94+
}
95+
96+
type VolumeTypeExtraSpecStatus struct {
97+
// name is the name of the extraspec
98+
// +kubebuilder:validation:MaxLength:=255
99+
// +optional
100+
Name string `json:"name,omitempty"`
101+
102+
// value is the value of the extraspec
103+
// +kubebuilder:validation:MaxLength:=255
104+
// +optional
105+
Value string `json:"value,omitempty"`
74106
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 56 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/models-schema/zz_generated.openapi.go

Lines changed: 120 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/openstack.k-orc.cloud_volumetypes.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ spec:
9696
maxLength: 255
9797
minLength: 1
9898
type: string
99+
isPublic:
100+
description: isPublic indicates whether the VolumeType is
101+
public.
102+
type: boolean
99103
name:
100104
description: name of the existing resource
101105
maxLength: 255
@@ -155,6 +159,29 @@ spec:
155159
maxLength: 255
156160
minLength: 1
157161
type: string
162+
extraSpecs:
163+
description: extraSpecs is a map of key-value pairs that define
164+
extra specifications for the volume type.
165+
items:
166+
properties:
167+
name:
168+
description: name is the name of the extraspec
169+
maxLength: 255
170+
type: string
171+
value:
172+
description: value is the value of the extraspec
173+
maxLength: 255
174+
type: string
175+
required:
176+
- name
177+
- value
178+
type: object
179+
maxItems: 32
180+
type: array
181+
x-kubernetes-list-type: atomic
182+
isPublic:
183+
description: isPublic indicates whether the volume type is public.
184+
type: boolean
158185
name:
159186
description: |-
160187
name will be the name of the created resource. If not specified, the
@@ -271,6 +298,26 @@ spec:
271298
resource.
272299
maxLength: 1024
273300
type: string
301+
extraSpecs:
302+
description: extraSpecs is a map of key-value pairs that define
303+
extra specifications for the volume type.
304+
items:
305+
properties:
306+
name:
307+
description: name is the name of the extraspec
308+
maxLength: 255
309+
type: string
310+
value:
311+
description: value is the value of the extraspec
312+
maxLength: 255
313+
type: string
314+
type: object
315+
maxItems: 32
316+
type: array
317+
x-kubernetes-list-type: atomic
318+
isPublic:
319+
description: isPublic indicates whether the VolumeType is public.
320+
type: boolean
274321
name:
275322
description: name is a Human-readable name for the resource. Might
276323
not be unique.

0 commit comments

Comments
 (0)