6
6
v1 "k8s.io/client-go/kubernetes/typed/core/v1"
7
7
"k8s.io/client-go/rest"
8
8
"k8s.io/client-go/tools/clientcmd"
9
- "k8s.io/client-go/tools/clientcmd/api "
9
+ "path/filepath "
10
10
)
11
11
12
12
type KubeClient struct {
@@ -27,20 +27,20 @@ func (client KubeClient) Secrets() v1.SecretInterface {
27
27
return client .ClientSet .CoreV1 ().Secrets (client .Namespace )
28
28
}
29
29
30
- func NewConfigLoader (kubeconfigPath , context string ) clientcmd.ClientConfig {
30
+ func NewConfigLoader (kubeconfig , context string ) clientcmd.ClientConfig {
31
31
var overrides * clientcmd.ConfigOverrides
32
32
if context != "" {
33
33
overrides = & clientcmd.ConfigOverrides {CurrentContext : context }
34
34
}
35
35
36
36
return clientcmd .NewNonInteractiveDeferredLoadingClientConfig (
37
- & clientcmd.ClientConfigLoadingRules {ExplicitPath : kubeconfigPath },
37
+ & clientcmd.ClientConfigLoadingRules {Precedence : filepath . SplitList ( kubeconfig ) },
38
38
overrides ,
39
39
)
40
40
}
41
41
42
- func NewClient (kubeconfigPath , context , namespace string ) (config KubeClient , err error ) {
43
- configLoader := NewConfigLoader (kubeconfigPath , context )
42
+ func NewClient (kubeconfig , context , namespace string ) (config KubeClient , err error ) {
43
+ configLoader := NewConfigLoader (kubeconfig , context )
44
44
45
45
config .ClientConfig , err = configLoader .ClientConfig ()
46
46
if err != nil {
@@ -82,10 +82,3 @@ func NewClientFromCmd(cmd *cobra.Command) (KubeClient, error) {
82
82
83
83
return NewClient (kubeconfig , context , namespace )
84
84
}
85
-
86
- func RawConfig (kubeconfigPath string ) (api.Config , error ) {
87
- configLoader := clientcmd .NewNonInteractiveDeferredLoadingClientConfig (
88
- & clientcmd.ClientConfigLoadingRules {ExplicitPath : kubeconfigPath }, nil ,
89
- )
90
- return configLoader .RawConfig ()
91
- }
0 commit comments