From 8ea07bb91c0823f4b673e21571992aad6f3536e0 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Tue, 23 Aug 2022 20:22:14 +0200 Subject: [PATCH] feat(copr): add method for getting chroots Add method that returns set of chroots configured on the given Copr project. Related to packit/packit-service#1499 Signed-off-by: Matej Focko --- packit/copr_helper.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packit/copr_helper.py b/packit/copr_helper.py index 61ad66795..374777190 100644 --- a/packit/copr_helper.py +++ b/packit/copr_helper.py @@ -4,7 +4,7 @@ import logging import time from datetime import datetime, timedelta -from typing import Callable, List, Optional, Dict, Tuple, Any +from typing import Callable, List, Optional, Dict, Tuple, Any, Set from cachetools.func import ttl_cache from copr.v3 import Client as CoprClient @@ -396,3 +396,19 @@ def get_repo_download_url(self, owner: str, project: str, chroot: str) -> str: raise PackitCoprProjectException( f"There is no such target {chroot} in {owner}/{project}." ) + + def get_chroots(self, owner: str, project: str) -> Set[str]: + """ + Get chroots set on a specific project. + + Args: + owner: Owner of the Copr project. + project: Name of the Copr project. + + Returns: + Set of all enabled chroots on the requested Copr project. + """ + copr_project = self.copr_client.project_proxy.get( + ownername=owner, projectname=project + ) + return set(copr_project.chroot_repos.keys())