Skip to content

Commit

Permalink
Add DeviceSelector types
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Lönnegren <[email protected]>
  • Loading branch information
frelon committed Nov 2, 2023
1 parent de0d098 commit 758eb92
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 0 deletions.
30 changes: 30 additions & 0 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type Install struct {
// +optional
Device string `json:"device,omitempty" yaml:"device,omitempty"`
// +optional
DeviceSelector DeviceSelector `json:"device-selector,omitempty" yaml:"device-selector,omitempty"`
// +optional
NoFormat bool `json:"no-format,omitempty" yaml:"no-format,omitempty"`
// +optional
ConfigURLs []string `json:"config-urls,omitempty" yaml:"config-urls,omitempty"`
Expand Down Expand Up @@ -120,3 +122,31 @@ type Config struct {
// +optional
CloudConfig map[string]runtime.RawExtension `json:"cloud-config,omitempty" yaml:"cloud-config,omitempty"`
}

type DeviceSelector []DeviceSelectorRequirement

type DeviceSelectorRequirement struct {
// +required
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=Name;Size
Key DeviceSelectorKey `json:"key"`
// +required
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=In;NotIn;Gt;Lt
Operator DeviceSelectorOperator `json:"operator"`
// +optional
Values []string `json:"values,omitempty"`
}

type DeviceSelectorKey string
type DeviceSelectorOperator string

const (
DeviceSelectorOpIn DeviceSelectorOperator = "In"
DeviceSelectorOpNotIn DeviceSelectorOperator = "NotIn"
DeviceSelectorOpGt DeviceSelectorOperator = "Gt"
DeviceSelectorOpLt DeviceSelectorOperator = "Lt"

DeviceSelectorKeyName DeviceSelectorKey = "Name"
DeviceSelectorKeySize DeviceSelectorKey = "Size"
)
48 changes: 48 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

16 changes: 16 additions & 0 deletions charts/crds/templates/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,22 @@ spec:
type: boolean
device:
type: string
device-selector:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
disable-boot-entry:
type: boolean
eject-cd:
Expand Down
24 changes: 24 additions & 0 deletions config/crd/bases/elemental.cattle.io_machineregistrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,30 @@ spec:
type: boolean
device:
type: string
device-selector:
items:
properties:
key:
enum:
- Name
- Size
type: string
operator:
enum:
- In
- NotIn
- Gt
- Lt
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
disable-boot-entry:
type: boolean
eject-cd:
Expand Down

0 comments on commit 758eb92

Please sign in to comment.