Skip to content

Commit

Permalink
fix(kube): improve kubeconfig path overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveRuble committed Nov 1, 2021
1 parent 0ebc371 commit 6dc2ffa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/bosun/bosun.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,15 @@ func (b *Bosun) UseStack(stack brns.StackBrn) error {
b.ws.CurrentCluster = b.env.Cluster().Name
b.ws.CurrentStack = b.env.Stack().Name


b.ws.CurrentKubeconfig = b.ws.ClusterKubeconfigPaths[b.ws.CurrentCluster]
if b.ws.CurrentKubeconfig == "" {
b.ws.CurrentKubeconfig = os.ExpandEnv("$HOME/.kube/config")
}

cluster := b.env.Cluster()
cluster.KubeconfigPath = b.ws.CurrentKubeconfig

err = b.ws.Save()
return err
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ func (e *Environment) Render(ctx environmentvariables.Dependencies) (string, err
vars["BOSUN_STACK_BRN"] = e.Stack().Brn.String()
}

vars["KUBECONFIG"] = ctx.WorkspaceContext().CurrentKubeconfig

s := command.RenderEnvironmentSettingScript(vars, aliases)

return s, nil
Expand Down
1 change: 1 addition & 0 deletions pkg/kube/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (c ClusterConfig) GetKubeconfigPath() string {
if c.KubeconfigPath == "" {
return os.ExpandEnv("$HOME/.kube/config")
}

return c.KubeconfigPath
}

Expand Down

0 comments on commit 6dc2ffa

Please sign in to comment.