mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
Replace http method strings with net/http constants (#14677)
This commit is contained in:
committed by
GitHub
parent
7f36a29e04
commit
0dd4cda7c9
@@ -2,6 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TokenAuth is used to perform token backend operations on Vault
|
// TokenAuth is used to perform token backend operations on Vault
|
||||||
@@ -22,7 +23,7 @@ func (c *TokenAuth) CreateWithContext(ctx context.Context, opts *TokenCreateRequ
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", "/v1/auth/token/create")
|
r := c.c.NewRequest(http.MethodPost, "/v1/auth/token/create")
|
||||||
if err := r.SetJSONBody(opts); err != nil {
|
if err := r.SetJSONBody(opts); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -44,7 +45,7 @@ func (c *TokenAuth) CreateOrphanWithContext(ctx context.Context, opts *TokenCrea
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", "/v1/auth/token/create-orphan")
|
r := c.c.NewRequest(http.MethodPost, "/v1/auth/token/create-orphan")
|
||||||
if err := r.SetJSONBody(opts); err != nil {
|
if err := r.SetJSONBody(opts); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -66,7 +67,7 @@ func (c *TokenAuth) CreateWithRoleWithContext(ctx context.Context, opts *TokenCr
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", "/v1/auth/token/create/"+roleName)
|
r := c.c.NewRequest(http.MethodPost, "/v1/auth/token/create/"+roleName)
|
||||||
if err := r.SetJSONBody(opts); err != nil {
|
if err := r.SetJSONBody(opts); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -88,7 +89,7 @@ func (c *TokenAuth) LookupWithContext(ctx context.Context, token string) (*Secre
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", "/v1/auth/token/lookup")
|
r := c.c.NewRequest(http.MethodPost, "/v1/auth/token/lookup")
|
||||||
if err := r.SetJSONBody(map[string]interface{}{
|
if err := r.SetJSONBody(map[string]interface{}{
|
||||||
"token": token,
|
"token": token,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@@ -112,7 +113,7 @@ func (c *TokenAuth) LookupAccessorWithContext(ctx context.Context, accessor stri
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", "/v1/auth/token/lookup-accessor")
|
r := c.c.NewRequest(http.MethodPost, "/v1/auth/token/lookup-accessor")
|
||||||
if err := r.SetJSONBody(map[string]interface{}{
|
if err := r.SetJSONBody(map[string]interface{}{
|
||||||
"accessor": accessor,
|
"accessor": accessor,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@@ -136,7 +137,7 @@ func (c *TokenAuth) LookupSelfWithContext(ctx context.Context) (*Secret, error)
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/auth/token/lookup-self")
|
r := c.c.NewRequest(http.MethodGet, "/v1/auth/token/lookup-self")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -155,7 +156,7 @@ func (c *TokenAuth) RenewAccessorWithContext(ctx context.Context, accessor strin
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", "/v1/auth/token/renew-accessor")
|
r := c.c.NewRequest(http.MethodPost, "/v1/auth/token/renew-accessor")
|
||||||
if err := r.SetJSONBody(map[string]interface{}{
|
if err := r.SetJSONBody(map[string]interface{}{
|
||||||
"accessor": accessor,
|
"accessor": accessor,
|
||||||
"increment": increment,
|
"increment": increment,
|
||||||
@@ -180,7 +181,7 @@ func (c *TokenAuth) RenewWithContext(ctx context.Context, token string, incremen
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/auth/token/renew")
|
r := c.c.NewRequest(http.MethodPut, "/v1/auth/token/renew")
|
||||||
if err := r.SetJSONBody(map[string]interface{}{
|
if err := r.SetJSONBody(map[string]interface{}{
|
||||||
"token": token,
|
"token": token,
|
||||||
"increment": increment,
|
"increment": increment,
|
||||||
@@ -205,7 +206,7 @@ func (c *TokenAuth) RenewSelfWithContext(ctx context.Context, increment int) (*S
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/auth/token/renew-self")
|
r := c.c.NewRequest(http.MethodPut, "/v1/auth/token/renew-self")
|
||||||
|
|
||||||
body := map[string]interface{}{"increment": increment}
|
body := map[string]interface{}{"increment": increment}
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
@@ -232,7 +233,7 @@ func (c *TokenAuth) RenewTokenAsSelfWithContext(ctx context.Context, token strin
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/auth/token/renew-self")
|
r := c.c.NewRequest(http.MethodPut, "/v1/auth/token/renew-self")
|
||||||
r.ClientToken = token
|
r.ClientToken = token
|
||||||
|
|
||||||
body := map[string]interface{}{"increment": increment}
|
body := map[string]interface{}{"increment": increment}
|
||||||
@@ -260,7 +261,7 @@ func (c *TokenAuth) RevokeAccessorWithContext(ctx context.Context, accessor stri
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", "/v1/auth/token/revoke-accessor")
|
r := c.c.NewRequest(http.MethodPost, "/v1/auth/token/revoke-accessor")
|
||||||
if err := r.SetJSONBody(map[string]interface{}{
|
if err := r.SetJSONBody(map[string]interface{}{
|
||||||
"accessor": accessor,
|
"accessor": accessor,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@@ -287,7 +288,7 @@ func (c *TokenAuth) RevokeOrphanWithContext(ctx context.Context, token string) e
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/auth/token/revoke-orphan")
|
r := c.c.NewRequest(http.MethodPut, "/v1/auth/token/revoke-orphan")
|
||||||
if err := r.SetJSONBody(map[string]interface{}{
|
if err := r.SetJSONBody(map[string]interface{}{
|
||||||
"token": token,
|
"token": token,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@@ -315,7 +316,7 @@ func (c *TokenAuth) RevokeSelfWithContext(ctx context.Context, token string) err
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/auth/token/revoke-self")
|
r := c.c.NewRequest(http.MethodPut, "/v1/auth/token/revoke-self")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -338,7 +339,7 @@ func (c *TokenAuth) RevokeTreeWithContext(ctx context.Context, token string) err
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/auth/token/revoke")
|
r := c.c.NewRequest(http.MethodPut, "/v1/auth/token/revoke")
|
||||||
if err := r.SetJSONBody(map[string]interface{}{
|
if err := r.SetJSONBody(map[string]interface{}{
|
||||||
"token": token,
|
"token": token,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func TestClientHostHeader(t *testing.T) {
|
|||||||
// Set the token manually
|
// Set the token manually
|
||||||
client.SetToken("foo")
|
client.SetToken("foo")
|
||||||
|
|
||||||
resp, err := client.RawRequest(client.NewRequest("PUT", "/"))
|
resp, err := client.RawRequest(client.NewRequest(http.MethodPut, "/"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -152,13 +152,13 @@ func TestClientBadToken(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
client.SetToken("foo")
|
client.SetToken("foo")
|
||||||
_, err = client.RawRequest(client.NewRequest("PUT", "/"))
|
_, err = client.RawRequest(client.NewRequest(http.MethodPut, "/"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client.SetToken("foo\u007f")
|
client.SetToken("foo\u007f")
|
||||||
_, err = client.RawRequest(client.NewRequest("PUT", "/"))
|
_, err = client.RawRequest(client.NewRequest(http.MethodPut, "/"))
|
||||||
if err == nil || !strings.Contains(err.Error(), "printable") {
|
if err == nil || !strings.Contains(err.Error(), "printable") {
|
||||||
t.Fatalf("expected error due to bad token")
|
t.Fatalf("expected error due to bad token")
|
||||||
}
|
}
|
||||||
@@ -187,7 +187,7 @@ func TestClientRedirect(t *testing.T) {
|
|||||||
client.SetToken("foo")
|
client.SetToken("foo")
|
||||||
|
|
||||||
// Do a raw "/" request
|
// Do a raw "/" request
|
||||||
resp, err := client.RawRequest(client.NewRequest("PUT", "/"))
|
resp, err := client.RawRequest(client.NewRequest(http.MethodPut, "/"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
@@ -331,7 +331,7 @@ func TestClientEnvNamespace(t *testing.T) {
|
|||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = client.RawRequest(client.NewRequest("GET", "/"))
|
_, err = client.RawRequest(client.NewRequest(http.MethodGet, "/"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
@@ -962,7 +962,7 @@ func TestClient_ReadYourWrites(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
testRequest := func(client *Client, val string) {
|
testRequest := func(client *Client, val string) {
|
||||||
req := client.NewRequest("GET", "/"+val)
|
req := client.NewRequest(http.MethodGet, "/"+val)
|
||||||
req.Headers.Set(HeaderIndex, val)
|
req.Headers.Set(HeaderIndex, val)
|
||||||
resp, err := client.RawRequestWithContext(context.Background(), req)
|
resp, err := client.RawRequestWithContext(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Help wraps HelpWithContext using context.Background.
|
// Help wraps HelpWithContext using context.Background.
|
||||||
@@ -15,7 +16,7 @@ func (c *Client) HelpWithContext(ctx context.Context, path string) (*Help, error
|
|||||||
ctx, cancelFunc := c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.NewRequest("GET", fmt.Sprintf("/v1/%s", path))
|
r := c.NewRequest(http.MethodGet, fmt.Sprintf("/v1/%s", path))
|
||||||
r.Params.Add("help", "1")
|
r.Params.Add("help", "1")
|
||||||
|
|
||||||
resp, err := c.rawRequestWithContext(ctx, r)
|
resp, err := c.rawRequestWithContext(ctx, r)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -30,7 +31,7 @@ var (
|
|||||||
return os.Getenv(EnvVaultWrapTTL)
|
return os.Getenv(EnvVaultWrapTTL)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operation == "PUT" || operation == "POST") && path == "sys/wrapping/wrap" {
|
if (operation == http.MethodPut || operation == http.MethodPost) && path == "sys/wrapping/wrap" {
|
||||||
return DefaultWrappingTTL
|
return DefaultWrappingTTL
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ func (c *Logical) ReadWithDataWithContext(ctx context.Context, path string, data
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/"+path)
|
r := c.c.NewRequest(http.MethodGet, "/v1/"+path)
|
||||||
|
|
||||||
var values url.Values
|
var values url.Values
|
||||||
for k, v := range data {
|
for k, v := range data {
|
||||||
@@ -116,7 +117,7 @@ func (c *Logical) ListWithContext(ctx context.Context, path string) (*Secret, er
|
|||||||
r := c.c.NewRequest("LIST", "/v1/"+path)
|
r := c.c.NewRequest("LIST", "/v1/"+path)
|
||||||
// Set this for broader compatibility, but we use LIST above to be able to
|
// Set this for broader compatibility, but we use LIST above to be able to
|
||||||
// handle the wrapping lookup function
|
// handle the wrapping lookup function
|
||||||
r.Method = "GET"
|
r.Method = http.MethodGet
|
||||||
r.Params.Set("list", "true")
|
r.Params.Set("list", "true")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
@@ -149,7 +150,7 @@ func (c *Logical) Write(path string, data map[string]interface{}) (*Secret, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Logical) WriteWithContext(ctx context.Context, path string, data map[string]interface{}) (*Secret, error) {
|
func (c *Logical) WriteWithContext(ctx context.Context, path string, data map[string]interface{}) (*Secret, error) {
|
||||||
r := c.c.NewRequest("PUT", "/v1/"+path)
|
r := c.c.NewRequest(http.MethodPut, "/v1/"+path)
|
||||||
if err := r.SetJSONBody(data); err != nil {
|
if err := r.SetJSONBody(data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -158,7 +159,7 @@ func (c *Logical) WriteWithContext(ctx context.Context, path string, data map[st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Logical) JSONMergePatch(ctx context.Context, path string, data map[string]interface{}) (*Secret, error) {
|
func (c *Logical) JSONMergePatch(ctx context.Context, path string, data map[string]interface{}) (*Secret, error) {
|
||||||
r := c.c.NewRequest("PATCH", "/v1/"+path)
|
r := c.c.NewRequest(http.MethodPatch, "/v1/"+path)
|
||||||
r.Headers.Set("Content-Type", "application/merge-patch+json")
|
r.Headers.Set("Content-Type", "application/merge-patch+json")
|
||||||
if err := r.SetJSONBody(data); err != nil {
|
if err := r.SetJSONBody(data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -172,7 +173,7 @@ func (c *Logical) WriteBytes(path string, data []byte) (*Secret, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Logical) WriteBytesWithContext(ctx context.Context, path string, data []byte) (*Secret, error) {
|
func (c *Logical) WriteBytesWithContext(ctx context.Context, path string, data []byte) (*Secret, error) {
|
||||||
r := c.c.NewRequest("PUT", "/v1/"+path)
|
r := c.c.NewRequest(http.MethodPut, "/v1/"+path)
|
||||||
r.BodyBytes = data
|
r.BodyBytes = data
|
||||||
|
|
||||||
return c.write(ctx, path, r)
|
return c.write(ctx, path, r)
|
||||||
@@ -222,7 +223,7 @@ func (c *Logical) DeleteWithDataWithContext(ctx context.Context, path string, da
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", "/v1/"+path)
|
r := c.c.NewRequest(http.MethodDelete, "/v1/"+path)
|
||||||
|
|
||||||
var values url.Values
|
var values url.Values
|
||||||
for k, v := range data {
|
for k, v := range data {
|
||||||
@@ -282,7 +283,7 @@ func (c *Logical) UnwrapWithContext(ctx context.Context, wrappingToken string) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/wrapping/unwrap")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/wrapping/unwrap")
|
||||||
if err := r.SetJSONBody(data); err != nil {
|
if err := r.SetJSONBody(data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
retryablehttp "github.com/hashicorp/go-retryablehttp"
|
retryablehttp "github.com/hashicorp/go-retryablehttp"
|
||||||
@@ -45,7 +46,7 @@ func (d *OutputStringError) parseRequest() {
|
|||||||
if d.TLSSkipVerify {
|
if d.TLSSkipVerify {
|
||||||
d.parsedCurlString += "--insecure "
|
d.parsedCurlString += "--insecure "
|
||||||
}
|
}
|
||||||
if d.Request.Method != "GET" {
|
if d.Request.Method != http.MethodGet {
|
||||||
d.parsedCurlString = fmt.Sprintf("%s-X %s ", d.parsedCurlString, d.Request.Method)
|
d.parsedCurlString = fmt.Sprintf("%s-X %s ", d.parsedCurlString, d.Request.Method)
|
||||||
}
|
}
|
||||||
if d.ClientCACert != "" {
|
if d.ClientCACert != "" {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SSH is used to return a client to invoke operations on SSH backend.
|
// SSH is used to return a client to invoke operations on SSH backend.
|
||||||
@@ -34,7 +35,7 @@ func (c *SSH) CredentialWithContext(ctx context.Context, role string, data map[s
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", fmt.Sprintf("/v1/%s/creds/%s", c.MountPoint, role))
|
r := c.c.NewRequest(http.MethodPut, fmt.Sprintf("/v1/%s/creds/%s", c.MountPoint, role))
|
||||||
if err := r.SetJSONBody(data); err != nil {
|
if err := r.SetJSONBody(data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -59,7 +60,7 @@ func (c *SSH) SignKeyWithContext(ctx context.Context, role string, data map[stri
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", fmt.Sprintf("/v1/%s/sign/%s", c.MountPoint, role))
|
r := c.c.NewRequest(http.MethodPut, fmt.Sprintf("/v1/%s/sign/%s", c.MountPoint, role))
|
||||||
if err := r.SetJSONBody(data); err != nil {
|
if err := r.SetJSONBody(data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/hashicorp/errwrap"
|
"github.com/hashicorp/errwrap"
|
||||||
@@ -218,7 +219,7 @@ func (c *SSHHelper) VerifyWithContext(ctx context.Context, otp string) (*SSHVeri
|
|||||||
"otp": otp,
|
"otp": otp,
|
||||||
}
|
}
|
||||||
verifyPath := fmt.Sprintf("/v1/%s/verify", c.MountPoint)
|
verifyPath := fmt.Sprintf("/v1/%s/verify", c.MountPoint)
|
||||||
r := c.c.NewRequest("PUT", verifyPath)
|
r := c.c.NewRequest(http.MethodPut, verifyPath)
|
||||||
if err := r.SetJSONBody(data); err != nil {
|
if err := r.SetJSONBody(data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
@@ -20,7 +21,7 @@ func (c *Sys) AuditHashWithContext(ctx context.Context, path string, input strin
|
|||||||
"input": input,
|
"input": input,
|
||||||
}
|
}
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", fmt.Sprintf("/v1/sys/audit-hash/%s", path))
|
r := c.c.NewRequest(http.MethodPut, fmt.Sprintf("/v1/sys/audit-hash/%s", path))
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -59,7 +60,7 @@ func (c *Sys) ListAuditWithContext(ctx context.Context) (map[string]*Audit, erro
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/audit")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/audit")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -102,7 +103,7 @@ func (c *Sys) EnableAuditWithOptionsWithContext(ctx context.Context, path string
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", fmt.Sprintf("/v1/sys/audit/%s", path))
|
r := c.c.NewRequest(http.MethodPut, fmt.Sprintf("/v1/sys/audit/%s", path))
|
||||||
if err := r.SetJSONBody(options); err != nil {
|
if err := r.SetJSONBody(options); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -124,7 +125,7 @@ func (c *Sys) DisableAuditWithContext(ctx context.Context, path string) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", fmt.Sprintf("/v1/sys/audit/%s", path))
|
r := c.c.NewRequest(http.MethodDelete, fmt.Sprintf("/v1/sys/audit/%s", path))
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
@@ -16,7 +17,7 @@ func (c *Sys) ListAuthWithContext(ctx context.Context) (map[string]*AuthMount, e
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/auth")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/auth")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -57,7 +58,7 @@ func (c *Sys) EnableAuthWithOptionsWithContext(ctx context.Context, path string,
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", fmt.Sprintf("/v1/sys/auth/%s", path))
|
r := c.c.NewRequest(http.MethodPost, fmt.Sprintf("/v1/sys/auth/%s", path))
|
||||||
if err := r.SetJSONBody(options); err != nil {
|
if err := r.SetJSONBody(options); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -79,7 +80,7 @@ func (c *Sys) DisableAuthWithContext(ctx context.Context, path string) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", fmt.Sprintf("/v1/sys/auth/%s", path))
|
r := c.c.NewRequest(http.MethodDelete, fmt.Sprintf("/v1/sys/auth/%s", path))
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
@@ -37,7 +38,7 @@ func (c *Sys) CapabilitiesWithContext(ctx context.Context, token, path string) (
|
|||||||
reqPath = fmt.Sprintf("%s-self", reqPath)
|
reqPath = fmt.Sprintf("%s-self", reqPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", reqPath)
|
r := c.c.NewRequest(http.MethodPost, reqPath)
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
@@ -15,7 +16,7 @@ func (c *Sys) CORSStatusWithContext(ctx context.Context) (*CORSResponse, error)
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/config/cors")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/config/cors")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -48,7 +49,7 @@ func (c *Sys) ConfigureCORSWithContext(ctx context.Context, req *CORSRequest) er
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/config/cors")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/config/cors")
|
||||||
if err := r.SetJSONBody(req); err != nil {
|
if err := r.SetJSONBody(req); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -68,7 +69,7 @@ func (c *Sys) DisableCORSWithContext(ctx context.Context) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", "/v1/sys/config/cors")
|
r := c.c.NewRequest(http.MethodDelete, "/v1/sys/config/cors")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import "context"
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func (c *Sys) GenerateRootStatus() (*GenerateRootStatusResponse, error) {
|
func (c *Sys) GenerateRootStatus() (*GenerateRootStatusResponse, error) {
|
||||||
return c.GenerateRootStatusWithContext(context.Background())
|
return c.GenerateRootStatusWithContext(context.Background())
|
||||||
@@ -30,7 +33,7 @@ func (c *Sys) generateRootStatusCommonWithContext(ctx context.Context, path stri
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", path)
|
r := c.c.NewRequest(http.MethodGet, path)
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -76,7 +79,7 @@ func (c *Sys) generateRootInitCommonWithContext(ctx context.Context, path, otp,
|
|||||||
"pgp_key": pgpKey,
|
"pgp_key": pgpKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", path)
|
r := c.c.NewRequest(http.MethodPut, path)
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -120,7 +123,7 @@ func (c *Sys) generateRootCancelCommonWithContext(ctx context.Context, path stri
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", path)
|
r := c.c.NewRequest(http.MethodDelete, path)
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -162,7 +165,7 @@ func (c *Sys) generateRootUpdateCommonWithContext(ctx context.Context, path, sha
|
|||||||
"nonce": nonce,
|
"nonce": nonce,
|
||||||
}
|
}
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", path)
|
r := c.c.NewRequest(http.MethodPut, path)
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ func (c *Sys) HAStatusWithContext(ctx context.Context) (*HAStatusResponse, error
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/ha-status")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/ha-status")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import "context"
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func (c *Sys) Health() (*HealthResponse, error) {
|
func (c *Sys) Health() (*HealthResponse, error) {
|
||||||
return c.HealthWithContext(context.Background())
|
return c.HealthWithContext(context.Background())
|
||||||
@@ -10,7 +13,7 @@ func (c *Sys) HealthWithContext(ctx context.Context) (*HealthResponse, error) {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/health")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/health")
|
||||||
// If the code is 400 or above it will automatically turn into an error,
|
// If the code is 400 or above it will automatically turn into an error,
|
||||||
// but the sys/health API defaults to returning 5xx when not sealed or
|
// but the sys/health API defaults to returning 5xx when not sealed or
|
||||||
// inited, so we force this code to be something else so we parse correctly
|
// inited, so we force this code to be something else so we parse correctly
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import "context"
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func (c *Sys) InitStatus() (bool, error) {
|
func (c *Sys) InitStatus() (bool, error) {
|
||||||
return c.InitStatusWithContext(context.Background())
|
return c.InitStatusWithContext(context.Background())
|
||||||
@@ -10,7 +13,7 @@ func (c *Sys) InitStatusWithContext(ctx context.Context) (bool, error) {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/init")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/init")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -31,7 +34,7 @@ func (c *Sys) InitWithContext(ctx context.Context, opts *InitRequest) (*InitResp
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/init")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/init")
|
||||||
if err := r.SetJSONBody(opts); err != nil {
|
if err := r.SetJSONBody(opts); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ func (c *Sys) LeaderWithContext(ctx context.Context) (*LeaderResponse, error) {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/leader")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/leader")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Sys) Renew(id string, increment int) (*Secret, error) {
|
func (c *Sys) Renew(id string, increment int) (*Secret, error) {
|
||||||
@@ -13,7 +14,7 @@ func (c *Sys) RenewWithContext(ctx context.Context, id string, increment int) (*
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/leases/renew")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/leases/renew")
|
||||||
|
|
||||||
body := map[string]interface{}{
|
body := map[string]interface{}{
|
||||||
"increment": increment,
|
"increment": increment,
|
||||||
@@ -40,7 +41,7 @@ func (c *Sys) LookupWithContext(ctx context.Context, id string) (*Secret, error)
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/leases/lookup")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/leases/lookup")
|
||||||
|
|
||||||
body := map[string]interface{}{
|
body := map[string]interface{}{
|
||||||
"lease_id": id,
|
"lease_id": id,
|
||||||
@@ -66,7 +67,7 @@ func (c *Sys) RevokeWithContext(ctx context.Context, id string) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/leases/revoke")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/leases/revoke")
|
||||||
body := map[string]interface{}{
|
body := map[string]interface{}{
|
||||||
"lease_id": id,
|
"lease_id": id,
|
||||||
}
|
}
|
||||||
@@ -89,7 +90,7 @@ func (c *Sys) RevokePrefixWithContext(ctx context.Context, id string) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/leases/revoke-prefix/"+id)
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/leases/revoke-prefix/"+id)
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -106,7 +107,7 @@ func (c *Sys) RevokeForceWithContext(ctx context.Context, id string) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/leases/revoke-force/"+id)
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/leases/revoke-force/"+id)
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -137,7 +138,7 @@ func (c *Sys) RevokeWithOptionsWithContext(ctx context.Context, opts *RevokeOpti
|
|||||||
}
|
}
|
||||||
path += opts.LeaseID
|
path += opts.LeaseID
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", path)
|
r := c.c.NewRequest(http.MethodPut, path)
|
||||||
if !opts.Force {
|
if !opts.Force {
|
||||||
body := map[string]interface{}{
|
body := map[string]interface{}{
|
||||||
"sync": opts.Sync,
|
"sync": opts.Sync,
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Monitor returns a channel that outputs strings containing the log messages
|
// Monitor returns a channel that outputs strings containing the log messages
|
||||||
// coming from the server.
|
// coming from the server.
|
||||||
func (c *Sys) Monitor(ctx context.Context, logLevel string) (chan string, error) {
|
func (c *Sys) Monitor(ctx context.Context, logLevel string) (chan string, error) {
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/monitor")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/monitor")
|
||||||
|
|
||||||
if logLevel == "" {
|
if logLevel == "" {
|
||||||
r.Params.Add("log_level", "info")
|
r.Params.Add("log_level", "info")
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
@@ -17,7 +18,7 @@ func (c *Sys) ListMountsWithContext(ctx context.Context) (map[string]*MountOutpu
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/mounts")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/mounts")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -50,7 +51,7 @@ func (c *Sys) MountWithContext(ctx context.Context, path string, mountInfo *Moun
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", fmt.Sprintf("/v1/sys/mounts/%s", path))
|
r := c.c.NewRequest(http.MethodPost, fmt.Sprintf("/v1/sys/mounts/%s", path))
|
||||||
if err := r.SetJSONBody(mountInfo); err != nil {
|
if err := r.SetJSONBody(mountInfo); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -72,7 +73,7 @@ func (c *Sys) UnmountWithContext(ctx context.Context, path string) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", fmt.Sprintf("/v1/sys/mounts/%s", path))
|
r := c.c.NewRequest(http.MethodDelete, fmt.Sprintf("/v1/sys/mounts/%s", path))
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -124,7 +125,7 @@ func (c *Sys) StartRemountWithContext(ctx context.Context, from, to string) (*Mo
|
|||||||
"to": to,
|
"to": to,
|
||||||
}
|
}
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", "/v1/sys/remount")
|
r := c.c.NewRequest(http.MethodPost, "/v1/sys/remount")
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -161,7 +162,7 @@ func (c *Sys) RemountStatusWithContext(ctx context.Context, migrationID string)
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", fmt.Sprintf("/v1/sys/remount/status/%s", migrationID))
|
r := c.c.NewRequest(http.MethodGet, fmt.Sprintf("/v1/sys/remount/status/%s", migrationID))
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -193,7 +194,7 @@ func (c *Sys) TuneMountWithContext(ctx context.Context, path string, config Moun
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", fmt.Sprintf("/v1/sys/mounts/%s/tune", path))
|
r := c.c.NewRequest(http.MethodPost, fmt.Sprintf("/v1/sys/mounts/%s/tune", path))
|
||||||
if err := r.SetJSONBody(config); err != nil {
|
if err := r.SetJSONBody(config); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -213,7 +214,7 @@ func (c *Sys) MountConfigWithContext(ctx context.Context, path string) (*MountCo
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", fmt.Sprintf("/v1/sys/mounts/%s/tune", path))
|
r := c.c.NewRequest(http.MethodGet, fmt.Sprintf("/v1/sys/mounts/%s/tune", path))
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func (c *Sys) ListPluginsWithContext(ctx context.Context, i *ListPluginsInput) (
|
|||||||
method := ""
|
method := ""
|
||||||
if i.Type == consts.PluginTypeUnknown {
|
if i.Type == consts.PluginTypeUnknown {
|
||||||
path = "/v1/sys/plugins/catalog"
|
path = "/v1/sys/plugins/catalog"
|
||||||
method = "GET"
|
method = http.MethodGet
|
||||||
} else {
|
} else {
|
||||||
path = fmt.Sprintf("/v1/sys/plugins/catalog/%s", i.Type)
|
path = fmt.Sprintf("/v1/sys/plugins/catalog/%s", i.Type)
|
||||||
method = "LIST"
|
method = "LIST"
|
||||||
@@ -54,7 +54,7 @@ func (c *Sys) ListPluginsWithContext(ctx context.Context, i *ListPluginsInput) (
|
|||||||
if method == "LIST" {
|
if method == "LIST" {
|
||||||
// Set this for broader compatibility, but we use LIST above to be able
|
// Set this for broader compatibility, but we use LIST above to be able
|
||||||
// to handle the wrapping lookup function
|
// to handle the wrapping lookup function
|
||||||
req.Method = "GET"
|
req.Method = http.MethodGet
|
||||||
req.Params.Set("list", "true")
|
req.Params.Set("list", "true")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
@@ -19,7 +20,7 @@ func (c *Sys) ListPoliciesWithContext(ctx context.Context) ([]string, error) {
|
|||||||
r := c.c.NewRequest("LIST", "/v1/sys/policies/acl")
|
r := c.c.NewRequest("LIST", "/v1/sys/policies/acl")
|
||||||
// Set this for broader compatibility, but we use LIST above to be able to
|
// Set this for broader compatibility, but we use LIST above to be able to
|
||||||
// handle the wrapping lookup function
|
// handle the wrapping lookup function
|
||||||
r.Method = "GET"
|
r.Method = http.MethodGet
|
||||||
r.Params.Set("list", "true")
|
r.Params.Set("list", "true")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
@@ -53,7 +54,7 @@ func (c *Sys) GetPolicyWithContext(ctx context.Context, name string) (string, er
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", fmt.Sprintf("/v1/sys/policies/acl/%s", name))
|
r := c.c.NewRequest(http.MethodGet, fmt.Sprintf("/v1/sys/policies/acl/%s", name))
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
@@ -93,7 +94,7 @@ func (c *Sys) PutPolicyWithContext(ctx context.Context, name, rules string) erro
|
|||||||
"policy": rules,
|
"policy": rules,
|
||||||
}
|
}
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", fmt.Sprintf("/v1/sys/policies/acl/%s", name))
|
r := c.c.NewRequest(http.MethodPut, fmt.Sprintf("/v1/sys/policies/acl/%s", name))
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -115,7 +116,7 @@ func (c *Sys) DeletePolicyWithContext(ctx context.Context, name string) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", fmt.Sprintf("/v1/sys/policies/acl/%s", name))
|
r := c.c.NewRequest(http.MethodDelete, fmt.Sprintf("/v1/sys/policies/acl/%s", name))
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ func (c *Sys) RaftJoinWithContext(ctx context.Context, opts *RaftJoinRequest) (*
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", "/v1/sys/storage/raft/join")
|
r := c.c.NewRequest(http.MethodPost, "/v1/sys/storage/raft/join")
|
||||||
|
|
||||||
if err := r.SetJSONBody(opts); err != nil {
|
if err := r.SetJSONBody(opts); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -144,7 +144,7 @@ func (c *Sys) RaftSnapshot(snapWriter io.Writer) error {
|
|||||||
// RaftSnapshotWithContext invokes the API that takes the snapshot of the raft cluster and
|
// RaftSnapshotWithContext invokes the API that takes the snapshot of the raft cluster and
|
||||||
// writes it to the supplied io.Writer.
|
// writes it to the supplied io.Writer.
|
||||||
func (c *Sys) RaftSnapshotWithContext(ctx context.Context, snapWriter io.Writer) error {
|
func (c *Sys) RaftSnapshotWithContext(ctx context.Context, snapWriter io.Writer) error {
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/storage/raft/snapshot")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/storage/raft/snapshot")
|
||||||
r.URL.RawQuery = r.Params.Encode()
|
r.URL.RawQuery = r.Params.Encode()
|
||||||
|
|
||||||
resp, err := c.c.httpRequestWithContext(ctx, r)
|
resp, err := c.c.httpRequestWithContext(ctx, r)
|
||||||
@@ -245,7 +245,7 @@ func (c *Sys) RaftAutopilotStateWithContext(ctx context.Context) (*AutopilotStat
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/storage/raft/autopilot/state")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/storage/raft/autopilot/state")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
@@ -285,7 +285,7 @@ func (c *Sys) RaftAutopilotConfigurationWithContext(ctx context.Context) (*Autop
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/storage/raft/autopilot/configuration")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/storage/raft/autopilot/configuration")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
@@ -333,7 +333,7 @@ func (c *Sys) PutRaftAutopilotConfigurationWithContext(ctx context.Context, opts
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", "/v1/sys/storage/raft/autopilot/configuration")
|
r := c.c.NewRequest(http.MethodPost, "/v1/sys/storage/raft/autopilot/configuration")
|
||||||
|
|
||||||
if err := r.SetJSONBody(opts); err != nil {
|
if err := r.SetJSONBody(opts); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
@@ -15,7 +16,7 @@ func (c *Sys) RekeyStatusWithContext(ctx context.Context) (*RekeyStatusResponse,
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/rekey/init")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/rekey/init")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -36,7 +37,7 @@ func (c *Sys) RekeyRecoveryKeyStatusWithContext(ctx context.Context) (*RekeyStat
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/rekey-recovery-key/init")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/rekey-recovery-key/init")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -57,7 +58,7 @@ func (c *Sys) RekeyVerificationStatusWithContext(ctx context.Context) (*RekeyVer
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/rekey/verify")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/rekey/verify")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -78,7 +79,7 @@ func (c *Sys) RekeyRecoveryKeyVerificationStatusWithContext(ctx context.Context)
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/rekey-recovery-key/verify")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/rekey-recovery-key/verify")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -99,7 +100,7 @@ func (c *Sys) RekeyInitWithContext(ctx context.Context, config *RekeyInitRequest
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/rekey/init")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/rekey/init")
|
||||||
if err := r.SetJSONBody(config); err != nil {
|
if err := r.SetJSONBody(config); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -123,7 +124,7 @@ func (c *Sys) RekeyRecoveryKeyInitWithContext(ctx context.Context, config *Rekey
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/rekey-recovery-key/init")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/rekey-recovery-key/init")
|
||||||
if err := r.SetJSONBody(config); err != nil {
|
if err := r.SetJSONBody(config); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -147,7 +148,7 @@ func (c *Sys) RekeyCancelWithContext(ctx context.Context) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", "/v1/sys/rekey/init")
|
r := c.c.NewRequest(http.MethodDelete, "/v1/sys/rekey/init")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -164,7 +165,7 @@ func (c *Sys) RekeyRecoveryKeyCancelWithContext(ctx context.Context) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", "/v1/sys/rekey-recovery-key/init")
|
r := c.c.NewRequest(http.MethodDelete, "/v1/sys/rekey-recovery-key/init")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -181,7 +182,7 @@ func (c *Sys) RekeyVerificationCancelWithContext(ctx context.Context) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", "/v1/sys/rekey/verify")
|
r := c.c.NewRequest(http.MethodDelete, "/v1/sys/rekey/verify")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -198,7 +199,7 @@ func (c *Sys) RekeyRecoveryKeyVerificationCancelWithContext(ctx context.Context)
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", "/v1/sys/rekey-recovery-key/verify")
|
r := c.c.NewRequest(http.MethodDelete, "/v1/sys/rekey-recovery-key/verify")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -220,7 +221,7 @@ func (c *Sys) RekeyUpdateWithContext(ctx context.Context, shard, nonce string) (
|
|||||||
"nonce": nonce,
|
"nonce": nonce,
|
||||||
}
|
}
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/rekey/update")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/rekey/update")
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -249,7 +250,7 @@ func (c *Sys) RekeyRecoveryKeyUpdateWithContext(ctx context.Context, shard, nonc
|
|||||||
"nonce": nonce,
|
"nonce": nonce,
|
||||||
}
|
}
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/rekey-recovery-key/update")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/rekey-recovery-key/update")
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -273,7 +274,7 @@ func (c *Sys) RekeyRetrieveBackupWithContext(ctx context.Context) (*RekeyRetriev
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/rekey/backup")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/rekey/backup")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -306,7 +307,7 @@ func (c *Sys) RekeyRetrieveRecoveryBackupWithContext(ctx context.Context) (*Reke
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/rekey/recovery-key-backup")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/rekey/recovery-key-backup")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -339,7 +340,7 @@ func (c *Sys) RekeyDeleteBackupWithContext(ctx context.Context) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", "/v1/sys/rekey/backup")
|
r := c.c.NewRequest(http.MethodDelete, "/v1/sys/rekey/backup")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -357,7 +358,7 @@ func (c *Sys) RekeyDeleteRecoveryBackupWithContext(ctx context.Context) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("DELETE", "/v1/sys/rekey/recovery-key-backup")
|
r := c.c.NewRequest(http.MethodDelete, "/v1/sys/rekey/recovery-key-backup")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -380,7 +381,7 @@ func (c *Sys) RekeyVerificationUpdateWithContext(ctx context.Context, shard, non
|
|||||||
"nonce": nonce,
|
"nonce": nonce,
|
||||||
}
|
}
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/rekey/verify")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/rekey/verify")
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -409,7 +410,7 @@ func (c *Sys) RekeyRecoveryKeyVerificationUpdateWithContext(ctx context.Context,
|
|||||||
"nonce": nonce,
|
"nonce": nonce,
|
||||||
}
|
}
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/rekey-recovery-key/verify")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/rekey-recovery-key/verify")
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ func (c *Sys) RotateWithContext(ctx context.Context) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("POST", "/v1/sys/rotate")
|
r := c.c.NewRequest(http.MethodPost, "/v1/sys/rotate")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -32,7 +33,7 @@ func (c *Sys) KeyStatusWithContext(ctx context.Context) (*KeyStatus, error) {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/key-status")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/key-status")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import "context"
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func (c *Sys) SealStatus() (*SealStatusResponse, error) {
|
func (c *Sys) SealStatus() (*SealStatusResponse, error) {
|
||||||
return c.SealStatusWithContext(context.Background())
|
return c.SealStatusWithContext(context.Background())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Sys) SealStatusWithContext(ctx context.Context) (*SealStatusResponse, error) {
|
func (c *Sys) SealStatusWithContext(ctx context.Context) (*SealStatusResponse, error) {
|
||||||
r := c.c.NewRequest("GET", "/v1/sys/seal-status")
|
r := c.c.NewRequest(http.MethodGet, "/v1/sys/seal-status")
|
||||||
return sealStatusRequestWithContext(ctx, c, r)
|
return sealStatusRequestWithContext(ctx, c, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +22,7 @@ func (c *Sys) SealWithContext(ctx context.Context) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/seal")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/seal")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -37,7 +40,7 @@ func (c *Sys) ResetUnsealProcess() (*SealStatusResponse, error) {
|
|||||||
func (c *Sys) ResetUnsealProcessWithContext(ctx context.Context) (*SealStatusResponse, error) {
|
func (c *Sys) ResetUnsealProcessWithContext(ctx context.Context) (*SealStatusResponse, error) {
|
||||||
body := map[string]interface{}{"reset": true}
|
body := map[string]interface{}{"reset": true}
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/unseal")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/unseal")
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -52,7 +55,7 @@ func (c *Sys) Unseal(shard string) (*SealStatusResponse, error) {
|
|||||||
func (c *Sys) UnsealWithContext(ctx context.Context, shard string) (*SealStatusResponse, error) {
|
func (c *Sys) UnsealWithContext(ctx context.Context, shard string) (*SealStatusResponse, error) {
|
||||||
body := map[string]interface{}{"key": shard}
|
body := map[string]interface{}{"key": shard}
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/unseal")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/unseal")
|
||||||
if err := r.SetJSONBody(body); err != nil {
|
if err := r.SetJSONBody(body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -65,7 +68,7 @@ func (c *Sys) UnsealWithOptions(opts *UnsealOpts) (*SealStatusResponse, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Sys) UnsealWithOptionsWithContext(ctx context.Context, opts *UnsealOpts) (*SealStatusResponse, error) {
|
func (c *Sys) UnsealWithOptionsWithContext(ctx context.Context, opts *UnsealOpts) (*SealStatusResponse, error) {
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/unseal")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/unseal")
|
||||||
|
|
||||||
if err := r.SetJSONBody(opts); err != nil {
|
if err := r.SetJSONBody(opts); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import "context"
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func (c *Sys) StepDown() error {
|
func (c *Sys) StepDown() error {
|
||||||
return c.StepDownWithContext(context.Background())
|
return c.StepDownWithContext(context.Background())
|
||||||
@@ -10,7 +13,7 @@ func (c *Sys) StepDownWithContext(ctx context.Context) error {
|
|||||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||||
defer cancelFunc()
|
defer cancelFunc()
|
||||||
|
|
||||||
r := c.c.NewRequest("PUT", "/v1/sys/step-down")
|
r := c.c.NewRequest(http.MethodPut, "/v1/sys/step-down")
|
||||||
|
|
||||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||||
if resp != nil && resp.Body != nil {
|
if resp != nil && resp.Body != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user