mirror of https://github.com/k3s-io/k3s
Merge pull request #77726 from sttts/sttts-structural-schema-sort-errors
apiextensions: always sort structural schema violations, not only in conditionk3s-v1.15.3
commit
8fecbd8eca
|
@ -18,6 +18,7 @@ package schema
|
|||
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
)
|
||||
|
@ -62,6 +63,12 @@ func ValidateStructural(s *Structural, fldPath *field.Path) field.ErrorList {
|
|||
allErrs = append(allErrs, validateStructuralInvariants(s, rootLevel, fldPath)...)
|
||||
allErrs = append(allErrs, validateStructuralCompleteness(s, fldPath)...)
|
||||
|
||||
// sort error messages. Otherwise, the errors slice will change every time due to
|
||||
// maps in the types and randomized iteration.
|
||||
sort.Slice(allErrs, func(i, j int) bool {
|
||||
return allErrs[i].Error() < allErrs[j].Error()
|
||||
})
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package nonstructuralschema
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
|
@ -115,12 +114,6 @@ func calculateCondition(in *apiextensions.CustomResourceDefinition) *apiextensio
|
|||
return nil
|
||||
}
|
||||
|
||||
// sort error messages. Otherwise, the condition message will change every sync due to
|
||||
// randomized map iteration.
|
||||
sort.Slice(allErrs, func(i, j int) bool {
|
||||
return allErrs[i].Error() < allErrs[j].Error()
|
||||
})
|
||||
|
||||
cond.Status = apiextensions.ConditionTrue
|
||||
cond.Reason = "Violations"
|
||||
cond.Message = allErrs.ToAggregate().Error()
|
||||
|
|
Loading…
Reference in New Issue