Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly wire deploy.kubectl.defaultNamespace field to be set in SKAFFOLD_NAMESPACES #8129

Merged
merged 1 commit into from
Nov 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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