api: use strconv

This commit is contained in:
Ryan Uber
2015-09-11 17:20:33 -07:00
parent 2ba01d2dd9
commit ea24468e0e

View File

@@ -1,5 +1,9 @@
package api
import (
"strconv"
)
// Nodes is used to query node-related API endpoints
type Nodes struct {
client *Client
@@ -32,15 +36,7 @@ func (n *Nodes) Info(nodeID string, q *QueryOptions) (*Node, *QueryMeta, error)
// ToggleDrain is used to toggle drain mode on/off for a given node.
func (n *Nodes) ToggleDrain(nodeID string, drain bool, q *WriteOptions) (*WriteMeta, error) {
// Conver the bool to a string
var drainArg string
if drain {
drainArg = "true"
} else {
drainArg = "false"
}
// Send the query
drainArg := strconv.FormatBool(drain)
wm, err := n.client.write("/v1/node/"+nodeID+"/drain?enable="+drainArg, nil, nil, q)
if err != nil {
return nil, err