Skip to content

Commit

Permalink
util: support load Colon-separated KUBECONFIG
Browse files Browse the repository at this point in the history
Signed-off-by: Morlay <[email protected]>
  • Loading branch information
morlay committed Sep 8, 2021
1 parent 6cf9fa8 commit c838121
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions commands/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,15 @@ func driversForNodeGroup(ctx context.Context, dockerCli command.Cli, ng *store.N
func configFromContext(endpointName string, s ctxstore.Reader) (clientcmd.ClientConfig, error) {
if strings.HasPrefix(endpointName, "kubernetes://") {
u, _ := url.Parse(endpointName)

if kubeconfig := u.Query().Get("kubeconfig"); kubeconfig != "" {
clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
&clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfig},
&clientcmd.ConfigOverrides{},
)
return clientConfig, nil
_ = os.Setenv(clientcmd.RecommendedConfigPathEnvVar, kubeconfig)
}
rules := clientcmd.NewDefaultClientConfigLoadingRules()
apiConfig, err := rules.Load()
if err != nil {
return nil, err
}
return clientcmd.NewDefaultClientConfig(*apiConfig, &clientcmd.ConfigOverrides{}), nil
}
return kubernetes.ConfigFromContext(endpointName, s)
}
Expand Down

0 comments on commit c838121

Please sign in to comment.