mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-14 14:02:33 +08:00
support dockerhub credentials when pulling with kaniko-ecr (#27)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type (
|
||||
Auth struct {
|
||||
Auth string `json:"auth"`
|
||||
}
|
||||
|
||||
Config struct {
|
||||
Auths map[string]Auth `json:"auths"`
|
||||
CredHelpers map[string]string `json:"credHelpers"`
|
||||
}
|
||||
)
|
||||
|
||||
func NewConfig() *Config {
|
||||
return &Config{
|
||||
Auths: map[string]Auth{},
|
||||
CredHelpers: map[string]string{},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) SetAuth(registry, username, password string) {
|
||||
authBytes := []byte(fmt.Sprintf("%s:%s", username, password))
|
||||
encodedString := base64.StdEncoding.EncodeToString(authBytes)
|
||||
c.Auths[registry] = Auth{Auth: encodedString}
|
||||
}
|
||||
|
||||
func (c *Config) SetCredHelper(registry, helper string) {
|
||||
c.CredHelpers[registry] = helper
|
||||
}
|
||||
Reference in New Issue
Block a user