Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a couple of instances where we are using LIST verb #6026

Merged
merged 3 commits into from
Jan 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions api/sys_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ func (c *Sys) ListPlugins(i *ListPluginsInput) (*ListPluginsResponse, error) {
}

req := c.c.NewRequest(method, path)
if method == "LIST" {
// Set this for broader compatibility, but we use LIST above to be able
// to handle the wrapping lookup function
req.Method = "GET"
req.Params.Set("list", "true")
}

ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
Expand All @@ -55,9 +61,10 @@ func (c *Sys) ListPlugins(i *ListPluginsInput) (*ListPluginsResponse, error) {
defer resp.Body.Close()

// We received an Unsupported Operation response from Vault, indicating
// Vault of an older version that doesn't support the READ method yet.
if resp.StatusCode == 405 && req.Method == "GET" {
req.Method = "LIST"
// Vault of an older version that doesn't support the GET method yet;
// switch it to a LIST.
if resp.StatusCode == 405 {
req.Params.Set("list", "true")
resp, err := c.c.RawRequestWithContext(ctx, req)
if err != nil {
return nil, err
Expand Down
4 changes: 4 additions & 0 deletions api/sys_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (

func (c *Sys) ListPolicies() ([]string, error) {
r := c.c.NewRequest("LIST", "/v1/sys/policies/acl")
// Set this for broader compatibility, but we use LIST above to be able to
// handle the wrapping lookup function
r.Method = "GET"
r.Params.Set("list", "true")

ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
Expand Down