mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #129434 from xigang/crd_handler
refactor: simplify boolean expressions in CRD handler
This commit is contained in:
commit
14dafc30c9
@ -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)
|
||||
}
|
||||
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.
|
||||
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
|
||||
}
|
||||
|
||||
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.
|
||||
s = s.DeepCopy()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user