@@ -188,41 +188,43 @@ func (r *ObjectStorageSpec) Validate(basePath *field.Path) field.ErrorList {
188188func (r * CloudKitty ) ValidateCreate () (admission.Warnings , error ) {
189189 cloudKittyLog .Info ("validate create" , "name" , r .Name )
190190
191- allErrs := r .Spec .ValidateCreate (field .NewPath ("spec" ), r .Namespace )
191+ allWarns , allErrs := r .Spec .ValidateCreate (field .NewPath ("spec" ), r .Namespace )
192192
193193 if len (allErrs ) != 0 {
194- return nil , apierrors .NewInvalid (
194+ return allWarns , apierrors .NewInvalid (
195195 schema.GroupKind {Group : "cloudkitties.telemetry.openstack.org" , Kind : "CloudKitty" },
196196 r .Name , allErrs )
197197 }
198198
199- return nil , nil
199+ return allWarns , nil
200200}
201201
202202// ValidateCreate validates the CloudKittySpec during the webhook invocation.
203- func (r * CloudKittySpec ) ValidateCreate (basePath * field.Path , namespace string ) field.ErrorList {
203+ func (r * CloudKittySpec ) ValidateCreate (basePath * field.Path , namespace string ) ([] string , field.ErrorList ) {
204204 return r .CloudKittySpecBase .ValidateCreate (basePath , namespace )
205205}
206206
207207// ValidateCreate validates the CloudKittySpecCore during the webhook invocation. It is
208208// expected to be called by the validation webhook in the higher level telemetry webhook
209- func (r * CloudKittySpecCore ) ValidateCreate (basePath * field.Path , namespace string ) field.ErrorList {
209+ func (r * CloudKittySpecCore ) ValidateCreate (basePath * field.Path , namespace string ) ([] string , field.ErrorList ) {
210210 return r .CloudKittySpecBase .ValidateCreate (basePath , namespace )
211211}
212212
213213// ValidateCreate validates the CloudKittySpecBase during the webhook invocation.
214- func (r * CloudKittySpecBase ) ValidateCreate (basePath * field.Path , namespace string ) field.ErrorList {
214+ func (r * CloudKittySpecBase ) ValidateCreate (basePath * field.Path , namespace string ) ([] string , field.ErrorList ) {
215215 var allErrs field.ErrorList
216+ var allWarns []string
216217
217218 // Validate deprecated fields using shared helper
218- _ , errs := r .validateDeprecatedFieldsCreate (basePath )
219+ warns , errs := r .validateDeprecatedFieldsCreate (basePath )
220+ allWarns = append (allWarns , warns ... )
219221 allErrs = append (allErrs , errs ... )
220222
221223 allErrs = append (allErrs , r .S3StorageConfig .Validate (basePath .Child ("s3StorageConfig" ))... )
222224
223225 // TODO: Add other CK spec field validations as needed
224226
225- return allErrs
227+ return allWarns , allErrs
226228}
227229
228230// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
@@ -234,42 +236,44 @@ func (r *CloudKitty) ValidateUpdate(old runtime.Object) (admission.Warnings, err
234236 return nil , apierrors .NewInternalError (fmt .Errorf ("unable to convert existing object" ))
235237 }
236238
237- allErrs := r .Spec .ValidateUpdate (oldCloudKitty .Spec , field .NewPath ("spec" ), r .Namespace )
239+ allWarns , allErrs := r .Spec .ValidateUpdate (oldCloudKitty .Spec , field .NewPath ("spec" ), r .Namespace )
238240
239241 if len (allErrs ) != 0 {
240- return nil , apierrors .NewInvalid (
242+ return allWarns , apierrors .NewInvalid (
241243 schema.GroupKind {Group : "cloudkitties.telemetry.openstack.org" , Kind : "CloudKitty" },
242244 r .Name , allErrs )
243245 }
244246
245- return nil , nil
247+ return allWarns , nil
246248
247249}
248250
249- // ValidateCreate validates the CloudKittySpec during the webhook invocation.
250- func (r * CloudKittySpec ) ValidateUpdate (old CloudKittySpec , basePath * field.Path , namespace string ) field.ErrorList {
251+ // ValidateUpdate validates the CloudKittySpec during the webhook invocation.
252+ func (r * CloudKittySpec ) ValidateUpdate (old CloudKittySpec , basePath * field.Path , namespace string ) ([] string , field.ErrorList ) {
251253 return r .CloudKittySpecBase .ValidateUpdate (old .CloudKittySpecBase , basePath , namespace )
252254}
253255
254256// ValidateUpdate validates the CloudKittySpecCore during the webhook invocation. It is
255257// expected to be called by the validation webhook in the higher level telemetry webhook
256- func (r * CloudKittySpecCore ) ValidateUpdate (old CloudKittySpecCore , basePath * field.Path , namespace string ) field.ErrorList {
258+ func (r * CloudKittySpecCore ) ValidateUpdate (old CloudKittySpecCore , basePath * field.Path , namespace string ) ([] string , field.ErrorList ) {
257259 return r .CloudKittySpecBase .ValidateUpdate (old .CloudKittySpecBase , basePath , namespace )
258260}
259261
260262// ValidateUpdate validates the CloudKittySpecBase during the webhook invocation.
261- func (r * CloudKittySpecBase ) ValidateUpdate (old CloudKittySpecBase , basePath * field.Path , namespace string ) field.ErrorList {
263+ func (r * CloudKittySpecBase ) ValidateUpdate (old CloudKittySpecBase , basePath * field.Path , namespace string ) ([] string , field.ErrorList ) {
262264 var allErrs field.ErrorList
265+ var allWarns []string
263266
264267 // Validate deprecated fields using shared helper
265- _ , errs := r .validateDeprecatedFieldsUpdate (old , basePath )
268+ warns , errs := r .validateDeprecatedFieldsUpdate (old , basePath )
269+ allWarns = append (allWarns , warns ... )
266270 allErrs = append (allErrs , errs ... )
267271
268272 allErrs = append (allErrs , r .S3StorageConfig .Validate (basePath .Child ("s3StorageConfig" ))... )
269273
270274 // TODO: Add other CK spec field validations as needed
271275
272- return allErrs
276+ return allWarns , allErrs
273277}
274278
275279// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
0 commit comments