diff --git a/dnf/artifact-registry.py b/dnf/artifact-registry.py index cfff6853..931e22ff 100644 --- a/dnf/artifact-registry.py +++ b/dnf/artifact-registry.py @@ -33,9 +33,14 @@ def __init__(self, base, cli): def config(self): """ Setup http headers to repos with baseurl option containing pkg.dev. """ for repo in self.base.repos.iter_enabled(): + # Check if the 'artifact_registry_oauth' option is set in the repository's config. + if repo.cfg.has_option(repo.id, 'artifact_registry_oauth') and repo.cfg.getboolean(repo.id, 'artifact_registry_oauth'): + self._add_headers(repo) + break # Don't add more than one Authorization header. # We don't have baseurl option so skip it earlier. if not hasattr(repo, 'baseurl'): continue + # Check if any repo urls are for Artifact Registry. for baseurl in repo.baseurl: # We stop checking if an error has been flagged. if baseurl.startswith('https://') and '-yum.pkg.dev/' in baseurl and not self.error: diff --git a/yum/artifact-registry.py b/yum/artifact-registry.py index 1da037ac..f95bf7a5 100644 --- a/yum/artifact-registry.py +++ b/yum/artifact-registry.py @@ -27,6 +27,11 @@ def prereposetup_hook(conduit): if not token: return for repo in conduit.getRepos().listEnabled(): + # Check if the 'artifact_registry_oauth' option is set in the repository's config. + if repo.cfg.has_option(repo.id, 'artifact_registry_oauth') and repo.cfg.getboolean(repo.id, 'artifact_registry_oauth'): + _add_headers(token, repo) + break # Stop looking at URLs + # Check if any repo urls are for Artifact Registry. for url in repo.urls: if 'pkg.dev' in url and url.startswith('https://'): _add_headers(token, repo)