Skip to content

Commit 1d01a76

Browse files
committed
Allow beakerlib library without url/path
Without those keys we take the tmt tree to be the default value for the `path` Signed-off-by: Cristian Le <git@lecris.dev>
1 parent af1649b commit 1d01a76

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

tmt/libraries/beakerlib.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ def __init__(
7575
parent: Optional[tmt.utils.Common] = None,
7676
logger: tmt.log.Logger,
7777
) -> None:
78+
from tmt.steps.discover.fmf import (
79+
DiscoverFmf, # pyright: ignore[reportUnknownVariableType]
80+
)
81+
7882
super().__init__(parent=parent, logger=logger)
7983

8084
# Default branch is detected from the origin after cloning
@@ -111,9 +115,11 @@ def __init__(
111115
self.url = identifier.url
112116
self.path = identifier.path
113117
if not self.url and not self.path:
114-
raise tmt.utils.SpecificationError(
115-
"Need 'url' or 'path' to fetch a beakerlib library."
116-
)
118+
# Default the path to TMT_TREE for the cases where the beakerlib library is
119+
# next to the tmt metadata.
120+
# FIXME: it seems self.parent is always a `DiscoverFmf`?
121+
assert isinstance(self.parent, DiscoverFmf)
122+
self.path = self.parent.step.plan.worktree
117123
# Strip the '.git' suffix from url for known forges
118124
if self.url:
119125
for forge in STRIP_SUFFIX_FORGES:

tmt/schemas/common.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,6 @@ definitions:
146146
required:
147147
- type
148148

149-
anyOf:
150-
- required:
151-
- url
152-
- required:
153-
- path
154-
155149
# This would have been the easy way, understandable by newer jsonschema
156150
# packages.
157151
# url: true

0 commit comments

Comments
 (0)