bug fix: Fixed namespace usage with cli command 'version' #1630
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: John Matthews jwmatthews@gmail.com
Noticed today that
velero version -n NAMESPACE
was not honoring the specified namespace.Issue is that while -n/--namespace will set the namespace, the instance of DefaultServerStatusGetter is using the initial namespace value before the flags have been parsed, so it's using the default version.
https://github.com/heptio/velero/blob/master/pkg/cmd/cli/version/version.go#L34
https://github.com/heptio/velero/blob/master/pkg/client/factory.go#L70
f.flags.StringVarP(&f.namespace, "namespace", "n", f.namespace, "The namespace in which Velero should operate")
https://github.com/heptio/velero/blob/master/pkg/client/factory.go#L106
The change I'm suggesting is to ensure the namespace value is set on the serverStatusGetter when the command is run, this way flags have been parsed.
Below is an example of running it with change, now it's going to the correct namespace.
I'm using a custom built velero image for the below, hence the version string itself is not set, but the mechanism is working as expected now.