From 3daf36e342e81bac8d0d06ca9639a1a68b4b4b4e Mon Sep 17 00:00:00 2001 From: Denys Fedoryshchenko Date: Fri, 11 Oct 2024 15:40:03 +0300 Subject: [PATCH] fix(docker/k8s): Fix image naming We had previously hack with hardcoding ghcr.io. Now we make it more flexible, so people can set their own image url, and our staging instance automatically add staging- prefix in appropriate place. Signed-off-by: Denys Fedoryshchenko --- config/runtime/base/kubernetes.jinja2 | 2 +- kernelci/runtime/__init__.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/config/runtime/base/kubernetes.jinja2 b/config/runtime/base/kubernetes.jinja2 index bb31b36c1b..0f872e6efa 100644 --- a/config/runtime/base/kubernetes.jinja2 +++ b/config/runtime/base/kubernetes.jinja2 @@ -32,7 +32,7 @@ spec: containers: - name: kernelci - image: ghcr.io/{{ runtime_image }} + image: {{ runtime_image }} imagePullPolicy: Always volumeMounts: diff --git a/kernelci/runtime/__init__.py b/kernelci/runtime/__init__.py index b3ec8462f5..92740cf220 100644 --- a/kernelci/runtime/__init__.py +++ b/kernelci/runtime/__init__.py @@ -147,6 +147,23 @@ def get_params(self, job, api_config=None): if not device_dtb: print(f"dtb file {job.platform_config.dtb} not found!") return None + # we add a bit of advanced logic for docker image + instance = os.getenv('KCI_INSTANCE', 'prod') + if instance != 'prod': + # if we dont have '/' in the image name, we add the ghcr.io/ prefix + if '/' not in job.config.image: + imageurl = f'ghcr.io/kernelci/staging-{job.config.image}' + else: + # we need split image name and path + prefix = job.config.image.rsplit('/', 1)[0] + imagename = job.config.image.rsplit('/', 1)[1] + imageurl = f'{prefix}/staging-{imagename}' + else: + if '/' not in job.config.image: + imageurl = f'ghcr.io/kernelci/{job.config.image}' + else: + imageurl = job.config.image + params = { 'api_config': api_config or {}, 'storage_config': job.storage_config or {},