Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion api/v1alpha1/flavor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ limitations under the License.
package v1alpha1

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

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

// description contains a free form description of the flavor.
// +kubebuilder:validation:MinLength:=1
// +kubebuilder:validation:MaxLength:=65535
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="description is immutable"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that the description should in theory be mutable (https://docs.openstack.org/api-ref/compute/#update-flavor-description) but this is clearly out of scope for this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know about mutable description, but as you said i didn't want to change it with this PR.

// +optional
Description *string `json:"description,omitempty"`

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

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

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

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

// extraSpecs is a list of key-value pairs that define extra specifications for the flavor.
// +kubebuilder:validation:MaxItems:=128
// +listType=map
// +listMapKey=name
// +optional
ExtraSpecs []FlavorExtraSpec `json:"extraSpecs,omitempty"`

// isPublic flags a flavor as being available to all projects or not.
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="isPublic is immutable"
// +optional
IsPublic *bool `json:"isPublic,omitempty"`

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

// extraSpecs is a map of key-value pairs that define extra specifications for the flavor.
// +kubebuilder:validation:MaxItems:=128
// +listType=atomic
// +optional
ExtraSpecs []FlavorExtraSpecStatus `json:"extraSpecs"`

// isPublic flags a flavor as being available to all projects or not.
// +optional
IsPublic *bool `json:"isPublic,omitempty"`
Expand All @@ -139,3 +160,28 @@ type FlavorResourceStatus struct {
// +optional
Ephemeral *int32 `json:"ephemeral,omitempty"`
}

type FlavorExtraSpec struct {
// name is the name of the extraspec
// +kubebuilder:validation:Pattern="^[a-zA-Z0-9-_:. ]+$"
// +kubebuilder:validation:MaxLength:=255
// +required
Name string `json:"name"`

// value is the value of the extraspec
// +kubebuilder:validation:MaxLength:=255
// +required
Value string `json:"value"`
}

type FlavorExtraSpecStatus struct {
// name is the name of the extraspec
// +kubebuilder:validation:MaxLength:=255
// +optional
Name string `json:"name,omitempty"`

// value is the value of the extraspec
// +kubebuilder:validation:MaxLength:=255
// +optional
Value string `json:"value,omitempty"`
}
40 changes: 40 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 102 additions & 0 deletions cmd/models-schema/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading