mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
Add context-aware functions to vault/api (#14388)
This commit is contained in:
committed by
GitHub
parent
fea828993c
commit
8234a663e7
@@ -9,10 +9,24 @@ import (
|
||||
)
|
||||
|
||||
func (c *Sys) CapabilitiesSelf(path string) ([]string, error) {
|
||||
return c.Capabilities(c.c.Token(), path)
|
||||
return c.CapabilitiesSelfWithContext(context.Background(), path)
|
||||
}
|
||||
|
||||
func (c *Sys) CapabilitiesSelfWithContext(ctx context.Context, path string) ([]string, error) {
|
||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||
defer cancelFunc()
|
||||
|
||||
return c.CapabilitiesWithContext(ctx, c.c.Token(), path)
|
||||
}
|
||||
|
||||
func (c *Sys) Capabilities(token, path string) ([]string, error) {
|
||||
return c.CapabilitiesWithContext(context.Background(), token, path)
|
||||
}
|
||||
|
||||
func (c *Sys) CapabilitiesWithContext(ctx context.Context, token, path string) ([]string, error) {
|
||||
ctx, cancelFunc := c.c.withConfiguredTimeout(ctx)
|
||||
defer cancelFunc()
|
||||
|
||||
body := map[string]string{
|
||||
"token": token,
|
||||
"path": path,
|
||||
@@ -28,9 +42,7 @@ func (c *Sys) Capabilities(token, path string) ([]string, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
defer cancelFunc()
|
||||
resp, err := c.c.RawRequestWithContext(ctx, r)
|
||||
resp, err := c.c.rawRequestWithContext(ctx, r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user