Skip to content

Commit 5955c7d

Browse files
committed
feat(tools): Adjust generate script to update image resource
Signed-off-by: Jan Schoone <jan.schoone@uhurutec.com>
1 parent 953f8ef commit 5955c7d

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

hack/generate_version.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from pathlib import Path, PosixPath
2020

2121
import yaml
22+
import requests
2223

2324
BASE_PATH = Path(__file__).parent.parent
2425
SOURCE_PATH = BASE_PATH.joinpath("providers", "openstack", "scs")
@@ -238,12 +239,18 @@ def update_node_images(target: PosixPath, **kwargs):
238239

239240
# TODO: can this magic URL be 'removed'?
240241
# pylint: disable=locally-disabled, line-too-long
241-
url = f'https://swift.services.a.regiocloud.tech/swift/v1/AUTH_b182637428444b9aa302bb8d5a5a418c/openstack-k8s-capi-images/ubuntu-2204-kube-v{kwargs["kubernetes"][0:4]}/ubuntu-2204-kube-v{kwargs["kubernetes"]}.qcow2'
242-
content["openStackNodeImages"][0]["url"] = url
242+
url = f"https://swift.services.a.regiocloud.tech/swift/v1/AUTH_b182637428444b9aa302bb8d5a5a418c/openstack-k8s-capi-images/ubuntu-2204-kube-v{kwargs['kubernetes'][0:4]}/ubuntu-2204-kube-v{kwargs['kubernetes']}.qcow2"
243+
content["spec"]["resource"]["content"]["download"]["url"] = url
243244

244-
content["openStackNodeImages"][0]["createOpts"][
245-
"name"
246-
] = f"ubuntu-capi-image-v{kwargs['kubernetes']}"
245+
checksum_url = f"{url}.CHECKSUM"
246+
response = requests.get(checksum_url, timeout=30)
247+
response.raise_for_status()
248+
249+
checksum_line = response.text.strip()
250+
checksum = checksum_line.split()[0]
251+
252+
content["spec"]["resource"]["content"]["download"]["hash"]["value"] = checksum
253+
logger.info("Updated checksum: %s", checksum)
247254

248255
writefile(target, content)
249256

@@ -297,4 +304,6 @@ def update_node_images(target: PosixPath, **kwargs):
297304
)
298305
update_csctl_conf(output_dir.joinpath("csctl.yaml"), **tv)
299306
update_cluster_class(output_dir.joinpath("cluster-class"), **tv)
300-
update_node_images(output_dir.joinpath("node-images", "config.yaml"), **tv)
307+
update_node_images(
308+
output_dir.joinpath("cluster-class", "templates", "image.yaml"), **tv
309+
)

0 commit comments

Comments
 (0)