Skip to content

Commit b706598

Browse files
authored
feat: align v1 override types with v1beta1 schema parity (#509)
Signed-off-by: Yetkin Timocin <ytimocin@microsoft.com>
1 parent 9543d7e commit b706598

9 files changed

Lines changed: 23 additions & 20 deletions

apis/placement/v1/clusterresourceplacement_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ import (
2929
const (
3030
// PlacementCleanupFinalizer is a finalizer added by the placement controller to all placement objects, to make sure
3131
// that the placement controller can react to placement object deletions if necessary.
32-
PlacementCleanupFinalizer = fleetPrefix + "crp-cleanup"
32+
PlacementCleanupFinalizer = FleetPrefix + "crp-cleanup"
3333

3434
// SchedulerCleanupFinalizer is a finalizer added by the scheduler to placement objects, to make sure
3535
// that all bindings derived from a placement object can be cleaned up after the placement object is deleted.
36-
SchedulerCleanupFinalizer = fleetPrefix + "scheduler-cleanup"
36+
SchedulerCleanupFinalizer = FleetPrefix + "scheduler-cleanup"
3737
)
3838

3939
// make sure the PlacementObj and PlacementObjList interfaces are implemented by the
@@ -1513,7 +1513,7 @@ func (crpl *ClusterResourcePlacementList) GetPlacementObjs() []PlacementObj {
15131513
const (
15141514
// ResourcePlacementCleanupFinalizer is a finalizer added by the RP controller to all RPs, to make sure
15151515
// that the RP controller can react to RP deletions if necessary.
1516-
ResourcePlacementCleanupFinalizer = fleetPrefix + "rp-cleanup"
1516+
ResourcePlacementCleanupFinalizer = FleetPrefix + "rp-cleanup"
15171517
)
15181518

15191519
// +genclient

apis/placement/v1/commons.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@ limitations under the License.
1717
package v1
1818

1919
const (
20-
// fleetPrefix is the prefix used for official fleet labels/annotations.
20+
// FleetPrefix is the prefix used for official fleet labels/annotations.
2121
// Unprefixed labels/annotations are reserved for end-users
2222
// See https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#label-selector-and-annotation-conventions
23-
fleetPrefix = "kubernetes-fleet.io/"
23+
FleetPrefix = "kubernetes-fleet.io/"
2424
)
2525

2626
// NamespacedName comprises a resource name, with a mandatory namespace.
2727
type NamespacedName struct {
2828
// Name is the name of the namespaced scope resource.
29-
// +required
29+
// +kubebuilder:validation:Required
3030
Name string `json:"name"`
31+
3132
// Namespace is namespace of the namespaced scope resource.
32-
// +required
33+
// +kubebuilder:validation:Required
3334
Namespace string `json:"namespace"`
3435
}

apis/placement/v1/override_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
// +genclient:nonNamespaced
2626
// +kubebuilder:object:root=true
2727
// +kubebuilder:resource:scope="Cluster",categories={fleet,fleet-placement}
28+
// +kubebuilder:validation:XValidation:rule="!has(self.spec.placement) || self.spec.placement.scope != 'Namespaced'",message="clusterResourceOverride placement reference cannot be Namespaced scope"
2829
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
2930

3031
// ClusterResourceOverride defines a group of override policies about how to override the selected cluster scope resources
@@ -48,7 +49,6 @@ type ClusterResourceOverrideSpec struct {
4849
// If set, the override will trigger the placement rollout immediately when the rollout strategy type is RollingUpdate.
4950
// Otherwise, it will be applied to the next rollout.
5051
// The recommended way is to set the placement so that the override can be rolled out immediately.
51-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="The placement field is immutable"
5252
// +optional
5353
Placement *PlacementRef `json:"placement,omitempty"`
5454

@@ -84,8 +84,8 @@ const (
8484
type PlacementRef struct {
8585
// Name is the reference to the name of placement.
8686
// +required
87-
8887
Name string `json:"name"`
88+
8989
// Scope defines the scope of the placement.
9090
// A clusterResourceOverride can only reference a clusterResourcePlacement (cluster-scoped),
9191
// and a resourceOverride can reference either a clusterResourcePlacement or resourcePlacement (namespaced).

apis/placement/v1/overridesnapshot_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2020

2121
const (
2222

23-
// OverrideIndexLabel is the label that indicate the policy snapshot index of a cluster policy.
24-
OverrideIndexLabel = fleetPrefix + "override-index"
23+
// OverrideIndexLabel is the label that indicates the override snapshot index of an override.
24+
OverrideIndexLabel = FleetPrefix + "override-index"
2525

2626
// OverrideSnapshotNameFmt is clusterResourceOverrideSnapshot name format: {CROName}-{OverrideSnapshotIndex}.
2727
OverrideSnapshotNameFmt = "%s-%d"
2828

2929
// OverrideTrackingLabel is the label that points to the cluster resource override that creates a resource snapshot.
30-
OverrideTrackingLabel = fleetPrefix + "parent-resource-override"
30+
OverrideTrackingLabel = FleetPrefix + "parent-resource-override"
3131

3232
// OverrideFinalizer is a finalizer added by the override controllers to all override, to make sure
3333
// that the override controller can react to override deletions if necessary.
34-
OverrideFinalizer = fleetPrefix + "override-cleanup"
34+
OverrideFinalizer = FleetPrefix + "override-cleanup"
3535
)
3636

3737
// +genclient

apis/placement/v1beta1/overridesnapshot_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2020

2121
const (
2222

23-
// OverrideIndexLabel is the label that indicate the policy snapshot index of a cluster policy.
23+
// OverrideIndexLabel is the label that indicates the override snapshot index of an override.
2424
OverrideIndexLabel = FleetPrefix + "override-index"
2525

2626
// OverrideSnapshotNameFmt is clusterResourceOverrideSnapshot name format: {CROName}-{OverrideSnapshotIndex}.

config/crd/bases/placement.kubernetes-fleet.io_clusterresourceoverrides.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ spec:
153153
The recommended way is to set the placement so that the override can be rolled out immediately.
154154
properties:
155155
name:
156+
description: Name is the reference to the name of placement.
156157
type: string
157158
scope:
158159
default: Cluster
@@ -168,9 +169,6 @@ spec:
168169
required:
169170
- name
170171
type: object
171-
x-kubernetes-validations:
172-
- message: The placement field is immutable
173-
rule: self == oldSelf
174172
policy:
175173
description: Policy defines how to override the selected resources
176174
on the target clusters.
@@ -399,6 +397,10 @@ spec:
399397
required:
400398
- spec
401399
type: object
400+
x-kubernetes-validations:
401+
- message: clusterResourceOverride placement reference cannot be Namespaced
402+
scope
403+
rule: '!has(self.spec.placement) || self.spec.placement.scope != ''Namespaced'''
402404
served: true
403405
storage: false
404406
- name: v1alpha1

config/crd/bases/placement.kubernetes-fleet.io_clusterresourceoverridesnapshots.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ spec:
167167
The recommended way is to set the placement so that the override can be rolled out immediately.
168168
properties:
169169
name:
170+
description: Name is the reference to the name of placement.
170171
type: string
171172
scope:
172173
default: Cluster
@@ -182,9 +183,6 @@ spec:
182183
required:
183184
- name
184185
type: object
185-
x-kubernetes-validations:
186-
- message: The placement field is immutable
187-
rule: self == oldSelf
188186
policy:
189187
description: Policy defines how to override the selected resources
190188
on the target clusters.

config/crd/bases/placement.kubernetes-fleet.io_resourceoverrides.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ spec:
5252
The recommended way is to set the placement so that the override can be rolled out immediately.
5353
properties:
5454
name:
55+
description: Name is the reference to the name of placement.
5556
type: string
5657
scope:
5758
default: Cluster

config/crd/bases/placement.kubernetes-fleet.io_resourceoverridesnapshots.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ spec:
6666
The recommended way is to set the placement so that the override can be rolled out immediately.
6767
properties:
6868
name:
69+
description: Name is the reference to the name of placement.
6970
type: string
7071
scope:
7172
default: Cluster

0 commit comments

Comments
 (0)