Skip to content

Commit

Permalink
Use constants for HTTP method names
Browse files Browse the repository at this point in the history
Co-authored-by: Vinny Mannello <[email protected]>
  • Loading branch information
averche and VinnyHC authored Mar 22, 2022
1 parent d1b650c commit 7912ba5
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion api/auth_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (c *TokenAuth) LookupSelfWithContext(ctx context.Context) (*Secret, error)
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions api/sys_audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (c *Sys) ListAuditWithContext(ctx context.Context) (map[string]*Audit, erro
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err != nil {
Expand Down Expand Up @@ -124,7 +124,7 @@ func (c *Sys) DisableAuditWithContext(ctx context.Context, path string) error {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)

Expand Down
4 changes: 2 additions & 2 deletions api/sys_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (c *Sys) ListAuthWithContext(ctx context.Context) (map[string]*AuthMount, e
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err != nil {
Expand Down Expand Up @@ -79,7 +79,7 @@ func (c *Sys) DisableAuthWithContext(ctx context.Context, path string) error {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err == nil {
Expand Down
4 changes: 2 additions & 2 deletions api/sys_config_cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (c *Sys) CORSStatusWithContext(ctx context.Context) (*CORSResponse, error)
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err != nil {
Expand Down Expand Up @@ -68,7 +68,7 @@ func (c *Sys) DisableCORSWithContext(ctx context.Context) error {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err == nil {
Expand Down
4 changes: 2 additions & 2 deletions api/sys_generate_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (c *Sys) generateRootStatusCommonWithContext(ctx context.Context, path stri
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
defer cancelFunc()

r := c.c.NewRequest("GET", path)
r := c.c.NewRequest(http.MethodGet, path)

resp, err := c.c.rawRequestWithContext(ctx, r)
if err != nil {
Expand Down Expand Up @@ -120,7 +120,7 @@ func (c *Sys) generateRootCancelCommonWithContext(ctx context.Context, path stri
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
defer cancelFunc()

r := c.c.NewRequest("DELETE", path)
r := c.c.NewRequest(http.MethodDelete, path)

resp, err := c.c.rawRequestWithContext(ctx, r)
if err == nil {
Expand Down
2 changes: 1 addition & 1 deletion api/sys_hastatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (c *Sys) HAStatusWithContext(ctx context.Context) (*HAStatusResponse, error
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion api/sys_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func (c *Sys) InitStatusWithContext(ctx context.Context) (bool, error) {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion api/sys_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (c *Sys) LeaderWithContext(ctx context.Context) (*LeaderResponse, error) {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions api/sys_leases.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (c *Sys) RevokePrefixWithContext(ctx context.Context, id string) error {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err == nil {
Expand All @@ -106,7 +106,7 @@ func (c *Sys) RevokeForceWithContext(ctx context.Context, id string) error {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err == nil {
Expand Down
8 changes: 4 additions & 4 deletions api/sys_mounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (c *Sys) ListMountsWithContext(ctx context.Context) (map[string]*MountOutpu
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err != nil {
Expand Down Expand Up @@ -72,7 +72,7 @@ func (c *Sys) UnmountWithContext(ctx context.Context, path string) error {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err == nil {
Expand Down Expand Up @@ -161,7 +161,7 @@ func (c *Sys) RemountStatusWithContext(ctx context.Context, migrationID string)
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err != nil {
Expand Down Expand Up @@ -213,7 +213,7 @@ func (c *Sys) MountConfigWithContext(ctx context.Context, path string) (*MountCo
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions api/sys_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (c *Sys) GetPolicyWithContext(ctx context.Context, name string) (string, er
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if resp != nil {
Expand Down Expand Up @@ -115,7 +115,7 @@ func (c *Sys) DeletePolicyWithContext(ctx context.Context, name string) error {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err == nil {
Expand Down
4 changes: 2 additions & 2 deletions api/sys_raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (c *Sys) RaftAutopilotStateWithContext(ctx context.Context) (*AutopilotStat
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if resp != nil {
Expand Down Expand Up @@ -285,7 +285,7 @@ func (c *Sys) RaftAutopilotConfigurationWithContext(ctx context.Context) (*Autop
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if resp != nil {
Expand Down
2 changes: 1 addition & 1 deletion api/sys_seal.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (c *Sys) SealWithContext(ctx context.Context) error {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion api/sys_stepdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func (c *Sys) StepDownWithContext(ctx context.Context) error {
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
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)
if resp != nil && resp.Body != nil {
Expand Down

0 comments on commit 7912ba5

Please sign in to comment.