Skip to content

Commit

Permalink
fix(docker/k8s): Fix image naming
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nuclearcat committed Oct 11, 2024
1 parent ed2c354 commit 3daf36e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/runtime/base/kubernetes.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:

containers:
- name: kernelci
image: ghcr.io/{{ runtime_image }}
image: {{ runtime_image }}
imagePullPolicy: Always

volumeMounts:
Expand Down
17 changes: 17 additions & 0 deletions kernelci/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'

Check warning on line 155 in kernelci/runtime/__init__.py

View workflow job for this annotation

GitHub Actions / Lint

Unused variable 'imageurl'
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 {},
Expand Down

0 comments on commit 3daf36e

Please sign in to comment.