Fix completion with direct connections#378
Conversation
| SSH: config.SSHDestination(dest), | ||
| } | ||
| } | ||
| if initErr != nil { |
There was a problem hiding this comment.
might be nice to add a comment that initErr may be set in initCLI and we check for that here, is a bit non-obvious
There was a problem hiding this comment.
addded a comment explaining this. initCLi can run from Cobras initializer before PersistentPreRunE
| return opts | ||
| } | ||
|
|
||
| func setCLIContext(cmd *cobra.Command, uncli *cli.CLI) { |
There was a problem hiding this comment.
why is this changed from
cmd.SetContext(context.WithValue(cmd.Context(), "cli", uncli))
?
There was a problem hiding this comment.
completion callbacks can run on the leaf command context so setting it only on the root command is not enough. so added comment here too
| return nil | ||
| } | ||
|
|
||
| func globalOptsFromArgs(opts globalOptions, args []string) globalOptions { |
There was a problem hiding this comment.
this looks odd and fragile... you have to do your own parsing for something that is a package that is supposed to do this?
There was a problem hiding this comment.
yeah i shortened it now and it reads --connect with pflag for the completion path
while I have moved my config.yaml out of the way. Works for me. |
fixes #377
Summary
--connectworks without a config file.Testing
GOCACHE=/tmp/go-build GOMODCACHE=/tmp/go-mod go test ./cmd/uncloud ./internal/cli/completionGOCACHE=/tmp/go-build GOMODCACHE=/tmp/go-mod go build -o /tmp/uc ./cmd/uncloudHOME=/tmp/uc-nohome /tmp/uc __complete --connect tcp://bad inspect ''Full
go test -p 1 ./...passed for non-e2e packages.test/e2efailed with existing Docker cluster runtime errors about invalid IPv6 addresses.