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

Commit

Permalink
command: peers via ETCDCTL_PEERS env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ajf authored and Brandon Philips committed Jul 8, 2014
1 parent f65102a commit fb2731b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ The following exit codes can be returned from etcdctl:
5 500 error from etcd
```

## Peers

If your etcd cluster isn't available on `http://127.0.0.1:4001` you can specify
a `--peers` flag or `ETCDCTL_PEERS` environment variable.

```
ETCDCTL_PEERS="http://10.0.28.1:4002" etcdctl set my-key to-a-value
```

## Project Details

### Versioning
Expand Down
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 comma-delimited list of machine addresses in the cluster (default: \"127.0.0.1:4001\")"},
}
app.Commands = []cli.Command{
command.NewMakeCommand(),
Expand Down

0 comments on commit fb2731b

Please sign in to comment.