mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #79165 from neolit123/kubeadm-1.16-fix-panic-kubeconfig
kubeadm: improve the kubeconfig file validation phase
This commit is contained in:
commit
4683054ff6
@ -224,7 +224,13 @@ func validateKubeConfig(outDir, filename string, config *clientcmdapi.Config) er
|
|||||||
expectedCtx := config.CurrentContext
|
expectedCtx := config.CurrentContext
|
||||||
expectedCluster := config.Contexts[expectedCtx].Cluster
|
expectedCluster := config.Contexts[expectedCtx].Cluster
|
||||||
currentCtx := currentConfig.CurrentContext
|
currentCtx := currentConfig.CurrentContext
|
||||||
|
if currentConfig.Contexts[currentCtx] == nil {
|
||||||
|
return errors.Errorf("failed to find CurrentContext in Contexts of the kubeconfig file %s", kubeConfigFilePath)
|
||||||
|
}
|
||||||
currentCluster := currentConfig.Contexts[currentCtx].Cluster
|
currentCluster := currentConfig.Contexts[currentCtx].Cluster
|
||||||
|
if currentConfig.Clusters[currentCluster] == nil {
|
||||||
|
return errors.Errorf("failed to find the given CurrentContext Cluster in Clusters of the kubeconfig file %s", kubeConfigFilePath)
|
||||||
|
}
|
||||||
|
|
||||||
// If the current CA cert on disk doesn't match the expected CA cert, error out because we have a file, but it's stale
|
// If the current CA cert on disk doesn't match the expected CA cert, error out because we have a file, but it's stale
|
||||||
if !bytes.Equal(currentConfig.Clusters[currentCluster].CertificateAuthorityData, config.Clusters[expectedCluster].CertificateAuthorityData) {
|
if !bytes.Equal(currentConfig.Clusters[currentCluster].CertificateAuthorityData, config.Clusters[expectedCluster].CertificateAuthorityData) {
|
||||||
|
Loading…
Reference in New Issue
Block a user