23 lines
500 B
Go
23 lines
500 B
Go
|
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
|
||
|
}
|