From 84c0f792860da2bfcf938574a39c0a8345305ec9 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 23 Jan 2025 16:43:16 -0800 Subject: [PATCH] osbuild-worker: Add helper to setup Repo SSL This same operation will be done in a few places, turn it into a function. Related: RHEL-60136 --- cmd/osbuild-worker/jobimpl-depsolve.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/osbuild-worker/jobimpl-depsolve.go b/cmd/osbuild-worker/jobimpl-depsolve.go index 36216e806..48e394c21 100644 --- a/cmd/osbuild-worker/jobimpl-depsolve.go +++ b/cmd/osbuild-worker/jobimpl-depsolve.go @@ -24,6 +24,13 @@ type RepositoryMTLSConfig struct { Proxy *url.URL } +// SetupRepoSSL copies the CA, Key, and Cert to the RepoConfig +func (rmc *RepositoryMTLSConfig) SetupRepoSSL(repo *rpmmd.RepoConfig) { + repo.SSLCACert = rmc.CA + repo.SSLClientKey = rmc.MTLSClientKey + repo.SSLClientCert = rmc.MTLSClientCert +} + func (rmc *RepositoryMTLSConfig) CompareBaseURL(baseURLStr string) (bool, error) { baseURL, err := url.Parse(baseURLStr) if err != nil { @@ -139,9 +146,7 @@ func (impl *DepsolveJobImpl) Run(job worker.Job) error { return err } if match { - args.PackageSets[pkgsetsi][pkgseti].Repositories[repoi].SSLCACert = impl.RepositoryMTLSConfig.CA - args.PackageSets[pkgsetsi][pkgseti].Repositories[repoi].SSLClientKey = impl.RepositoryMTLSConfig.MTLSClientKey - args.PackageSets[pkgsetsi][pkgseti].Repositories[repoi].SSLClientCert = impl.RepositoryMTLSConfig.MTLSClientCert + impl.RepositoryMTLSConfig.SetupRepoSSL(&args.PackageSets[pkgsetsi][pkgseti].Repositories[repoi]) } } }