Skip to content

Commit d67e89a

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

35 files changed

Lines changed: 874 additions & 235 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: 21 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,25 @@ 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+
// +listType=atomic
78+
// +optional
79+
ExtraSpecs []ExtraSpec `json:"extraSpecs,omitempty"`
80+
6981
// isPublic flags a flavor as being available to all projects or not.
82+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="isPublic is immutable"
7083
// +optional
7184
IsPublic *bool `json:"isPublic,omitempty"`
7285

@@ -75,6 +88,7 @@ type FlavorResourceSpec struct {
7588
// be used as a scratch space for applications that are aware of its
7689
// limitations. Defaults to 0.
7790
// +kubebuilder:validation:Minimum=0
91+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ephemeral is immutable"
7892
// +optional
7993
Ephemeral int32 `json:"ephemeral,omitempty"`
8094
}
@@ -131,6 +145,12 @@ type FlavorResourceStatus struct {
131145
// +optional
132146
Swap *int32 `json:"swap,omitempty"`
133147

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

api/v1alpha1/volumetype_types.go

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type VolumeTypeResourceSpec struct {
3333
// +kubebuilder:validation:MaxItems:=64
3434
// +listType=atomic
3535
// +optional
36-
ExtraSpecs []VolumeTypeExtraSpec `json:"extraSpecs,omitempty"`
36+
ExtraSpecs []ExtraSpec `json:"extraSpecs,omitempty"`
3737

3838
// isPublic indicates whether the volume type is public.
3939
// +optional
@@ -74,33 +74,9 @@ type VolumeTypeResourceStatus struct {
7474
// +kubebuilder:validation:MaxItems:=64
7575
// +listType=atomic
7676
// +optional
77-
ExtraSpecs []VolumeTypeExtraSpecStatus `json:"extraSpecs"`
77+
ExtraSpecs []ExtraSpecStatus `json:"extraSpecs"`
7878

7979
// isPublic indicates whether the VolumeType is public.
8080
// +optional
8181
IsPublic *bool `json:"isPublic"`
8282
}
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)