Conversation
ax ssh --help was taken as a task name and ended in a NotFound error after resolving the server. The ssh arguments are now parsed up front, so -h/--help prints ssh usage and a missing task name fails fast, before any server lookup or port-forward. The global flag parser also kept consuming -a, -n, --server and --context after "--", so ax ssh t -- grep -n foo file silently set the namespace to foo. Parsing now stops at "--" and hands the rest to the command unchanged. Fixes google#373 Fixes google#410
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #373. Fixes #410.
What was wrong
ax ssh --helptreated--helpas the task name, resolved the server (possibly starting a port-forward), and then failed withtask "--help" not found.main()kept consuming-a,-n,--serverand--contextafter--. Soax ssh t -- grep -n foo filesilently set the namespace tofooand rangrep fileremotely, andax ssh t -- ls -a /tmpswitched the atespace to/tmp.Change
parseGlobalArgs, which stops at--and passes everything after it to the command unchanged. Behaviour before--is the same as before.parseSSHArgs.maincalls it before resolving the server, so-h/--helpprints ssh usage (exit 0) and a missing task name or unknown flag fails immediately (exit 1) without touching the cluster.--helpafter the task name still goes to the remote command (ax ssh t -- git --help).cmd/ax/main_test.go, the first tests for that package.Testing
Not covered here: #374 (
ax ssh <task>with no command exits immediately because stdin is never forwarded). That needs protocol changes ininternal/guestand deserves its own PR.