Skip to content

Commit

Permalink
Merge pull request etcd-io#7390 from fanminshi/put_ctl_warning
Browse files Browse the repository at this point in the history
etcdctl: show warning if ETCDCTL_API is not set
  • Loading branch information
fanminshi authored Mar 2, 2017
2 parents db91277 + f76ca01 commit 5cdb557
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion etcdctl/ctlv2/ctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/urfave/cli"
)

func Start() {
func Start(apiv string) {
app := cli.NewApp()
app.Name = "etcdctl"
app.Version = version.Version
Expand All @@ -34,6 +34,14 @@ func Start() {
fmt.Fprintln(c.App.Writer, "API version: 2")
}
app.Usage = "A simple command line client for etcd."

if apiv == "" {
app.Usage += "\n\n" +
"WARNING:\n" +
" Environment variable ETCDCTL_API is not set; defaults to etcdctl v2.\n" +
" Set environment variable ETCDCTL_API=3 to use v3 API or ETCDCTL_API=2 to use v2 API."
}

app.Flags = []cli.Flag{
cli.BoolFlag{Name: "debug", Usage: "output cURL commands which can be used to reproduce the request"},
cli.BoolFlag{Name: "no-sync", Usage: "don't synchronize cluster information before sending request"},
Expand Down
2 changes: 1 addition & 1 deletion etcdctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func main() {
// unset apiEnv to avoid side-effect for future env and flag parsing.
os.Unsetenv(apiEnv)
if len(apiv) == 0 || apiv == "2" {
ctlv2.Start()
ctlv2.Start(apiv)
return
}

Expand Down

0 comments on commit 5cdb557

Please sign in to comment.