Skip to content

Commit 9312996

Browse files
committed
extract ui operator version
1 parent 74a278c commit 9312996

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

buildchain/buildchain/salt_tree.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,29 @@ def task(self) -> types.TaskDict:
201201

202202
def _download_ui_operator_crds() -> str:
203203
"""Download UI Operator CRDs from GitHub releases."""
204-
url = "https://github.com/scality/ui-operator/releases/download/0.1.1/ui-operator-crds-0.1.1.yaml"
205-
206-
with urllib.request.urlopen(url) as response:
207-
return response.read().decode('utf-8')
204+
url = (
205+
f"https://github.com/scality/ui-operator/releases/download/"
206+
f"{versions.UI_OPERATOR_VERSION}/ui-operator-crds-"
207+
f"{versions.UI_OPERATOR_VERSION}.yaml"
208+
)
209+
210+
try:
211+
with urllib.request.urlopen(url) as response:
212+
return str(response.read().decode("utf-8"))
213+
except urllib.error.HTTPError as error:
214+
if error.code == 404:
215+
raise RuntimeError(
216+
f"Failed to download UI Operator CRDs: File not found at {url}\n"
217+
f"Please ensure that UI Operator version {versions.UI_OPERATOR_VERSION} "
218+
f"has been released and the CRDs file is available."
219+
) from error
220+
raise RuntimeError(
221+
f"Failed to download UI Operator CRDs from {url}: HTTP {error.code}"
222+
) from error
223+
except urllib.error.URLError as error:
224+
raise RuntimeError(
225+
f"Failed to download UI Operator CRDs from {url}: {error.reason}"
226+
) from error
208227

209228

210229
PILLAR_FILES: Tuple[Union[Path, targets.AtomicTarget], ...] = (

buildchain/buildchain/versions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def load_version_information() -> None:
8686
NODEJS_IMAGE_VERSION: str = "20.11.1"
8787
KEEPALIVED_VERSION: str = "2.3.3"
8888
CERT_MANAGER_VERSION: str = "1.17.1"
89+
UI_OPERATOR_VERSION: str = "0.1.0"
8990

9091
# Current build IDs, to be augmented whenever we rebuild the corresponding
9192
# image, e.g. because the `Dockerfile` is changed, or one of the dependencies
@@ -268,7 +269,7 @@ def _version_prefix(version: str, prefix: str = "v") -> str:
268269
),
269270
Image(
270271
name="ui-operator",
271-
version="0.1.0",
272+
version=UI_OPERATOR_VERSION,
272273
digest="sha256:5a039b2f16fab190e26e21f27f2662752c0a0f2799afeb102df85b3cf605b754",
273274
),
274275
Image(

0 commit comments

Comments
 (0)