Skip to content

Commit

Permalink
fix: properly wire deploy.kubectl.defaultNamespace field to be set in…
Browse files Browse the repository at this point in the history
… SKAFFOLD_NAMESPACES (#8129)
  • Loading branch information
aaron-prindle authored Nov 28, 2022
1 parent 9938801 commit b2ba140
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/skaffold/runner/runcontext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ func (rc *RunContext) GetNamespace() string {
if rc.Opts.Namespace != "" {
return rc.Opts.Namespace
}
var defaultNamespace string
for _, p := range rc.GetPipelines() {
if p.Deploy.KubectlDeploy != nil && p.Deploy.KubectlDeploy.DefaultNamespace != nil {
if defaultNamespace != "" {
log.Entry(context.TODO()).Warn("multiple deploy.kubectl.defaultNamespace values set, only last pipeline's value will be used")
}
defaultNamespace = *p.Deploy.KubectlDeploy.DefaultNamespace
}
}
if defaultNamespace != "" {
return defaultNamespace
}
b, err := (&util.Commander{}).RunCmdOut(context.Background(), exec.Command("kubectl", "config", "view", "--minify", "-o", "jsonpath='{..namespace}'"))
if err != nil {
return rc.Opts.Namespace
Expand Down

0 comments on commit b2ba140

Please sign in to comment.