fix(ssh): bind ssh.task_definition to sshCmd's own flag#42
Open
SAY-5 wants to merge 1 commit into
Open
Conversation
cmd/ssh.go bound ssh.task_definition to runCmd.PersistentFlags().Lookup("task_definition").
runCmd does not define task_definition (its BindPFlag line is
commented out in cmd/run.go), so the Lookup returned a nil
*pflag.Flag. viper.BindPFlag silently stored the nil binding, and
the first viper.Get("ssh.task_definition") in the command path
panicked inside pflagValue.HasChanged — crashing 'ecs-tool ssh'
with:
panic: runtime error: invalid memory address or nil pointer dereference
viper.pflagValue.HasChanged flags.go:41
viper.(*Viper).find viper.go:914
cmd.glob..func9 ssh.go:26
Bind to sshCmd's own PersistentFlags, which is where the flag is
actually registered two lines above.
Refs springload/ecs-tool issue 41.
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 #41.
Problem
cmd/ssh.gobindsssh.task_definitiontorunCmd'stask_definitionflag:But
runCmddoesn't definetask_definition, itsBindPFlagcall is commented out incmd/run.go:58.Lookupreturns a nil*pflag.Flag,viper.BindPFlagsilently stores the nil binding, and the firstviper.Get("ssh.task_definition")in the command path panics insidepflagValue.HasChanged:This crashes
ecs-tool sshon any invocation (v1.9.8 regression, v1.9.7 works).Fix
Bind to
sshCmd's ownPersistentFlags, which is where the flag is actually registered two lines above.Test
go build ./...andgo vet ./cmd/...clean. Package has no existing tests; the regression is that running thesshsubcommand no longer panics.