Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
squash
Browse files Browse the repository at this point in the history
  • Loading branch information
bcwaldon committed Apr 29, 2015
1 parent c6131a4 commit de175ea
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions fleetctl/fleetctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,22 +262,16 @@ func main() {
os.Exit(2)
}

visited := make(map[string]struct{}, 0)
globalFlagset.Visit(func(f *flag.Flag) { visited[f.Name] = struct{}{} })
visited := make(map[string]bool, 0)
globalFlagset.Visit(func(f *flag.Flag) { visited[f.Name] = true })

// if --driver is not set, but --endpoint looks like an etcd
// server, set the driver to etcd
if _, ok := visited["driver"]; !ok {
if _, ok = visited["endpoint"]; ok {
if eps := strings.Split(globalFlags.Endpoint, ","); len(eps) >= 1 {
if u, err := url.Parse(eps[0]); err == nil {
if _, port, err := net.SplitHostPort(u.Host); err == nil {
if port == "4001" || port == "2379" {
log.Debugf("Defaulting to --driver=%s as --endpoint appears to be etcd", clientDriverEtcd)
globalFlags.ClientDriver = clientDriverEtcd
}
}
}
if visited["endpoint"] && !visited["driver"] {
if u, err := url.Parse(strings.Split(globalFlags.Endpoint, ",")[0]); err == nil {
if _, port, err := net.SplitHostPort(u.Host); err == nil && (port == "4001" || port == "2379") {
log.Debugf("Defaulting to --driver=%s as --endpoint appears to be etcd", clientDriverEtcd)
globalFlags.ClientDriver = clientDriverEtcd
}
}
}
Expand Down

0 comments on commit de175ea

Please sign in to comment.