diff --git a/internal/config/config.go b/internal/config/config.go index 4cbc4a2..180a826 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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 { diff --git a/internal/runconfig/runconfig.go b/internal/runconfig/runconfig.go index 4161fe7..2df222c 100644 --- a/internal/runconfig/runconfig.go +++ b/internal/runconfig/runconfig.go @@ -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{