MCPcopy
hub / github.com/kubernetes/client-go / Validate

Function Validate

tools/clientcmd/validation.go:104–130  ·  view source on GitHub ↗

Validate checks for errors in the Config. It does not return early so that it can find as many errors as possible.

(config clientcmdapi.Config)

Source from the content-addressed store, hash-verified

102
103// Validate checks for errors in the Config. It does not return early so that it can find as many errors as possible.
104func Validate(config clientcmdapi.Config) error {
105 validationErrors := make([]error, 0)
106
107 if clientcmdapi.IsConfigEmpty(&config) {
108 return newErrConfigurationInvalid([]error{ErrEmptyConfig})
109 }
110
111 if len(config.CurrentContext) != 0 {
112 if _, exists := config.Contexts[config.CurrentContext]; !exists {
113 validationErrors = append(validationErrors, &errContextNotFound{config.CurrentContext})
114 }
115 }
116
117 for contextName, context := range config.Contexts {
118 validationErrors = append(validationErrors, validateContext(contextName, *context, config)...)
119 }
120
121 for authInfoName, authInfo := range config.AuthInfos {
122 validationErrors = append(validationErrors, validateAuthInfo(authInfoName, *authInfo)...)
123 }
124
125 for clusterName, clusterInfo := range config.Clusters {
126 validationErrors = append(validationErrors, validateClusterInfo(clusterName, *clusterInfo)...)
127 }
128
129 return newErrConfigurationInvalid(validationErrors)
130}
131
132// ConfirmUsable looks a particular context and determines if that particular part of the config is useable. There might still be errors in the config,
133// but no errors in the sections requested or referenced. It does not return early so that it can find as many errors as possible.

Callers 3

TestIsContextNotFoundFunction · 0.85
TestIsEmptyConfigFunction · 0.85
testConfigMethod · 0.85

Calls 4

validateContextFunction · 0.85
validateAuthInfoFunction · 0.85
validateClusterInfoFunction · 0.85

Tested by 3

TestIsContextNotFoundFunction · 0.68
TestIsEmptyConfigFunction · 0.68
testConfigMethod · 0.68