mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
refactor: simplify boolean expressions in CRD handler
Signed-off-by: xigang <wangxigang2014@gmail.com>
This commit is contained in:
parent
71f32f9930
commit
deb234c9d5
@ -660,13 +660,13 @@ func (r *crdHandler) getOrCreateServingInfoFor(uid types.UID, name string) (*crd
|
|||||||
return nil, fmt.Errorf("failed converting CRD validation to internal version: %v", err)
|
return nil, fmt.Errorf("failed converting CRD validation to internal version: %v", err)
|
||||||
}
|
}
|
||||||
s, err := structuralschema.NewStructural(internalValidation.OpenAPIV3Schema)
|
s, err := structuralschema.NewStructural(internalValidation.OpenAPIV3Schema)
|
||||||
if crd.Spec.PreserveUnknownFields == false && err != nil {
|
if !crd.Spec.PreserveUnknownFields && err != nil {
|
||||||
// This should never happen. If it does, it is a programming error.
|
// This should never happen. If it does, it is a programming error.
|
||||||
utilruntime.HandleError(fmt.Errorf("failed to convert schema to structural: %v", err))
|
utilruntime.HandleError(fmt.Errorf("failed to convert schema to structural: %v", err))
|
||||||
return nil, fmt.Errorf("the server could not properly serve the CR schema") // validation should avoid this
|
return nil, fmt.Errorf("the server could not properly serve the CR schema") // validation should avoid this
|
||||||
}
|
}
|
||||||
|
|
||||||
if crd.Spec.PreserveUnknownFields == false {
|
if !crd.Spec.PreserveUnknownFields {
|
||||||
// we don't own s completely, e.g. defaults are not deep-copied. So better make a copy here.
|
// we don't own s completely, e.g. defaults are not deep-copied. So better make a copy here.
|
||||||
s = s.DeepCopy()
|
s = s.DeepCopy()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user