config/runconfig: add global docker registries auth

This commit is contained in:
Simone Gotti 2019-05-10 11:45:00 +02:00
parent 59e4a1f0ba
commit ba5399b97e
2 changed files with 19 additions and 0 deletions

View File

@ -51,6 +51,8 @@ var (
type Config struct {
Runs []*Run `json:"runs"`
DockerRegistriesAuth map[string]*DockerRegistryAuth `json:"docker_registries_auth"`
}
type RuntimeType string
@ -773,6 +775,12 @@ func checkConfig(config *Config) error {
}
// Set defaults
for _, registryAuth := range config.DockerRegistriesAuth {
if registryAuth.Type == "" {
registryAuth.Type = DockerRegistryAuthTypeBasic
}
}
for _, run := range config.Runs {
// set auth type to basic if not specified
for _, registryAuth := range run.DockerRegistriesAuth {

View File

@ -206,6 +206,17 @@ func GenRunConfigTasks(uuid util.UUIDGenerator, c *config.Config, runName string
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 {
for regname, auth := range cr.DockerRegistriesAuth {
t.DockerRegistriesAuth[regname] = rstypes.DockerRegistryAuth{