Skip to content

Commit

Permalink
replace the flags usage with the cli package.
Browse files Browse the repository at this point in the history
  • Loading branch information
gesellix committed Mar 18, 2018
1 parent f91d4fc commit 0a11919
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions couchdb-cluster-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import (
"os"
"github.com/gesellix/couchdb-cluster-config/pkg"
"github.com/urfave/cli"
"flag"
)

var (
insecure = flag.Bool("insecure", true, "Ignore server certificate if using https")
)

func main() {
Expand All @@ -21,6 +16,10 @@ func main() {
Name: "nodes",
Usage: "list of node ip addresses to participate in the CouchDB cluster",
},
cli.BoolTFlag{
Name: "insecure",
Usage: "Ignore server certificate if using https",
},
}

app.Action = func(c *cli.Context) error {
Expand All @@ -30,7 +29,7 @@ func main() {
}

fmt.Printf("Going to setup the following nodes as cluster\n%v\n", nodes)
return cluster_config.SetupClusterNodes(nodes, insecure)
return cluster_config.SetupClusterNodes(nodes, c.Bool("insecure"))
}

err := app.Run(os.Args)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster-setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
adminPassword = "a-secret"
)

func SetupClusterNodes(ipAddresses []string, insecure *bool) error {
func SetupClusterNodes(ipAddresses []string, insecure bool) error {
hosts := make([]string, len(ipAddresses))
for i, ip := range ipAddresses {
hosts[i] = fmt.Sprintf("%s:5984", ip)
Expand Down
4 changes: 2 additions & 2 deletions pkg/couchdb-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ func (c *CouchdbClient) Request(method string, uri string, body io.Reader) (resp
return respData, nil
}

func NewCouchdbClient(uri string, basicAuth BasicAuth, databases []string, insecure *bool) *CouchdbClient {
func NewCouchdbClient(uri string, basicAuth BasicAuth, databases []string, insecure bool) *CouchdbClient {
httpClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: *insecure},
TLSClientConfig: &tls.Config{InsecureSkipVerify: insecure},
},
}

Expand Down

0 comments on commit 0a11919

Please sign in to comment.