Skip to content

Commit

Permalink
Change certificateAutority function signature
Browse files Browse the repository at this point in the history
This function only care about the kubeconfig file path, not the whole
clusterConfig obj, It will allow us to reuse this function and also
add the test around it.
  • Loading branch information
praveenkumar committed Oct 7, 2020
1 parent c229545 commit 1a108ad
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/crc/machine/kubeconfig.go
Expand Up @@ -62,7 +62,7 @@ func WriteKubeconfig(ip string, clusterConfig *ClusterConfig) error {
// Make sure .kube/config exist if not then this will create
_, _ = os.OpenFile(kubeconfig, os.O_RDONLY|os.O_CREATE, 0600)

ca, err := certificateAuthority(clusterConfig)
ca, err := certificateAuthority(clusterConfig.KubeConfig)
if err != nil {
return err
}
Expand Down Expand Up @@ -94,8 +94,8 @@ func WriteKubeconfig(ip string, clusterConfig *ClusterConfig) error {
return clientcmd.WriteToFile(*cfg, kubeconfig)
}

func certificateAuthority(clusterConfig *ClusterConfig) ([]byte, error) {
bin, err := ioutil.ReadFile(clusterConfig.KubeConfig)
func certificateAuthority(kubeconfigFile string) ([]byte, error) {
bin, err := ioutil.ReadFile(kubeconfigFile)
if err != nil {
return nil, err
}
Expand All @@ -105,7 +105,7 @@ func certificateAuthority(clusterConfig *ClusterConfig) ([]byte, error) {
}
cluster, ok := builtin.Clusters["crc"]
if !ok {
return nil, fmt.Errorf("crc cluster not found in kubeconfig %s", clusterConfig.KubeConfig)
return nil, fmt.Errorf("crc cluster not found in kubeconfig %s", kubeconfigFile)
}
return cluster.CertificateAuthorityData, nil
}
Expand Down

0 comments on commit 1a108ad

Please sign in to comment.