Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7965338
D236.1759516444.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D236.1759516444.diff
View Options
diff --git a/lilybuild/lilybuild/ci_steps.py b/lilybuild/lilybuild/ci_steps.py
--- a/lilybuild/lilybuild/ci_steps.py
+++ b/lilybuild/lilybuild/ci_steps.py
@@ -4,7 +4,7 @@
from buildbot.interfaces import IRenderable
from twisted.internet import defer
from .ci_syntax import ci_file
-from .helpers import rsync_rules_from_artifacts, get_job_script
+from .helpers import rsync_rules_from_artifacts, get_job_script, normalize_image
import re
import sys
import json
@@ -142,7 +142,7 @@
name='Run script in container',
command=[
'/lilybuild/podman-helper',
- job.image or self.default_image,
+ normalize_image(job.image or self.default_image),
self.src_relative,
self.script_dir,
self.result_relative,
diff --git a/lilybuild/lilybuild/helpers.py b/lilybuild/lilybuild/helpers.py
--- a/lilybuild/lilybuild/helpers.py
+++ b/lilybuild/lilybuild/helpers.py
@@ -68,3 +68,9 @@
'\n\n'.join(job.after_script) +
'\n\nexit 0'
)
+
+def normalize_image(image):
+ if isinstance(image, str):
+ return json.dumps({'name': image})
+ else:
+ return json.dumps(image)
diff --git a/lilybuild/lilybuild/tests/helpers_test.py b/lilybuild/lilybuild/tests/helpers_test.py
--- a/lilybuild/lilybuild/tests/helpers_test.py
+++ b/lilybuild/lilybuild/tests/helpers_test.py
@@ -9,6 +9,7 @@
ci_vars_to_cmds,
get_job_script,
DEFAULT_SCRIPT_HEADER,
+ normalize_image,
)
from lilybuild.tests.resources import get_res
@@ -128,5 +129,15 @@
exit 0''')
+class NormalizeImageTest(unittest.TestCase):
+ def test_str(self):
+ res = normalize_image('alpine')
+ self.assertEqual(json.loads(res), {'name': 'alpine'})
+
+ def test_object(self):
+ orig = {'name': 'alpine', 'entrypoint': ['/docker-run', '/bin/bb']}
+ res = normalize_image(orig)
+ self.assertEqual(json.loads(res), orig)
+
if __name__ == '__main__':
unittest.main()
diff --git a/lilybuild/podman-helper b/lilybuild/podman-helper
--- a/lilybuild/podman-helper
+++ b/lilybuild/podman-helper
@@ -127,19 +127,29 @@
local_dir,
], check=True)
+def image_to_podman_args(image):
+ name = image['name']
+ args = []
+ if 'entrypoint' in image:
+ # ci.json requires that the entrypoint is an array of strings
+ ep = json.dumps(image['entrypoint'])
+ args += ['--entrypoint', ep]
+ args += [name]
+ return args
+
def run_in_container(image, work_volname, script_volname):
timeout = 60 * 60 * 2 # 2 hours by default
p = verbose_run([
'podman', 'run', '--rm',
f'--mount=type=volume,source={work_volname},destination={work_vol_mount_dir}',
f'--mount=type=volume,source={script_volname},destination={script_vol_mount_dir}',
- image,
+ ] + image_to_podman_args(image) + [
script_name,
], timeout=timeout)
return p
def main():
- image = sys.argv[1]
+ image = json.loads(sys.argv[1])
work_dir = sys.argv[2]
script_dir = sys.argv[3]
result_dir = sys.argv[4]
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Oct 3, 11:34 AM (13 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
490645
Default Alt Text
D236.1759516444.diff (3 KB)
Attached To
Mode
D236: Support object format for image
Attached
Detach File
Event Timeline
Log In to Comment