You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// +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"
205
205
// +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 /"
207
206
Pathstring`json:"path"`
208
207
// Value defines the content to be applied on the target location.
209
208
// Value should be empty when operator is `remove`.
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() {
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
-
varstatusErr*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
-
202
138
It("Should deny creation of ClusterResourceOverride with invalid jsonPatchOverrides Paths (/apiVersion)", func() {
203
139
cro:= placementv1alpha1.ClusterResourceOverride{
204
140
ObjectMeta: metav1.ObjectMeta{
@@ -647,38 +583,5 @@ var _ = Describe("Test placement v1alpha1 API validation", func() {
647
583
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{})))
648
584
Expect(statusErr.Status().Message).Should(ContainSubstring("Path cannot contain empty or whitespace-only segments"))
649
585
})
650
-
651
-
It("Should deny creation of ResourceOverride with Path not starting with /", func() {
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 /"))
0 commit comments