mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-10 03:29:18 +00:00
fix: kubecontext flag has no effect
Signed-off-by: Matthis Holleville <matthish29@gmail.com>
This commit is contained in:
18
cmd/root.go
18
cmd/root.go
@@ -61,15 +61,6 @@ func init() {
|
|||||||
// when this action is called directly.
|
// when this action is called directly.
|
||||||
// rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
// rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||||
|
|
||||||
//Initialise the kubeconfig
|
|
||||||
kubernetesClient, err := kubernetes.NewClient(kubecontext, kubeconfig)
|
|
||||||
if err != nil {
|
|
||||||
color.Red("Error initialising kubernetes client: %v", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
viper.Set("kubernetesClient", kubernetesClient)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// initConfig reads in config file and ENV variables if set.
|
// initConfig reads in config file and ENV variables if set.
|
||||||
@@ -90,6 +81,15 @@ func initConfig() {
|
|||||||
viper.SafeWriteConfig()
|
viper.SafeWriteConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Initialise the kubeconfig
|
||||||
|
kubernetesClient, err := kubernetes.NewClient(kubecontext, kubeconfig)
|
||||||
|
if err != nil {
|
||||||
|
color.Red("Error initialising kubernetes client: %v", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
viper.Set("kubernetesClient", kubernetesClient)
|
||||||
|
|
||||||
viper.AutomaticEnv() // read in environment variables that match
|
viper.AutomaticEnv() // read in environment variables that match
|
||||||
|
|
||||||
// If a config file is found, read it in.
|
// If a config file is found, read it in.
|
||||||
|
Reference in New Issue
Block a user