mirror of
https://github.com/rancher/norman.git
synced 2025-09-10 19:49:01 +00:00
Update vendor
This commit is contained in:
52
vendor/github.com/rancher/wrangler/pkg/kubeconfig/loader.go
generated
vendored
Normal file
52
vendor/github.com/rancher/wrangler/pkg/kubeconfig/loader.go
generated
vendored
Normal 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
1
vendor/modules.txt
vendored
@@ -66,6 +66,7 @@ github.com/prometheus/procfs
|
|||||||
github.com/prometheus/procfs/internal/fs
|
github.com/prometheus/procfs/internal/fs
|
||||||
github.com/prometheus/procfs/internal/util
|
github.com/prometheus/procfs/internal/util
|
||||||
# github.com/rancher/wrangler v0.4.1
|
# github.com/rancher/wrangler v0.4.1
|
||||||
|
github.com/rancher/wrangler/pkg/kubeconfig
|
||||||
github.com/rancher/wrangler/pkg/name
|
github.com/rancher/wrangler/pkg/name
|
||||||
github.com/rancher/wrangler/pkg/ratelimit
|
github.com/rancher/wrangler/pkg/ratelimit
|
||||||
# github.com/sirupsen/logrus v1.4.2
|
# github.com/sirupsen/logrus v1.4.2
|
||||||
|
Reference in New Issue
Block a user