Skip to content

Commit 9fe5847

Browse files
committed
small fix
Signed-off-by: Britania Rodriguez Reyes <[email protected]>
1 parent 3a08b40 commit 9fe5847

8 files changed

+10
-106
lines changed

apis/placement/v1alpha1/override_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ type JSONPatchOverride struct {
203203
// +kubebuilder:validation:XValidation:rule="!(self == '/kind' || self == '/apiVersion')",message="Path cannot target typeMeta fields (kind, apiVersion)"
204204
// +kubebuilder:validation:XValidation:rule="!(self.startsWith('/metadata') && (!(self.startsWith('/metadata/annotations') || self.startsWith('/metadata/labels'))) || self == '/metadata')",message="Path can only target annotations and labels under metadata"
205205
// +kubebuilder:validation:XValidation:rule="!self.startsWith('/status')",message="Path cannot target status fields"
206-
// +kubebuilder:validation:XValidation:rule="self.startsWith('/')",message="Path must start with /"
207206
Path string `json:"path"`
208207
// Value defines the content to be applied on the target location.
209208
// Value should be empty when operator is `remove`.

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,6 @@ spec:
338338
self == ''/metadata'')'
339339
- message: Path cannot target status fields
340340
rule: '!self.startsWith(''/status'')'
341-
- message: Path must start with /
342-
rule: self.startsWith('/')
343341
value:
344342
description: |-
345343
Value defines the content to be applied on the target location.

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,6 @@ spec:
352352
|| self == ''/metadata'')'
353353
- message: Path cannot target status fields
354354
rule: '!self.startsWith(''/status'')'
355-
- message: Path must start with /
356-
rule: self.startsWith('/')
357355
value:
358356
description: |-
359357
Value defines the content to be applied on the target location.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ spec:
4040
Each snapshot MUST have the following labels:
4141
- `CRPTrackingLabel` which points to its owner CRP.
4242
- `ResourceIndexLabel` which is the index of the snapshot group.
43+
44+
The first snapshot of the index group MAY have the following labels:
4345
- `IsLatestSnapshotLabel` which indicates whether the snapshot is the latest one.
4446
4547
All the snapshots within the same index group must have the same ResourceIndexLabel.
@@ -50,6 +52,9 @@ spec:
5052
5153
Each snapshot (excluding the first snapshot) MUST have the following annotations:
5254
- `SubindexOfResourceSnapshotAnnotation` to store the subindex of resource snapshot in the group.
55+
56+
Snapshot may have the following annotations to indicate the time of next resourceSnapshot candidate detected by the controller:
57+
- `NextResourceSnapshotCandidateDetectionTimeAnnotation` to store the time of next resourceSnapshot candidate detected by the controller.
5358
properties:
5459
apiVersion:
5560
description: |-
@@ -186,6 +191,9 @@ spec:
186191
187192
Each snapshot (excluding the first snapshot) MUST have the following annotations:
188193
- `SubindexOfResourceSnapshotAnnotation` to store the subindex of resource snapshot in the group.
194+
195+
Snapshot may have the following annotations to indicate the time of next resourceSnapshot candidate detected by the controller:
196+
- `NextResourceSnapshotCandidateDetectionTimeAnnotation` to store the time of next resourceSnapshot candidate detected by the controller.
189197
properties:
190198
apiVersion:
191199
description: |-

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,6 @@ spec:
254254
self == ''/metadata'')'
255255
- message: Path cannot target status fields
256256
rule: '!self.startsWith(''/status'')'
257-
- message: Path must start with /
258-
rule: self.startsWith('/')
259257
value:
260258
description: |-
261259
Value defines the content to be applied on the target location.

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,6 @@ spec:
268268
|| self == ''/metadata'')'
269269
- message: Path cannot target status fields
270270
rule: '!self.startsWith(''/status'')'
271-
- message: Path must start with /
272-
rule: self.startsWith('/')
273271
value:
274272
description: |-
275273
Value defines the content to be applied on the target location.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ spec:
4040
Each snapshot MUST have the following labels:
4141
- `CRPTrackingLabel` which points to its owner resource placement.
4242
- `ResourceIndexLabel` which is the index of the snapshot group.
43+
44+
The first snapshot of the index group MAY have the following labels:
4345
- `IsLatestSnapshotLabel` which indicates whether the snapshot is the latest one.
4446
4547
All the snapshots within the same index group must have the same ResourceIndexLabel.

test/apis/placement/v1alpha1/api_validation_integration_test.go

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -135,70 +135,6 @@ var _ = Describe("Test placement v1alpha1 API validation", func() {
135135
Expect(statusErr.Status().Message).Should(MatchRegexp("jsonPatchOverrides must be set when the override type is JSONPatch."))
136136
})
137137

138-
It("Should deny creation of ClusterResourceOverride with Path not starting with /", func() {
139-
cro := placementv1alpha1.ClusterResourceOverride{
140-
ObjectMeta: metav1.ObjectMeta{
141-
Name: croName,
142-
},
143-
Spec: placementv1alpha1.ClusterResourceOverrideSpec{
144-
ClusterResourceSelectors: []placementv1beta1.ClusterResourceSelector{
145-
validClusterResourceSelector,
146-
},
147-
Policy: &placementv1alpha1.OverridePolicy{
148-
OverrideRules: []placementv1alpha1.OverrideRule{
149-
{
150-
OverrideType: placementv1alpha1.JSONPatchOverrideType,
151-
ClusterSelector: validClusterSelector,
152-
JSONPatchOverrides: []placementv1alpha1.JSONPatchOverride{
153-
{
154-
Operator: placementv1alpha1.JSONPatchOverrideOpAdd,
155-
Path: "metadata/labels//old-label",
156-
Value: apiextensionsv1.JSON{Raw: []byte(`"old-value"`)},
157-
},
158-
},
159-
},
160-
},
161-
},
162-
},
163-
}
164-
err := hubClient.Create(ctx, &cro)
165-
var statusErr *k8sErrors.StatusError
166-
Expect(errors.As(err, &statusErr)).To(BeTrue(), fmt.Sprintf("Create ClusterResourceOverride call produced error %s. Error type wanted is %s.", reflect.TypeOf(err), reflect.TypeOf(&k8sErrors.StatusError{})))
167-
Expect(statusErr.Status().Message).Should(MatchRegexp("Path must start with /"))
168-
})
169-
170-
It("Should deny creation of ClusterResourceOverride with empty segments in Path", func() {
171-
cro := placementv1alpha1.ClusterResourceOverride{
172-
ObjectMeta: metav1.ObjectMeta{
173-
Name: croName,
174-
},
175-
Spec: placementv1alpha1.ClusterResourceOverrideSpec{
176-
ClusterResourceSelectors: []placementv1beta1.ClusterResourceSelector{
177-
validClusterResourceSelector,
178-
},
179-
Policy: &placementv1alpha1.OverridePolicy{
180-
OverrideRules: []placementv1alpha1.OverrideRule{
181-
{
182-
OverrideType: placementv1alpha1.JSONPatchOverrideType,
183-
ClusterSelector: validClusterSelector,
184-
JSONPatchOverrides: []placementv1alpha1.JSONPatchOverride{
185-
{
186-
Operator: placementv1alpha1.JSONPatchOverrideOpAdd,
187-
Path: "/metadata/labels//old-label",
188-
Value: apiextensionsv1.JSON{Raw: []byte(`"old-value"`)}, // This should not be set for remove operator
189-
},
190-
},
191-
},
192-
},
193-
},
194-
},
195-
}
196-
err := hubClient.Create(ctx, &cro)
197-
var statusErr *k8sErrors.StatusError
198-
Expect(errors.As(err, &statusErr)).To(BeTrue(), fmt.Sprintf("Create ClusterResourceOverride call produced error %s. Error type wanted is %s.", reflect.TypeOf(err), reflect.TypeOf(&k8sErrors.StatusError{})))
199-
Expect(statusErr.Status().Message).Should(MatchRegexp("Value must be empty when operator is remove"))
200-
})
201-
202138
It("Should deny creation of ClusterResourceOverride with invalid jsonPatchOverrides Paths (/apiVersion)", func() {
203139
cro := placementv1alpha1.ClusterResourceOverride{
204140
ObjectMeta: metav1.ObjectMeta{
@@ -647,38 +583,5 @@ var _ = Describe("Test placement v1alpha1 API validation", func() {
647583
Expect(errors.As(err, &statusErr)).To(BeTrue(), fmt.Sprintf("Create Override call produced error %s. Error type wanted is %s.", reflect.TypeOf(err), reflect.TypeOf(&k8sErrors.StatusError{})))
648584
Expect(statusErr.Status().Message).Should(ContainSubstring("Path cannot contain empty or whitespace-only segments"))
649585
})
650-
651-
It("Should deny creation of ResourceOverride with Path not starting with /", func() {
652-
ro := placementv1alpha1.ResourceOverride{
653-
ObjectMeta: metav1.ObjectMeta{
654-
Name: roName,
655-
Namespace: "test-namespace",
656-
},
657-
Spec: placementv1alpha1.ResourceOverrideSpec{
658-
ResourceSelectors: []placementv1alpha1.ResourceSelector{
659-
validResourceSelector,
660-
},
661-
Policy: &placementv1alpha1.OverridePolicy{
662-
OverrideRules: []placementv1alpha1.OverrideRule{
663-
{
664-
OverrideType: placementv1alpha1.JSONPatchOverrideType,
665-
ClusterSelector: validClusterSelector,
666-
JSONPatchOverrides: []placementv1alpha1.JSONPatchOverride{
667-
{
668-
Operator: placementv1alpha1.JSONPatchOverrideOpAdd,
669-
Path: "metadata/labels//old-label",
670-
Value: apiextensionsv1.JSON{Raw: []byte(`"old-value"`)},
671-
},
672-
},
673-
},
674-
},
675-
},
676-
},
677-
}
678-
err := hubClient.Create(ctx, &ro)
679-
var statusErr *k8sErrors.StatusError
680-
Expect(errors.As(err, &statusErr)).To(BeTrue(), fmt.Sprintf("Create ResourceOverride call produced error %s. Error type wanted is %s.", reflect.TypeOf(err), reflect.TypeOf(&k8sErrors.StatusError{})))
681-
Expect(statusErr.Status().Message).Should(MatchRegexp("Path must start with /"))
682-
})
683586
})
684587
})

0 commit comments

Comments
 (0)