Skip to content

Commit

Permalink
fix: check / wake up kube context if defined when running commands
Browse files Browse the repository at this point in the history
Signed-off-by: Russell Centanni <[email protected]>
  • Loading branch information
lizardruss committed Feb 15, 2024
1 parent e93bd85 commit ddbfa39
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit ddbfa39

Please sign in to comment.