config/runconfig: add global docker registries auth
This commit is contained in:
parent
59e4a1f0ba
commit
ba5399b97e
|
@ -51,6 +51,8 @@ var (
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Runs []*Run `json:"runs"`
|
Runs []*Run `json:"runs"`
|
||||||
|
|
||||||
|
DockerRegistriesAuth map[string]*DockerRegistryAuth `json:"docker_registries_auth"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RuntimeType string
|
type RuntimeType string
|
||||||
|
@ -773,6 +775,12 @@ func checkConfig(config *Config) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
|
for _, registryAuth := range config.DockerRegistriesAuth {
|
||||||
|
if registryAuth.Type == "" {
|
||||||
|
registryAuth.Type = DockerRegistryAuthTypeBasic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, run := range config.Runs {
|
for _, run := range config.Runs {
|
||||||
// set auth type to basic if not specified
|
// set auth type to basic if not specified
|
||||||
for _, registryAuth := range run.DockerRegistriesAuth {
|
for _, registryAuth := range run.DockerRegistriesAuth {
|
||||||
|
|
|
@ -206,6 +206,17 @@ func GenRunConfigTasks(uuid util.UUIDGenerator, c *config.Config, runName string
|
||||||
DockerRegistriesAuth: make(map[string]rstypes.DockerRegistryAuth),
|
DockerRegistriesAuth: make(map[string]rstypes.DockerRegistryAuth),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.DockerRegistriesAuth != nil {
|
||||||
|
for regname, auth := range c.DockerRegistriesAuth {
|
||||||
|
t.DockerRegistriesAuth[regname] = rstypes.DockerRegistryAuth{
|
||||||
|
Type: rstypes.DockerRegistryAuthType(auth.Type),
|
||||||
|
Username: genValue(auth.Username, variables),
|
||||||
|
Password: genValue(auth.Password, variables),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// override with per run docker registry auth
|
||||||
if cr.DockerRegistriesAuth != nil {
|
if cr.DockerRegistriesAuth != nil {
|
||||||
for regname, auth := range cr.DockerRegistriesAuth {
|
for regname, auth := range cr.DockerRegistriesAuth {
|
||||||
t.DockerRegistriesAuth[regname] = rstypes.DockerRegistryAuth{
|
t.DockerRegistriesAuth[regname] = rstypes.DockerRegistryAuth{
|
||||||
|
|
Loading…
Reference in New Issue