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
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 @@ class CoprHelper:
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())
