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..48a178c41b 100644 --- a/kernelci/runtime/__init__.py +++ b/kernelci/runtime/__init__.py @@ -123,6 +123,25 @@ def match(self, filter_data): """Apply filters and return True if they match, False otherwise.""" return self.config.match(filter_data) + def get_docker_name(self, param): + """Get the docker image name with the correct prefix""" + 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 param: + imageurl = f'ghcr.io/kernelci/staging-{param}' + else: + # we need split image name and path + prefix = param.rsplit('/', 1)[0] + imagename = param.rsplit('/', 1)[1] + imageurl = f'{prefix}/staging-{imagename}' + else: + if '/' not in param: + imageurl = f'ghcr.io/kernelci/{param}' + else: + imageurl = param + return imageurl + def get_params(self, job, api_config=None): """Get job template parameters""" instanceid = os.environ.get('KCI_INSTANCE') @@ -147,6 +166,9 @@ def get_params(self, job, api_config=None): if not device_dtb: print(f"dtb file {job.platform_config.dtb} not found!") return None + + imageurl = self.get_docker_name(job.config.params.get('image')) + params = { 'api_config': api_config or {}, 'storage_config': job.storage_config or {}, @@ -156,7 +178,7 @@ def get_params(self, job, api_config=None): 'name': job.name, 'node': job.node, 'runtime': self.config.lab_type, - 'runtime_image': job.config.image, + 'runtime_image': imageurl, } if job.platform_config.params: params.update(job.platform_config.params)