Skip to content

Commit 108a81f

Browse files
committed
ensure kubebuilder enum enforcement on all fields making use of CapacityReservationPreference type
1 parent aa0e221 commit 108a81f

6 files changed

+52
-26
lines changed

api/v1beta2/awsmachine_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ type AWSMachineSpec struct {
247247
HostAffinity *string `json:"hostAffinity,omitempty"`
248248

249249
// CapacityReservationPreference specifies the preference for use of Capacity Reservations by the instance. Valid values include:
250-
// "Open" (default): The instance may make use of open Capacity Reservations that match its AZ and InstanceType
250+
// "Open": The instance may make use of open Capacity Reservations that match its AZ and InstanceType
251251
// "None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
252252
// "CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation
253+
// +kubebuilder:validation:Enum="";None;CapacityReservationsOnly;Open
253254
// +optional
254255
CapacityReservationPreference CapacityReservationPreference `json:"capacityReservationPreference,omitempty"`
255256
}

config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,16 +645,22 @@ spec:
645645
Reservation into which the instance should be launched.
646646
type: string
647647
capacityReservationPreference:
648+
allOf:
649+
- enum:
650+
- ""
651+
- None
652+
- CapacityReservationsOnly
653+
- Open
654+
- enum:
655+
- ""
656+
- None
657+
- CapacityReservationsOnly
658+
- Open
648659
description: |-
649660
CapacityReservationPreference specifies the preference for use of Capacity Reservations by the instance. Valid values include:
650-
"Open" (default): The instance may make use of open Capacity Reservations that match its AZ and InstanceType
661+
"Open": The instance may make use of open Capacity Reservations that match its AZ and InstanceType
651662
"None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
652663
"CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation
653-
enum:
654-
- ""
655-
- None
656-
- CapacityReservationsOnly
657-
- Open
658664
type: string
659665
iamInstanceProfile:
660666
description: |-

config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,16 +642,22 @@ spec:
642642
into which the instance should be launched.
643643
type: string
644644
capacityReservationPreference:
645+
allOf:
646+
- enum:
647+
- ""
648+
- None
649+
- CapacityReservationsOnly
650+
- Open
651+
- enum:
652+
- ""
653+
- None
654+
- CapacityReservationsOnly
655+
- Open
645656
description: |-
646657
CapacityReservationPreference specifies the preference for use of Capacity Reservations by the instance. Valid values include:
647-
"Open" (default): The instance may make use of open Capacity Reservations that match its AZ and InstanceType
658+
"Open": The instance may make use of open Capacity Reservations that match its AZ and InstanceType
648659
"None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
649660
"CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation
650-
enum:
651-
- ""
652-
- None
653-
- CapacityReservationsOnly
654-
- Open
655661
type: string
656662
cloudInit:
657663
description: |-

config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,16 +561,22 @@ spec:
561561
Reservation into which the instance should be launched.
562562
type: string
563563
capacityReservationPreference:
564+
allOf:
565+
- enum:
566+
- ""
567+
- None
568+
- CapacityReservationsOnly
569+
- Open
570+
- enum:
571+
- ""
572+
- None
573+
- CapacityReservationsOnly
574+
- Open
564575
description: |-
565576
CapacityReservationPreference specifies the preference for use of Capacity Reservations by the instance. Valid values include:
566-
"Open" (default): The instance may make use of open Capacity Reservations that match its AZ and InstanceType
577+
"Open": The instance may make use of open Capacity Reservations that match its AZ and InstanceType
567578
"None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
568579
"CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation
569-
enum:
570-
- ""
571-
- None
572-
- CapacityReservationsOnly
573-
- Open
574580
type: string
575581
cloudInit:
576582
description: |-

config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -654,16 +654,22 @@ spec:
654654
Reservation into which the instance should be launched.
655655
type: string
656656
capacityReservationPreference:
657+
allOf:
658+
- enum:
659+
- ""
660+
- None
661+
- CapacityReservationsOnly
662+
- Open
663+
- enum:
664+
- ""
665+
- None
666+
- CapacityReservationsOnly
667+
- Open
657668
description: |-
658669
CapacityReservationPreference specifies the preference for use of Capacity Reservations by the instance. Valid values include:
659-
"Open" (default): The instance may make use of open Capacity Reservations that match its AZ and InstanceType
670+
"Open": The instance may make use of open Capacity Reservations that match its AZ and InstanceType
660671
"None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
661672
"CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation
662-
enum:
663-
- ""
664-
- None
665-
- CapacityReservationsOnly
666-
- Open
667673
type: string
668674
iamInstanceProfile:
669675
description: |-

exp/api/v1beta2/types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,10 @@ type AWSLaunchTemplate struct {
148148
MarketType infrav1.MarketType `json:"marketType,omitempty"`
149149

150150
// CapacityReservationPreference specifies the preference for use of Capacity Reservations by the instance. Valid values include:
151-
// "Open" (default): The instance may make use of open Capacity Reservations that match its AZ and InstanceType
151+
// "Open": The instance may make use of open Capacity Reservations that match its AZ and InstanceType
152152
// "None": The instance may not make use of any Capacity Reservations. This is to conserve open reservations for desired workloads
153153
// "CapacityReservationsOnly": The instance will only run if matched or targeted to a Capacity Reservation
154+
// +kubebuilder:validation:Enum="";None;CapacityReservationsOnly;Open
154155
// +optional
155156
CapacityReservationPreference infrav1.CapacityReservationPreference `json:"capacityReservationPreference,omitempty"`
156157
}

0 commit comments

Comments
 (0)