func (c *Config) GetRegistryAuth(registry string) string {
	username, password, defined := c.GetCredentials(registry)
	if !defined {
		return ""
	}
	authJSONString := getAuthJSONString(username, password)
	log.Debugf("JSON Auth String: %s", authJSONString)
	return base64.StdEncoding.EncodeToString(
		[]byte(authJSONString),
	)
}
GetRegistryAuth gets per-registry base64 authentication string
package config
import (
	"encoding/base64"
	"encoding/json"
	"fmt"
	"os"
	"strings"
	log "github.com/sirupsen/logrus"
	"github.com/ivanilves/lstags/docker/config/credhelper"
	"github.com/moby/moby/api/types"
	"github.com/ivanilves/lstags/util/fix"
)
var DefaultDockerJSON = "~/.docker/config.json"
type Config struct {
	Auths       map[string]Auth `json:"auths"`
	usernames   map[string]string
	passwords   map[string]string
	CredsStore  string            `json:"credsStore,omitempty"`
	CredHelpers map[string]string `json:"credHelpers,omitempty"`
}
type Auth struct {
	B64Auth string `json:"auth"`
}
func (c *Config) IsEmpty() bool {
	return len(c.Auths) == 0
}
func (c *Config) GetCredentials(registry string) (string, string, bool) {
	if _, defined := c.usernames[registry]; !defined {
		username, password, err := credhelper.GetCredentials(
			registry,
			c.CredsStore,
			c.CredHelpers,
		)
		if err != nil {
			return "", "", false
		}
		return username, password, true
	}
	return c.usernames[registry], c.passwords[registry], true
}
func getAuthJSONString(username, password string) string {
	b, err := json.Marshal(types.AuthConfig{
		Username: username,
		Password: password,
	})
	if err != nil {
		panic(err)
	}
	return string(b)
}