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
This commit is contained in:
Brian C. Lane 2025-01-23 16:43:16 -08:00 committed by Tomáš Hozza
parent cc79ad15e5
commit 84c0f79286

View file

@ -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])
}
}
}