Skip to content

Commit 45322d7

Browse files
committed
Make the --cluster-ip flag optional and check Kingpin parse errors
- This flag shouldn't be used when SIDECAR_SEEDS is set, so making it mandatory will break this functionality.
1 parent ed842f9 commit 45322d7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ $ go run *.go --cluster-ip <boostrap_host>
145145
```
146146

147147
You always need to supply at least one IP address or hostname with the
148-
`--cluster-ip` argument. If are running solo, or are the first member, this can
149-
be your own hostname. You may specify the argument multiple times to have
148+
`--cluster-ip` argument (or via the `SIDECAR_SEEDS` environment variable).
149+
If are running solo, or are the first member, this can be your own
150+
hostname. You may specify the argument multiple times to have
150151
multiple hosts. It is recommended to use more than one when possible.
151152

152153
Note: `--cluster-ip` will overwrite the values passed into the `SIDECAR_SEEDS` environment variable.

cli.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ func parseCommandLine() *CliOpts {
2828
app := kingpin.New("sidecar", "")
2929

3030
opts.AdvertiseIP = app.Flag("advertise-ip", "The address to advertise to the cluster").Short('a').String()
31-
opts.ClusterIPs = app.Flag("cluster-ip", "The cluster seed addresses").Required().Short('c').NoEnvar().Strings()
31+
opts.ClusterIPs = app.Flag("cluster-ip", "The cluster seed addresses").Short('c').NoEnvar().Strings()
3232
opts.ClusterName = app.Flag("cluster-name", "The cluster we're part of").Short('n').String()
3333
opts.CpuProfile = app.Flag("cpuprofile", "Enable CPU profiling").Short('p').Bool()
3434
opts.Discover = app.Flag("discover", "Method of discovery").Short('d').NoEnvar().Strings()
3535
opts.LoggingLevel = app.Flag("logging-level", "Set the logging level").Short('l').String()
3636

37-
app.Parse(os.Args[1:])
37+
_, err := app.Parse(os.Args[1:])
38+
exitWithError(err, "Failed to parse CLI opts")
3839

3940
return &opts
4041
}

0 commit comments

Comments
 (0)