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

@@ -1,6 +1,7 @@
package command
import (
"context"
"strings"
"testing"
@@ -22,13 +23,13 @@ func testLeaseLookupCommand(tb testing.TB) (*cli.MockUi, *LeaseLookupCommand) {
// testLeaseLookupCommandMountAndLease mounts a leased secret backend and returns
// the leaseID of an item.
func testLeaseLookupCommandMountAndLease(tb testing.TB, client *api.Client) string {
if err := client.Sys().Mount("testing", &api.MountInput{
if err := client.Sys().MountWithContext(context.Background(), "testing", &api.MountInput{
Type: "generic-leased",
}); err != nil {
tb.Fatal(err)
}
if _, err := client.Logical().Write("testing/foo", map[string]interface{}{
if _, err := client.Logical().WriteWithContext(context.Background(), "testing/foo", map[string]interface{}{
"key": "value",
"lease": "5m",
}); err != nil {
@@ -36,7 +37,7 @@ func testLeaseLookupCommandMountAndLease(tb testing.TB, client *api.Client) stri
}
// Read the secret back to get the leaseID
secret, err := client.Logical().Read("testing/foo")
secret, err := client.Logical().ReadWithContext(context.Background(), "testing/foo")
if err != nil {
tb.Fatal(err)
}