1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-10 19:49:01 +00:00

Update vendor

This commit is contained in:
Darren Shepherd
2020-02-12 14:19:36 -07:00
parent 732b9611fa
commit 8d0eea5619
2 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
package kubeconfig
import (
"io"
"io/ioutil"
"os"
"path/filepath"
"k8s.io/client-go/tools/clientcmd"
)
func GetNonInteractiveClientConfig(kubeConfig string) clientcmd.ClientConfig {
return GetClientConfig(kubeConfig, nil)
}
func GetInteractiveClientConfig(kubeConfig string) clientcmd.ClientConfig {
return GetClientConfig(kubeConfig, os.Stdin)
}
func GetClientConfig(kubeConfig string, reader io.Reader) clientcmd.ClientConfig {
loadingRules := GetLoadingRules(kubeConfig)
overrides := &clientcmd.ConfigOverrides{ClusterDefaults: clientcmd.ClusterDefaults}
return clientcmd.NewInteractiveDeferredLoadingClientConfig(loadingRules, overrides, reader)
}
func GetLoadingRules(kubeConfig string) *clientcmd.ClientConfigLoadingRules {
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
loadingRules.DefaultClientConfig = &clientcmd.DefaultClientConfig
if kubeConfig != "" {
loadingRules.ExplicitPath = kubeConfig
}
var otherFiles []string
homeDir, err := os.UserHomeDir()
if err == nil {
otherFiles = append(otherFiles, filepath.Join(homeDir, ".kube", "k3s.yaml"))
}
otherFiles = append(otherFiles, "/etc/rancher/k3s/k3s.yaml")
loadingRules.Precedence = append(loadingRules.Precedence, canRead(otherFiles)...)
return loadingRules
}
func canRead(files []string) (result []string) {
for _, f := range files {
_, err := ioutil.ReadFile(f)
if err == nil {
result = append(result, f)
}
}
return
}

1
vendor/modules.txt vendored
View File

@@ -66,6 +66,7 @@ github.com/prometheus/procfs
github.com/prometheus/procfs/internal/fs
github.com/prometheus/procfs/internal/util
# github.com/rancher/wrangler v0.4.1
github.com/rancher/wrangler/pkg/kubeconfig
github.com/rancher/wrangler/pkg/name
github.com/rancher/wrangler/pkg/ratelimit
# github.com/sirupsen/logrus v1.4.2