mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-04 02:17:42 +08:00
Merge pull request #761 from morlay/kubeconfig-enhance
util: support load Colon-separated KUBECONFIG
This commit is contained in:
commit
2b18a9b4a5
@ -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) {
|
func configFromContext(endpointName string, s ctxstore.Reader) (clientcmd.ClientConfig, error) {
|
||||||
if strings.HasPrefix(endpointName, "kubernetes://") {
|
if strings.HasPrefix(endpointName, "kubernetes://") {
|
||||||
u, _ := url.Parse(endpointName)
|
u, _ := url.Parse(endpointName)
|
||||||
|
|
||||||
if kubeconfig := u.Query().Get("kubeconfig"); kubeconfig != "" {
|
if kubeconfig := u.Query().Get("kubeconfig"); kubeconfig != "" {
|
||||||
clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
_ = os.Setenv(clientcmd.RecommendedConfigPathEnvVar, kubeconfig)
|
||||||
&clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfig},
|
|
||||||
&clientcmd.ConfigOverrides{},
|
|
||||||
)
|
|
||||||
return clientConfig, nil
|
|
||||||
}
|
}
|
||||||
|
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)
|
return kubernetes.ConfigFromContext(endpointName, s)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user