Skip to content

Commit

Permalink
feat(copr): add method for getting chroots
Browse files Browse the repository at this point in the history
Add method that returns set of chroots configured on the given Copr
project.

Related to packit/packit-service#1499

Signed-off-by: Matej Focko <[email protected]>
  • Loading branch information
mfocko committed Aug 24, 2022
1 parent fae3705 commit 8ea07bb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packit/copr_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())

0 comments on commit 8ea07bb

Please sign in to comment.