Skip to content

Commit

Permalink
etcdctl/ctlv3: exit with error on shadowed environment variable flags
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Aug 9, 2017
1 parent 4a9a3fd commit 34319bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion etcdctl/ctlv3/command/ep_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ func newEpHashKVCommand() *cobra.Command {

// epHealthCommandFunc executes the "endpoint-health" command.
func epHealthCommandFunc(cmd *cobra.Command, args []string) {
flags.SetPflagsFromEnv("ETCDCTL", cmd.InheritedFlags())
if err := flags.SetPflagsFromEnv("ETCDCTL", cmd.InheritedFlags(), flags.WithNoConflict()); err != nil {
ExitWithError(ExitBadArgs, err)
}

sec := secureCfgFromCmd(cmd)
dt := dialTimeoutFromCmd(cmd)
Expand Down
4 changes: 3 additions & 1 deletion etcdctl/ctlv3/command/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ func initDisplayFromCmd(cmd *cobra.Command) {
}

func mustClientFromCmd(cmd *cobra.Command) *clientv3.Client {
flags.SetPflagsFromEnv("ETCDCTL", cmd.InheritedFlags())
if err := flags.SetPflagsFromEnv("ETCDCTL", cmd.InheritedFlags(), flags.WithNoConflict()); err != nil {
ExitWithError(ExitBadArgs, err)
}

debug, derr := cmd.Flags().GetBool("debug")
if derr != nil {
Expand Down

0 comments on commit 34319bc

Please sign in to comment.