0b44a55d22
* Adding support for Consul 1.4 ACL system * Working tests * Fixed logic gate * Fixed logical gate that evaluate empty policy or empty list of policy names * Ensure tests are run against appropiate Consul versions * Running tests against official container with a 1.4.0-rc1 tag * policies can never be nil (as even if it is empty will be an empty array) * addressing feedback, refactoring tests * removing cast * converting old lease field to ttl, adding max ttl * cleanup * adding missing test * testing wrong version * adding support for local tokens * addressing feedback
31 lines
681 B
Go
31 lines
681 B
Go
package consul
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/consul/api"
|
|
"github.com/hashicorp/vault/logical"
|
|
)
|
|
|
|
func (b *backend) client(ctx context.Context, s logical.Storage) (*api.Client, error, error) {
|
|
conf, userErr, intErr := b.readConfigAccess(ctx, s)
|
|
if intErr != nil {
|
|
return nil, nil, intErr
|
|
}
|
|
if userErr != nil {
|
|
return nil, userErr, nil
|
|
}
|
|
if conf == nil {
|
|
return nil, nil, fmt.Errorf("no error received but no configuration found")
|
|
}
|
|
|
|
consulConf := api.DefaultNonPooledConfig()
|
|
consulConf.Address = conf.Address
|
|
consulConf.Scheme = conf.Scheme
|
|
consulConf.Token = conf.Token
|
|
|
|
client, err := api.NewClient(consulConf)
|
|
return client, nil, err
|
|
}
|