Skip to content

Commit

Permalink
Merge pull request #6175 from jandubois/wsl-kubeconfig
Browse files Browse the repository at this point in the history
Copy kubeconfig extra fields from Windows into WSL
  • Loading branch information
Nino-K authored Dec 12, 2023
2 parents e2b9d7d + 9cc795c commit 4a32089
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/go/wsl-helper/cmd/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ var kubeconfigCmd = &cobra.Command{
return err
}
defer finalKubeConfigFile.Close()
err = yaml.NewEncoder(finalKubeConfigFile).Encode(kubeConfig)
encoder := yaml.NewEncoder(finalKubeConfigFile)
err = encoder.Encode(kubeConfig)
if err != nil {
return err
}
return nil
return encoder.Close()
},
}

Expand Down Expand Up @@ -220,6 +221,13 @@ func mergeKubeConfigs(winConfig, linuxConfig kubeConfig) kubeConfig {
}
}

if linuxConfig.CurrentContext == "" {
linuxConfig.CurrentContext = rdCluster
}
if len(linuxConfig.Extras) == 0 {
linuxConfig.Extras = winConfig.Extras
}

return linuxConfig
}

Expand Down

0 comments on commit 4a32089

Please sign in to comment.