Add context-aware functions to vault/api (#14388)

This commit is contained in:
Anton Averchenkov
2022-03-23 17:47:43 -04:00
committed by GitHub
parent fea828993c
commit 8234a663e7
130 changed files with 2114 additions and 1463 deletions

View File

@@ -5,14 +5,20 @@ import (
"fmt"
)
// Help reads the help information for the given path.
// Help wraps HelpWithContext using context.Background.
func (c *Client) Help(path string) (*Help, error) {
return c.HelpWithContext(context.Background(), path)
}
// HelpWithContext reads the help information for the given path.
func (c *Client) HelpWithContext(ctx context.Context, path string) (*Help, error) {
ctx, cancelFunc := c.withConfiguredTimeout(ctx)
defer cancelFunc()
r := c.NewRequest("GET", fmt.Sprintf("/v1/%s", path))
r.Params.Add("help", "1")
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
resp, err := c.RawRequestWithContext(ctx, r)
resp, err := c.rawRequestWithContext(ctx, r)
if err != nil {
return nil, err
}