File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,15 @@ var ShowKubeConfigPath = sync.OnceValue(func() string {
2828// ShowKubeConfig 获取kube的配置
2929var ShowKubeConfig = sync .OnceValue (func () * restclient.Config {
3030
31- // 加载 kubeconfig 文件
32- config , err := clientcmd .BuildConfigFromFlags ("" , ShowKubeConfigPath ())
31+ configOverrides := & clientcmd.ConfigOverrides {
32+ CurrentContext : ShowContext (),
33+ }
34+ config , err := clientcmd .NewNonInteractiveDeferredLoadingClientConfig (
35+ & clientcmd.ClientConfigLoadingRules {ExplicitPath : ShowKubeConfigPath ()},
36+ configOverrides ,
37+ ).ClientConfig ()
3338 if err != nil {
34- logrus .Fatalf ("Error loading kubeconfig: %v" , err )
39+ logrus .Fatalf ("Error loading kubeconfig: %v\n " , err )
3540 }
3641
3742 return config
@@ -57,7 +62,7 @@ func ShowNamespace() string {
5762 }
5863
5964 config := ShowApiConfig ()
60- currentContext := config . CurrentContext
65+ currentContext := ShowContext ()
6166 contextDetails := config .Contexts [currentContext ]
6267 if contextDetails == nil {
6368 logrus .Fatal ("\" current context not found in kubeconfig" )
You can’t perform that action at this time.
0 commit comments