From 4f3c833b9483dad2ab4c6da46eb12810544d3e9b Mon Sep 17 00:00:00 2001 From: Vishal Nayak Date: Mon, 21 Sep 2020 13:43:21 -0400 Subject: [PATCH] Vendor diff --- .../hashicorp/vault/sdk/framework/filter.go | 34 +++++++++++++++++++ .../helper/awsutil/generate_credentials.go | 4 +++ 2 files changed, 38 insertions(+) create mode 100644 vendor/github.com/hashicorp/vault/sdk/framework/filter.go diff --git a/vendor/github.com/hashicorp/vault/sdk/framework/filter.go b/vendor/github.com/hashicorp/vault/sdk/framework/filter.go new file mode 100644 index 000000000..e042b5390 --- /dev/null +++ b/vendor/github.com/hashicorp/vault/sdk/framework/filter.go @@ -0,0 +1,34 @@ +package framework + +import ( + "context" + "github.com/hashicorp/vault/sdk/logical" + "github.com/ryanuber/go-glob" +) + +// GlobListFilter wraps an OperationFunc with an optional filter which excludes listed entries +// which don't match a glob style pattern +func GlobListFilter(fieldName string, callback OperationFunc) OperationFunc { + return func(ctx context.Context, req *logical.Request, data *FieldData) (*logical.Response, error) { + resp, err := callback(ctx, req, data) + if err != nil { + return nil, err + } + + if keys, ok := resp.Data["keys"]; ok { + if entries, ok := keys.([]string); ok { + filter, ok := data.GetOk(fieldName) + if ok && filter != "" && filter != "*" { + var filteredEntries []string + for _, e := range entries { + if glob.Glob(filter.(string), e) { + filteredEntries = append(filteredEntries, e) + } + } + resp.Data["keys"] = filteredEntries + } + } + } + return resp, nil + } +} \ No newline at end of file diff --git a/vendor/github.com/hashicorp/vault/sdk/helper/awsutil/generate_credentials.go b/vendor/github.com/hashicorp/vault/sdk/helper/awsutil/generate_credentials.go index 66c599a88..f34f14454 100644 --- a/vendor/github.com/hashicorp/vault/sdk/helper/awsutil/generate_credentials.go +++ b/vendor/github.com/hashicorp/vault/sdk/helper/awsutil/generate_credentials.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go/aws/defaults" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sts" + "github.com/hashicorp/go-hclog" "github.com/pkg/errors" ) @@ -37,6 +38,9 @@ type CredentialsConfig struct { // The http.Client to use, or nil for the client to use its default HTTPClient *http.Client + + // The logger to use for credential acquisition debugging + Logger hclog.Logger } func (c *CredentialsConfig) GenerateCredentialChain() (*credentials.Credentials, error) {