forked from openshift/origin
/
node.go
56 lines (40 loc) · 1.92 KB
/
node.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package validation
import (
"fmt"
"strings"
kapp "github.com/GoogleCloudPlatform/kubernetes/cmd/kubelet/app"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors"
"github.com/openshift/origin/pkg/cmd/server/api"
)
func ValidateNodeConfig(config *api.NodeConfig) fielderrors.ValidationErrorList {
allErrs := fielderrors.ValidationErrorList{}
if len(config.NodeName) == 0 {
allErrs = append(allErrs, fielderrors.NewFieldRequired("nodeName"))
}
allErrs = append(allErrs, ValidateServingInfo(config.ServingInfo).Prefix("servingInfo")...)
allErrs = append(allErrs, ValidateKubeConfig(config.MasterKubeConfig, "masterKubeConfig")...)
if len(config.DNSIP) > 0 {
allErrs = append(allErrs, ValidateSpecifiedIP(config.DNSIP, "dnsIP")...)
}
allErrs = append(allErrs, ValidateImageConfig(config.ImageConfig).Prefix("imageConfig")...)
if config.PodManifestConfig != nil {
allErrs = append(allErrs, ValidatePodManifestConfig(config.PodManifestConfig).Prefix("podManifestConfig")...)
}
allErrs = append(allErrs, ValidateDockerConfig(config.DockerConfig).Prefix("dockerConfig")...)
allErrs = append(allErrs, ValidateKubeletExtendedArguments(config.KubeletArguments).Prefix("kubeletArguments")...)
return allErrs
}
func ValidateDockerConfig(config api.DockerConfig) fielderrors.ValidationErrorList {
allErrs := fielderrors.ValidationErrorList{}
switch config.ExecHandlerName {
case api.DockerExecHandlerNative, api.DockerExecHandlerNsenter:
// ok
default:
validValues := strings.Join([]string{string(api.DockerExecHandlerNative), string(api.DockerExecHandlerNsenter)}, ", ")
allErrs = append(allErrs, fielderrors.NewFieldInvalid("execHandlerName", config.ExecHandlerName, fmt.Sprintf("must be one of %s", validValues)))
}
return allErrs
}
func ValidateKubeletExtendedArguments(config api.ExtendedArguments) fielderrors.ValidationErrorList {
return ValidateExtendedArguments(config, kapp.NewKubeletServer().AddFlags)
}