Skip to content

Commit

Permalink
Adds API method.
Browse files Browse the repository at this point in the history
  • Loading branch information
slackpad committed Aug 2, 2017
1 parent b7bc1c0 commit db97f3e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions api/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ func (c *Client) ACL() *ACL {
return &ACL{c}
}

// Bootstrap is used to perform a one-time ACL bootstrap operation on a cluster
// to get the first management token.
func (a *ACL) Bootstrap() (string, *WriteMeta, error) {
r := a.c.newRequest("PUT", "/v1/acl/bootstrap")
rtt, resp, err := requireOK(a.c.doRequest(r))
if err != nil {
return "", nil, err
}
defer resp.Body.Close()

wm := &WriteMeta{RequestTime: rtt}
var out struct{ ID string }
if err := decodeBody(resp, &out); err != nil {
return "", nil, err
}
return out.ID, wm, nil
}

// Create is used to generate a new token with the given parameters
func (a *ACL) Create(acl *ACLEntry, q *WriteOptions) (string, *WriteMeta, error) {
r := a.c.newRequest("PUT", "/v1/acl/create")
Expand Down
7 changes: 7 additions & 0 deletions api/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import (
"testing"
)

func TestAPI_ACLBootstrap(t *testing.T) {
// TODO (slackpad) We currently can't inject the version, and the
// version in the binary depends on Git tags, so we can't reliably
// test this until we are just running an agent in-process here and
// have full control over the config.
}

func TestAPI_ACLCreateDestroy(t *testing.T) {
t.Parallel()
c, s := makeACLClient(t)
Expand Down

0 comments on commit db97f3e

Please sign in to comment.