-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Collect namespaces of deployed resources. #2640
Collect namespaces of deployed resources. #2640
Conversation
} | ||
namespaces := make([]string, len(replacer.namespaces)) | ||
i := 0 | ||
for ns := range replacer.namespaces { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the idiomatic way to write this would be
for i, ns := range replacer.namespaces {
namespaces[i] = ns
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is map so its a key value pair.
I will use append
. I first thought it allocates a new memory every time and will be inefficient.
But turns out, it only allocates a new memory if the size is less than what was allocated.
namespaces := make([]string, 0, len(replacer.namespaces))
for ns := range replacer.namespaces {
namespaces = append(namespaces, ns)
}
adb6e5b
to
e03a889
Compare
e03a889
to
adcfede
Compare
d79853a
to
86e8416
Compare
Codecov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a couple small comments
pkg/skaffold/deploy/deploy.go
Outdated
return d.namespaces | ||
} | ||
|
||
func (d *Result) IsError() (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I feel like I typically see "OK bools" returned as the second argument--
for example, with maps:
val, ok := myMap[key]
In #2495, @corneliusweig noticed for a skaffold run without
--namespace
flag, we make a call for deployment health-check and port-forwardingand
ns
is""
.Similarly, during port-forwarding, we do the same
In
context.RunContext
, we already gather namespaces set in the kubecontext as well as on command line.This PR is collect all the namespaces from
kubectl manifests
andhelm releases
if they are set individually in the manifests.This PR is not enough for the bug fix for #2495. We need to followup with a PR where if runcontext.Namespaces is empty, we need to use "default" namespace.