func BuildSecretsTable(config map[string]interface{}) (SecretsTable, error) {  
	errInvalidFormat := errors.New("path to the secret where your Docker credentials are stored " +
		"must be specified in either 'auto_auth.method.config.secret' or " +
		"'auto_auth.method.config.secrets', but not both")
	secretRaw, hasSecret := config["secret"]
	secretsRaw, hasSecrets := config["secrets"]
	if hasSecret && hasSecrets {
		return SecretsTable{}, errInvalidFormat
	}
	if hasSecret {
		return secretsTableFromString(secretRaw)
	} else if hasSecrets {
		return secretsTableFromMap(secretsRaw)
	}
	return SecretsTable{}, errInvalidFormat
}
BuildSecretsTable parses the auto_auth.method.secrets.config stanza
of the configuration file. The value of this field may be either a
string or a map[string]string.
package config
import (
	"errors"
	"fmt"
	"io/ioutil"
	"net/url"
	"os"
	"path/filepath"
	"strings"
	vaultconfig "github.com/hashicorp/vault/command/agent/config"
)
const noSinkHCLTemplate string = `
%s
cache {
        use_auto_auth_token = true
}
listener "tcp" {
	address     = "127.0.0.1:8100"
	tls_disable = true
}
`
const errNoSinkMsg = "auto_auth requires at least one sink or at least one template or cache.use_auto_auth_token=true"
type SecretsTable struct {
	oneSecret        string
	registryToSecret map[string]string
}
func (s SecretsTable) GetPath(registry string) (string, error) {
	if s.oneSecret != "" {
		return s.oneSecret, nil
	}
	registry = strings.ToLower(registry)
	if !strings.HasPrefix(registry, "http://") && !strings.HasPrefix(registry, "https://") {
		registry = "http://" + registry
	}
	u, err := url.Parse(registry)
	if err != nil {
		return "", err
	}
	registry = u.Hostname()
	if u.Port() != "" {
		registry = registry + ":" + u.Port()
	}
	secret, ok := s.registryToSecret[registry]
	if !ok {
		return "", errors.New("registry \"" + registry + "\" not found in configuration")
	}
	return secret, nil
}
func LoadConfig(configFile string) (*vaultconfig.Config, error) {  
	config, err := vaultconfig.LoadConfig(configFile)
	if err != nil {
		if err.Error() != errNoSinkMsg {
			return nil, err
		}
		var data []byte
		data, err = ioutil.ReadFile(configFile)  
		if err != nil {
			return nil, err
		}
		hcl := fmt.Sprintf(noSinkHCLTemplate, string(data))
		configFileBase := filepath.Base(configFile)
		var tempFile *os.File
		tempFile, err = ioutil.TempFile("", configFileBase+".*")
		if err != nil {
			return nil, err
		}
		defer os.Remove(tempFile.Name())
		if _, err = tempFile.Write([]byte(hcl)); err != nil {
			return nil, err
		}
		if err = tempFile.Close(); err != nil {
			return nil, err
		}
		config, err = vaultconfig.LoadConfig(tempFile.Name())
		if err != nil {
			return nil, err
		}
	}
	if config == nil {
		return nil, errors.New("no configuration found")
	}
	if config.AutoAuth == nil {
		return nil, errors.New("no 'auto_auth' block found in configuration file")
	}
	if err = validateSinks(config.AutoAuth.Sinks); err != nil {
		return nil, err
	}
	return config, nil
}