Add k8s:optional on Device.Basic

This commit is contained in:
Lalit Chauhan
2025-11-19 19:51:32 +00:00
parent 54900791c4
commit 79b414dc8f
3 changed files with 10 additions and 0 deletions

View File

@@ -351,6 +351,14 @@ func Validate_Device(ctx context.Context, op operation.Operation, fldPath *field
if oldValueCorrelated && op.Type == operation.Update && equality.Semantic.DeepEqual(obj, oldObj) {
return nil
}
// call field-attached validations
earlyReturn := false
if e := validate.OptionalPointer(ctx, op, fldPath, obj, oldObj); len(e) != 0 {
earlyReturn = true
}
if earlyReturn {
return // do not proceed
}
// call the type's validation function
errs = append(errs, Validate_BasicDevice(ctx, op, fldPath, obj, oldObj)...)
return

View File

@@ -474,6 +474,7 @@ message Device {
//
// +optional
// +oneOf=deviceType
// +k8s:optional
optional BasicDevice basic = 2;
}

View File

@@ -304,6 +304,7 @@ type Device struct {
//
// +optional
// +oneOf=deviceType
// +k8s:optional
Basic *BasicDevice `json:"basic,omitempty" protobuf:"bytes,2,opt,name=basic"`
}