job/osbuild: set AuthFilePath for container upload if provided

If a `AuthFilePath` was configured, which should contain secrets
to access container registries, we set this on the `Client` so
that the secrets can be used during registry access.
This commit is contained in:
Ygal Blum 2022-07-27 12:28:36 +03:00 committed by Tom Gundersen
parent 64a3aac895
commit 9f8df4313c
2 changed files with 17 additions and 12 deletions

View file

@ -41,11 +41,11 @@ type S3Configuration struct {
}
type ContainersConfiguration struct {
ContainerAuthFile string
Domain string
Account string
CertPath string
TLSVerify *bool
AuthFilePath string
Domain string
Account string
CertPath string
TLSVerify *bool
}
type OSBuildJobImpl struct {
@ -214,7 +214,12 @@ func (impl *OSBuildJobImpl) getContainerClient(destination string, targetOptions
return nil, err
}
if impl.ContainersConfig.AuthFilePath != "" {
client.SetAuthFilePath(impl.ContainersConfig.AuthFilePath)
}
if appliedDefaults {
if impl.ContainersConfig.CertPath != "" {
client.SetDockerCertPath(impl.ContainersConfig.CertPath)
}
@ -338,9 +343,9 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
}
var extraEnv []string
if impl.ContainersConfig.ContainerAuthFile != "" {
if impl.ContainersConfig.AuthFilePath != "" {
extraEnv = []string{
fmt.Sprintf("REGISTRY_AUTH_FILE=%s", impl.ContainersConfig.ContainerAuthFile),
fmt.Sprintf("REGISTRY_AUTH_FILE=%s", impl.ContainersConfig.AuthFilePath),
}
}

View file

@ -444,11 +444,11 @@ func main() {
SkipSSLVerification: genericS3SkipSSLVerification,
},
ContainersConfig: ContainersConfiguration{
ContainerAuthFile: containersAuthFilePath,
Domain: containersDomain,
Account: containersAccount,
CertPath: containersCertPath,
TLSVerify: &containersTLSVerify,
AuthFilePath: containersAuthFilePath,
Domain: containersDomain,
Account: containersAccount,
CertPath: containersCertPath,
TLSVerify: &containersTLSVerify,
},
},
worker.JobTypeKojiInit: &KojiInitJobImpl{