Fix rebase issues

This commit is contained in:
Lalit Chauhan 2025-10-02 19:00:38 +00:00
parent cf96486aed
commit 95c42b9951
14 changed files with 36 additions and 19 deletions

View file

@ -502,6 +502,9 @@ func Validate_DeviceClassSpec(ctx context.Context, op operation.Operation, fldPa
return nil
}
// call field-attached validations
if e := validate.OptionalPointer(ctx, op, fldPath, obj, oldObj); len(e) != 0 {
return // do not proceed
}
errs = append(errs, validate.ExtendedResourceName(ctx, op, fldPath, obj, oldObj)...)
return
}(fldPath.Child("extendedResourceName"), obj.ExtendedResourceName, safe.Field(oldObj, func(oldObj *resourcev1beta1.DeviceClassSpec) *string { return oldObj.ExtendedResourceName }))...)

View file

@ -542,7 +542,9 @@ func ValidateDeviceClass(class *resource.DeviceClass) field.ErrorList {
// ValidateDeviceClassUpdate tests if an update to DeviceClass is valid.
func ValidateDeviceClassUpdate(class, oldClass *resource.DeviceClass) field.ErrorList {
allErrs := corevalidation.ValidateObjectMetaUpdate(&class.ObjectMeta, &oldClass.ObjectMeta, field.NewPath("metadata"))
// TODO(lalitc375): Remove this if decided in https://github.com/kubernetes/kubernetes/issues/134444.
allErrs := corevalidation.ValidateObjectMeta(&class.ObjectMeta, false, corevalidation.ValidateClassName, field.NewPath("metadata"))
allErrs = append(allErrs, corevalidation.ValidateObjectMetaUpdate(&class.ObjectMeta, &oldClass.ObjectMeta, field.NewPath("metadata"))...)
allErrs = append(allErrs, validateDeviceClassSpec(&class.Spec, &oldClass.Spec, field.NewPath("spec"))...)
return allErrs
}

View file

@ -83,9 +83,7 @@ func (deviceClassStrategy) PrepareForUpdate(ctx context.Context, obj, old runtim
func (deviceClassStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
newClass := obj.(*resource.DeviceClass)
oldClass := old.(*resource.DeviceClass)
errorList := validation.ValidateDeviceClassUpdate(newClass, oldClass)
return rest.ValidateDeclarativelyWithMigrationChecks(ctx, legacyscheme.Scheme, newClass, oldClass, errorList, operation.Update)
}

View file

@ -680,8 +680,8 @@ message DeviceClassSpec {
//
// This is an alpha field.
// +optional
// +k8s:optional
// +featureGate=DRAExtendedResource
// +k8s:optional
// +k8s:format=k8s-extended-resource-name
optional string extendedResourceName = 4;
}

View file

@ -1750,8 +1750,8 @@ type DeviceClassSpec struct {
//
// This is an alpha field.
// +optional
// +k8s:optional
// +featureGate=DRAExtendedResource
// +k8s:optional
// +k8s:format=k8s-extended-resource-name
ExtendedResourceName *string `json:"extendedResourceName,omitempty" protobuf:"bytes,4,opt,name=extendedResourceName"`
}

View file

@ -689,6 +689,7 @@ message DeviceClassSpec {
// This is an alpha field.
// +optional
// +featureGate=DRAExtendedResource
// +k8s:optional
// +k8s:format=k8s-extended-resource-name
optional string extendedResourceName = 4;
}

View file

@ -1759,6 +1759,7 @@ type DeviceClassSpec struct {
// This is an alpha field.
// +optional
// +featureGate=DRAExtendedResource
// +k8s:optional
// +k8s:format=k8s-extended-resource-name
ExtendedResourceName *string `json:"extendedResourceName,omitempty" protobuf:"bytes,4,opt,name=extendedResourceName"`
}

View file

@ -680,8 +680,8 @@ message DeviceClassSpec {
//
// This is an alpha field.
// +optional
// +k8s:optional
// +featureGate=DRAExtendedResource
// +k8s:optional
// +k8s:format=k8s-extended-resource-name
optional string extendedResourceName = 4;
}

View file

@ -1750,8 +1750,8 @@ type DeviceClassSpec struct {
//
// This is an alpha field.
// +optional
// +k8s:optional
// +featureGate=DRAExtendedResource
// +k8s:optional
// +k8s:format=k8s-extended-resource-name
ExtendedResourceName *string `json:"extendedResourceName,omitempty" protobuf:"bytes,4,opt,name=extendedResourceName"`
}

View file

@ -28,10 +28,10 @@ var localSchemeBuilder = testscheme.New()
// +k8s:validation:Required
type MyType struct {
TypeMeta int
// +k8s:Optional
// +k8s:optional
// +k8s:format=k8s-extended-resource-name
NameField string `json:"nameField"`
// +k8s:Optional
// +k8s:optional
// +k8s:format=k8s-extended-resource-name
NamePtrField *string `json:"namePtrField"`
// Note: no validation here

View file

@ -61,6 +61,9 @@ func Validate_MyType(ctx context.Context, op operation.Operation, fldPath *field
return nil
}
// call field-attached validations
if e := validate.OptionalValue(ctx, op, fldPath, obj, oldObj); len(e) != 0 {
return // do not proceed
}
errs = append(errs, validate.ExtendedResourceName(ctx, op, fldPath, obj, oldObj)...)
return
}(fldPath.Child("nameField"), &obj.NameField, safe.Field(oldObj, func(oldObj *MyType) *string { return &oldObj.NameField }))...)
@ -73,6 +76,9 @@ func Validate_MyType(ctx context.Context, op operation.Operation, fldPath *field
return nil
}
// call field-attached validations
if e := validate.OptionalPointer(ctx, op, fldPath, obj, oldObj); len(e) != 0 {
return // do not proceed
}
errs = append(errs, validate.ExtendedResourceName(ctx, op, fldPath, obj, oldObj)...)
return
}(fldPath.Child("namePtrField"), obj.NamePtrField, safe.Field(oldObj, func(oldObj *MyType) *string { return oldObj.NamePtrField }))...)

View file

@ -28,10 +28,10 @@ var localSchemeBuilder = testscheme.New()
// +k8s:validation:Required
type MyType struct {
TypeMeta int
// +k8s:Optional
// +k8s:optional
// +k8s:format=k8s-uuid
UUIDField string `json:"uuidField"`
// +k8s:Optional
// +k8s:optional
// +k8s:format=k8s-uuid
UUIDPtrField *string `json:"uuidPtrField"`
// Note: no validation here

View file

@ -61,6 +61,9 @@ func Validate_MyType(ctx context.Context, op operation.Operation, fldPath *field
return nil
}
// call field-attached validations
if e := validate.OptionalValue(ctx, op, fldPath, obj, oldObj); len(e) != 0 {
return // do not proceed
}
errs = append(errs, validate.UUID(ctx, op, fldPath, obj, oldObj)...)
return
}(fldPath.Child("uuidField"), &obj.UUIDField, safe.Field(oldObj, func(oldObj *MyType) *string { return &oldObj.UUIDField }))...)
@ -73,6 +76,9 @@ func Validate_MyType(ctx context.Context, op operation.Operation, fldPath *field
return nil
}
// call field-attached validations
if e := validate.OptionalPointer(ctx, op, fldPath, obj, oldObj); len(e) != 0 {
return // do not proceed
}
errs = append(errs, validate.UUID(ctx, op, fldPath, obj, oldObj)...)
return
}(fldPath.Child("uuidPtrField"), obj.UUIDPtrField, safe.Field(oldObj, func(oldObj *MyType) *string { return oldObj.UUIDPtrField }))...)

View file

@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-20.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -53,13 +53,13 @@ var (
// to be sure it works the current state of IP manual-ratcheting
// ipSloppyValidator = types.Name{Package: libValidationPkg, Name: "IPSloppy"}
extendedResourceNameValidator = types.Name{Package: libValidationPkg, Name: "ExtendedResourceName"}
labelKeyValidator = types.Name{Package: libValidationPkg, Name: "LabelKey"}
labelValueValidator = types.Name{Package: libValidationPkg, Name: "LabelValue"}
longNameCaselessValidator = types.Name{Package: libValidationPkg, Name: "LongNameCaseless"}
longNameValidator = types.Name{Package: libValidationPkg, Name: "LongName"}
resourcePoolNameValidator = types.Name{Package: libValidationPkg, Name: "ResourcePoolName"}
shortNameValidator = types.Name{Package: libValidationPkg, Name: "ShortName"}
uuidValidator = types.Name{Package: libValidationPkg, Name: "UUID"}
labelKeyValidator = types.Name{Package: libValidationPkg, Name: "LabelKey"}
labelValueValidator = types.Name{Package: libValidationPkg, Name: "LabelValue"}
longNameCaselessValidator = types.Name{Package: libValidationPkg, Name: "LongNameCaseless"}
longNameValidator = types.Name{Package: libValidationPkg, Name: "LongName"}
resourcePoolNameValidator = types.Name{Package: libValidationPkg, Name: "ResourcePoolName"}
shortNameValidator = types.Name{Package: libValidationPkg, Name: "ShortName"}
uuidValidator = types.Name{Package: libValidationPkg, Name: "UUID"}
)
func (formatTagValidator) GetValidations(context Context, tag codetags.Tag) (Validations, error) {