Validate topology
This commit is contained in:
@@ -19,6 +19,7 @@ package validation
|
||||
import (
|
||||
apivalidation "k8s.io/apimachinery/pkg/api/validation"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
corevalidation "k8s.io/kubernetes/pkg/apis/core/validation"
|
||||
"k8s.io/kubernetes/pkg/apis/node"
|
||||
)
|
||||
|
||||
@@ -30,6 +31,10 @@ func ValidateRuntimeClass(rc *node.RuntimeClass) field.ErrorList {
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("handler"), rc.Handler, msg))
|
||||
}
|
||||
|
||||
if rc.Topology != nil {
|
||||
allErrs = append(allErrs, validateTopology(rc.Topology, field.NewPath("topology"))...)
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
@@ -41,3 +46,12 @@ func ValidateRuntimeClassUpdate(new, old *node.RuntimeClass) field.ErrorList {
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateTopology(t *node.Topology, fldPath *field.Path) field.ErrorList {
|
||||
var allErrs field.ErrorList
|
||||
if t.NodeSelector != nil {
|
||||
allErrs = append(allErrs, corevalidation.ValidateNodeSelector(t.NodeSelector, fldPath.Child("nodeSelector"))...)
|
||||
}
|
||||
allErrs = append(allErrs, corevalidation.ValidateTolerations(t.Tolerations, fldPath.Child("tolerations"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
Reference in New Issue
Block a user