validateClusterInfo looks for conflicts and errors in the cluster info
(clusterName string, clusterInfo clientcmdapi.Cluster)
| 165 | |
| 166 | // validateClusterInfo looks for conflicts and errors in the cluster info |
| 167 | func 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 |
| 198 | func validateAuthInfo(authInfoName string, authInfo clientcmdapi.AuthInfo) []error { |