zelda/backend/pkg/utils/docker.go

23 lines
500 B
Go
Raw Permalink Normal View History

2024-11-19 16:57:27 +08:00
package utils
import (
"encoding/base64"
"strings"
)
func NewDockerAuth(user, password string) DockerAuth {
return DockerAuth{
User: user,
Password: password,
AuthString: base64.StdEncoding.EncodeToString([]byte(strings.Join([]string{user, password}, ":"))),
}
}
func NewDockerConfig(server, user, password string) DockerConfig {
config := DockerConfig{
AuthDataMap: make(map[string]DockerAuth),
}
config.AuthDataMap[server] = NewDockerAuth(user, password)
return config
}