mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-06 13:26:26 +00:00
Allow default kubeconfig resolution
- Changed the default kubeconfig loading to utilize the client-go's loader strategy. This allows users to use the Ark client without having to explicitly define a KUBECONFIG env var or argument. This more closely resemebles how Kubectl works and users are probably more used to while preserving the current rules. Signed-off-by: Justin Nauman <justin.r.nauman@gmail.com>
This commit is contained in:
@@ -24,8 +24,11 @@ import (
|
||||
// Config returns a *rest.Config, using either the kubeconfig (if specified) or an in-cluster
|
||||
// configuration.
|
||||
func Config(kubeconfig string) (*rest.Config, error) {
|
||||
if len(kubeconfig) > 0 {
|
||||
return clientcmd.BuildConfigFromFlags("", kubeconfig)
|
||||
loader := clientcmd.NewDefaultClientConfigLoadingRules()
|
||||
loader.ExplicitPath = kubeconfig
|
||||
clientConfig, err := clientcmd.BuildConfigFromKubeconfigGetter("", loader.Load)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rest.InClusterConfig()
|
||||
return clientConfig, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user