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

Function validateClusterInfo

tools/clientcmd/validation.go:167–195  ·  view source on GitHub ↗

validateClusterInfo looks for conflicts and errors in the cluster info

(clusterName string, clusterInfo clientcmdapi.Cluster)

Source from the content-addressed store, hash-verified

165
166// validateClusterInfo looks for conflicts and errors in the cluster info
167func validateClusterInfo(clusterName string, clusterInfo clientcmdapi.Cluster) []error {
168 validationErrors := make([]error, 0)
169
170 emptyCluster := clientcmdapi.NewCluster()
171 if reflect.DeepEqual(*emptyCluster, clusterInfo) {
172 return []error{ErrEmptyCluster}
173 }
174
175 if len(clusterInfo.Server) == 0 {
176 if len(clusterName) == 0 {
177 validationErrors = append(validationErrors, fmt.Errorf("default cluster has no server defined"))
178 } else {
179 validationErrors = append(validationErrors, fmt.Errorf("no server found for cluster %q", clusterName))
180 }
181 }
182 // Make sure CA data and CA file aren't both specified
183 if len(clusterInfo.CertificateAuthority) != 0 && len(clusterInfo.CertificateAuthorityData) != 0 {
184 validationErrors = append(validationErrors, fmt.Errorf("certificate-authority-data and certificate-authority are both specified for %v. certificate-authority-data will override.", clusterName))
185 }
186 if len(clusterInfo.CertificateAuthority) != 0 {
187 clientCertCA, err := os.Open(clusterInfo.CertificateAuthority)
188 defer clientCertCA.Close()
189 if err != nil {
190 validationErrors = append(validationErrors, fmt.Errorf("unable to read certificate-authority %v for %v due to %v", clusterInfo.CertificateAuthority, clusterName, err))
191 }
192 }
193
194 return validationErrors
195}
196
197// validateAuthInfo looks for conflicts and errors in the auth info
198func validateAuthInfo(authInfoName string, authInfo clientcmdapi.AuthInfo) []error {

Callers 5

testClusterMethod · 0.85
ValidateFunction · 0.85
ConfirmUsableFunction · 0.85
ConfirmUsableMethod · 0.85

Calls 2

ErrorfMethod · 0.65
CloseMethod · 0.65

Tested by 2

testClusterMethod · 0.68