Skip to content

Commit 597bac6

Browse files
committed
Add flavor extra_specs
Signed-off-by: Roman Hros <roman.hros@dnation.cloud>
1 parent b8cb5e0 commit 597bac6

36 files changed

Lines changed: 988 additions & 238 deletions

api/v1alpha1/common_types.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,27 @@ type KubernetesNameRef string
101101
// +kubebuilder:validation:MinLength:=1
102102
// +kubebuilder:validation:MaxLength:=64
103103
type KeystoneName string
104+
105+
type ExtraSpec struct {
106+
// name is the name of the extraspec
107+
// +kubebuilder:validation:MaxLength:=255
108+
// +required
109+
Name string `json:"name"`
110+
111+
// value is the value of the extraspec
112+
// +kubebuilder:validation:MaxLength:=255
113+
// +required
114+
Value string `json:"value"`
115+
}
116+
117+
type ExtraSpecStatus struct {
118+
// name is the name of the extraspec
119+
// +kubebuilder:validation:MaxLength:=255
120+
// +optional
121+
Name string `json:"name,omitempty"`
122+
123+
// value is the value of the extraspec
124+
// +kubebuilder:validation:MaxLength:=255
125+
// +optional
126+
Value string `json:"value,omitempty"`
127+
}

api/v1alpha1/flavor_types.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ limitations under the License.
1717
package v1alpha1
1818

1919
// FlavorResourceSpec contains the desired state of a flavor
20-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="FlavorResourceSpec is immutable"
2120
type FlavorResourceSpec struct {
2221
// name will be the name of the created resource. If not specified, the
2322
// name of the ORC object will be used.
23+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="name is immutable"
2424
// +optional
2525
Name *OpenStackName `json:"name,omitempty"`
2626

@@ -29,22 +29,26 @@ type FlavorResourceSpec struct {
2929
// +kubebuilder:validation:MinLength=1
3030
// +kubebuilder:validation:MaxLength=255
3131
// +kubebuilder:validation:Pattern=^[a-zA-Z0-9._-]([a-zA-Z0-9. _-]*[a-zA-Z0-9._-])?$
32+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="id is immutable"
3233
// +optional
3334
ID string `json:"id,omitempty"` //nolint:kubeapilinter // intentionally allow raw ID
3435

3536
// description contains a free form description of the flavor.
3637
// +kubebuilder:validation:MinLength:=1
3738
// +kubebuilder:validation:MaxLength:=65535
39+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="description is immutable"
3840
// +optional
3941
Description *string `json:"description,omitempty"`
4042

4143
// ram is the memory of the flavor, measured in MB.
4244
// +kubebuilder:validation:Minimum=1
45+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ram is immutable"
4346
// +required
4447
RAM int32 `json:"ram,omitempty"`
4548

4649
// vcpus is the number of vcpus for the flavor.
4750
// +kubebuilder:validation:Minimum=1
51+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="vcpus is immutable"
4852
// +required
4953
Vcpus int32 `json:"vcpus,omitempty"`
5054

@@ -57,16 +61,26 @@ type FlavorResourceSpec struct {
5761
// zero root disk via the
5862
// os_compute_api:servers:create:zero_disk_flavor policy rule.
5963
// +kubebuilder:validation:Minimum=0
64+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="disk is immutable"
6065
// +required
6166
Disk int32 `json:"disk"`
6267

6368
// swap is the size of a dedicated swap disk that will be allocated, in
6469
// MiB. If 0 (the default), no dedicated swap disk will be created.
6570
// +kubebuilder:validation:Minimum=0
71+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="swap is immutable"
6672
// +optional
6773
Swap int32 `json:"swap,omitempty"`
6874

75+
// extraSpecs is a map of key-value pairs that define extra specifications for the flavor.
76+
// +kubebuilder:validation:MaxItems:=128
77+
// +kubebuilder:validation:XValidation:rule="self.all(x, self.filter(y, y.name == x.name).size() == 1)",message="extraSpecs names must be unique"
78+
// +listType=atomic
79+
// +optional
80+
ExtraSpecs []ExtraSpec `json:"extraSpecs,omitempty"`
81+
6982
// isPublic flags a flavor as being available to all projects or not.
83+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="isPublic is immutable"
7084
// +optional
7185
IsPublic *bool `json:"isPublic,omitempty"`
7286

@@ -75,6 +89,7 @@ type FlavorResourceSpec struct {
7589
// be used as a scratch space for applications that are aware of its
7690
// limitations. Defaults to 0.
7791
// +kubebuilder:validation:Minimum=0
92+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ephemeral is immutable"
7893
// +optional
7994
Ephemeral int32 `json:"ephemeral,omitempty"`
8095
}
@@ -131,6 +146,12 @@ type FlavorResourceStatus struct {
131146
// +optional
132147
Swap *int32 `json:"swap,omitempty"`
133148

149+
// extraSpecs is a map of key-value pairs that define extra specifications for the flavor.
150+
// +kubebuilder:validation:MaxItems:=128
151+
// +listType=atomic
152+
// +optional
153+
ExtraSpecs []ExtraSpecStatus `json:"extraSpecs"`
154+
134155
// isPublic flags a flavor as being available to all projects or not.
135156
// +optional
136157
IsPublic *bool `json:"isPublic,omitempty"`

api/v1alpha1/volumetype_types.go

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ type VolumeTypeResourceSpec struct {
3131

3232
// extraSpecs is a map of key-value pairs that define extra specifications for the volume type.
3333
// +kubebuilder:validation:MaxItems:=64
34+
// +kubebuilder:validation:XValidation:rule="self.all(x, self.filter(y, y.name == x.name).size() == 1)",message="extraSpecs names must be unique"
3435
// +listType=atomic
3536
// +optional
36-
ExtraSpecs []VolumeTypeExtraSpec `json:"extraSpecs,omitempty"`
37+
ExtraSpecs []ExtraSpec `json:"extraSpecs,omitempty"`
3738

3839
// isPublic indicates whether the volume type is public.
3940
// +optional
@@ -74,33 +75,9 @@ type VolumeTypeResourceStatus struct {
7475
// +kubebuilder:validation:MaxItems:=64
7576
// +listType=atomic
7677
// +optional
77-
ExtraSpecs []VolumeTypeExtraSpecStatus `json:"extraSpecs"`
78+
ExtraSpecs []ExtraSpecStatus `json:"extraSpecs"`
7879

7980
// isPublic indicates whether the VolumeType is public.
8081
// +optional
8182
IsPublic *bool `json:"isPublic"`
8283
}
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"`
106-
}

api/v1alpha1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)