func BuildSinks(sc []*config.Sink, logger hclog.Logger, client *api.Client) ([]*sink.SinkConfig, error) {
	sinks := make([]*sink.SinkConfig, 0, len(sc))
	for _, ss := range sc {
		switch ss.Type {
		case "file":
			config := &sink.SinkConfig{
				Logger:  logger.Named("sink.file"),
				Config:  ss.Config,
				Client:  client,
				WrapTTL: ss.WrapTTL,
				DHType:  ss.DHType,
				DHPath:  ss.DHPath,
				AAD:     ss.AAD,
			}
			s, err := file.NewFileSink(config)
			if err != nil {
				return nil, xerrors.Errorf("error creating file sink: %w", err)
			}
			config.Sink = s
			sinks = append(sinks, config)
		default:
			return nil, xerrors.Errorf("unknown sink type %q", ss.Type)
		}
	}
	return sinks, nil
}
BuildSinks creates a set of sinks from the sink configurations.
package vault
import (
	"fmt"
	"os"
	"path"
	"github.com/hashicorp/go-hclog"
	"github.com/hashicorp/vault/api"
	"github.com/hashicorp/vault/command/agent/auth"
	"github.com/hashicorp/vault/command/agent/auth/alicloud"
	"github.com/hashicorp/vault/command/agent/auth/approle"
	"github.com/hashicorp/vault/command/agent/auth/aws"
	"github.com/hashicorp/vault/command/agent/auth/azure"
	"github.com/hashicorp/vault/command/agent/auth/cert"
	"github.com/hashicorp/vault/command/agent/auth/cf"
	"github.com/hashicorp/vault/command/agent/auth/gcp"
	"github.com/hashicorp/vault/command/agent/auth/jwt"
	"github.com/hashicorp/vault/command/agent/auth/kubernetes"
	"github.com/hashicorp/vault/command/agent/config"
	"github.com/hashicorp/vault/command/agent/sink"
	"github.com/hashicorp/vault/command/agent/sink/file"
	"golang.org/x/xerrors"
)
func NewClient(  
	methodConfig *config.Method,
	vaultConfig *config.Vault,
) (*api.Client, error) {
	if vaultConfig != nil {
		if os.Getenv(api.EnvVaultAddress) == "" && vaultConfig.Address != "" {
			os.Setenv(api.EnvVaultAddress, vaultConfig.Address)
			defer os.Unsetenv(api.EnvVaultAddress)
		}
		if os.Getenv(api.EnvVaultCACert) == "" && vaultConfig.CACert != "" {
			os.Setenv(api.EnvVaultCACert, vaultConfig.CACert)
			defer os.Unsetenv(api.EnvVaultCACert)
		}
		if os.Getenv(api.EnvVaultCAPath) == "" && vaultConfig.CAPath != "" {
			os.Setenv(api.EnvVaultCAPath, vaultConfig.CAPath)
			defer os.Unsetenv(api.EnvVaultCAPath)
		}
		if os.Getenv(api.EnvVaultSkipVerify) == "" && vaultConfig.TLSSkipVerifyRaw != nil {
			os.Setenv(api.EnvVaultSkipVerify, fmt.Sprintf("%t", vaultConfig.TLSSkipVerify))
			defer os.Unsetenv(api.EnvVaultSkipVerify)
		}
		if os.Getenv(api.EnvVaultClientCert) == "" && vaultConfig.ClientCert != "" {
			os.Setenv(api.EnvVaultClientCert, vaultConfig.ClientCert)
			defer os.Unsetenv(api.EnvVaultClientCert)
		}
		if os.Getenv(api.EnvVaultClientKey) == "" && vaultConfig.ClientKey != "" {
			os.Setenv(api.EnvVaultClientKey, vaultConfig.ClientKey)
			defer os.Unsetenv(api.EnvVaultClientKey)
		}
	}
	clientConfig := api.DefaultConfig()
	if clientConfig.Error != nil {
		return nil, clientConfig.Error
	}
	client, err := api.NewClient(clientConfig)
	if err != nil {
		return nil, err
	}
	return configureToken(client, methodConfig)
}
func configureToken(client *api.Client, methodConfig *config.Method) (*api.Client, error) {
	switch methodConfig.Type {
	case "token":
		if client.Token() == "" {
			tokenRaw, ok := methodConfig.Config["token"]
			if !ok {
				return nil, xerrors.New("missing 'auto_auth.method.config.token' value")
			}
			token, ok := tokenRaw.(string)
			if !ok {
				return nil, xerrors.New("could not convert 'auto_auth.method.config.token' config value to string")
			}
			if token == "" {
				return nil, xerrors.New("'auto_auth.method.config.token' value is empty")
			}
			client.SetToken(token)
		}
	default:
		client.ClearToken()
	}
	return client, nil
}