Vendor diff
This commit is contained in:
parent
9eb1fb1df4
commit
4f3c833b94
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue