From ddbfa39bdaadfa5b6c784d495284288a4a9b0c2d Mon Sep 17 00:00:00 2001 From: Russell Centanni Date: Thu, 15 Feb 2024 10:12:43 -0500 Subject: [PATCH] fix: check / wake up kube context if defined when running commands Signed-off-by: Russell Centanni --- cmd/run.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index 91ef3db809..a8d8c10b50 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -7,6 +7,7 @@ import ( "os" "strings" + "github.com/loft-sh/devspace/pkg/devspace/kubectl" "github.com/loft-sh/devspace/pkg/devspace/pipeline/env" "mvdan.cc/sh/v3/expand" @@ -251,9 +252,11 @@ func (cmd *RunCmd) LoadCommandsConfig(f factory.Factory, configLoader loader.Con // verify client connectivity / authn / authz if client != nil { - _, err = client.KubeClient().Discovery().ServerVersion() + // If the current kube context or namespace is different than old, + // show warnings and reset kube client if necessary + client, err = kubectl.CheckKubeContext(client, localCache, false, false, false, log) if err != nil { - log.Debugf("Unable to discover server version: %v", err) + log.Debugf("Unable to verify kube context %v", err) client = nil } }