Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

Peer configuration via ETCDCTL_PEERS env variable #95

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion command/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ func rawhandle(c *cli.Context, fn handlerFunc) (*etcd.Response, error) {
peers := c.GlobalStringSlice("peers")
// Append default peer address if not any
if len(peers) == 0 {
peers = append(peers, "127.0.0.1:4001")
peers_from_environment := os.Getenv("ETCDCTL_PEERS")

if peers_from_environment != "" {
peers = strings.Split(peers_from_environment, ",")
} else {
peers = append(peers, "127.0.0.1:4001")
}
}
// If no sync, create http path for each peer address
if !sync {
Expand Down
2 changes: 1 addition & 1 deletion etcdctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func main() {
cli.BoolFlag{"debug", "output cURL commands which can be used to reproduce the request"},
cli.BoolFlag{"no-sync", "don't synchronize cluster information before sending request"},
cli.StringFlag{"output, o", "simple", "output response in the given format (`simple` or `json`)"},
cli.StringSliceFlag{"peers, C", &cli.StringSlice{}, "a comma-delimited list of machine addresses in the cluster (default: {\"127.0.0.1:4001\"})"},
cli.StringSliceFlag{"peers, C", &cli.StringSlice{}, "a list of peers in the cluster, specify multiple times for multiple peers. (default: 127.0.0.1:4001 or ETCDCTL_PEERS environment variable)"},
}
app.Commands = []cli.Command{
command.NewMakeCommand(),
Expand Down