coreos/locksmith — pull request #56 by mattbostock (2014-12-17 14:30:54+00:00)
Title: [#73607174] locksmithctl: Support for multiple endpoints

Support multiple etcd endpoints to be specified either using commandline
flags or an environment variable.

Maintains the `-endpoint` flag for backwards compatibility. For
commandline flags, specify `-endpoint=` for each endpoint or
pass a comma-delimited list of endpoints, e.g. `-endpoint=,.
The former syntax is preferable IMO as it makes more sense semantically
given that `-endpoint` is singular rather than plural.

Specifying multiple endpoints using an environment variable is supported
by passing a comma-delimited list, e.g.
`LOCKSMITHCTL_ENDPOINT=,`.

The default endpoint of `http://127.0.0.1:4001` is retained and prints
correctly when `globalFlagset.Usage()` is called. I used `VisitAll()` to
set the default value so that I could make this distinct to the actual
flag value, which `flag.FlagSet.Var()` doesn't support.

The pattern of using a custom flag type that satisfies the `flag.Value`
interface is borrowed from example 3 of the Go Flag tests:
https://golang.org/src/flag/example_test.go

Fixes #53

* * *

Also, rename `globalFlagset` to `globalFlagSet` for consistency with the
`flag.FlagSet` struct in the Go Flag package:
http://golang.org/pkg/flag/#FlagSet