mirror of
https://github.com/containers/podman-compose.git
synced 2025-04-30 12:24:36 +02:00
Provide support for cache_from and cache_to fields
Signed-off-by: Felix Rubio <felix@kngnt.org>
This commit is contained in:
parent
0e3b372a29
commit
804852b218
1
newsfragments/cache-fields-support.feature
Normal file
1
newsfragments/cache-fields-support.feature
Normal file
@ -0,0 +1 @@
|
|||||||
|
Added support for cache_from and cache_to fields in build section.
|
@ -2519,6 +2519,10 @@ def container_to_build_args(compose, cnt, args, path_exists):
|
|||||||
"--build-arg",
|
"--build-arg",
|
||||||
build_arg,
|
build_arg,
|
||||||
))
|
))
|
||||||
|
for cache_img in build_desc.get("cache_from", []):
|
||||||
|
build_args.extend(["--cache-from", cache_img])
|
||||||
|
for cache_img in build_desc.get("cache_to", []):
|
||||||
|
build_args.extend(["--cache-to", cache_img])
|
||||||
build_args.append(ctx)
|
build_args.append(ctx)
|
||||||
return build_args
|
return build_args
|
||||||
|
|
||||||
|
@ -126,3 +126,33 @@ class TestContainerToBuildArgs(unittest.TestCase):
|
|||||||
'.',
|
'.',
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_caches(self):
|
||||||
|
c = create_compose_mock()
|
||||||
|
|
||||||
|
cnt = get_minimal_container()
|
||||||
|
cnt['build']['cache_from'] = ['registry/image1', 'registry/image2']
|
||||||
|
cnt['build']['cache_to'] = ['registry/image3', 'registry/image4']
|
||||||
|
args = get_minimal_args()
|
||||||
|
|
||||||
|
args = container_to_build_args(c, cnt, args, lambda path: True)
|
||||||
|
self.assertEqual(
|
||||||
|
args,
|
||||||
|
[
|
||||||
|
'-f',
|
||||||
|
'./Containerfile',
|
||||||
|
'-t',
|
||||||
|
'new-image',
|
||||||
|
'--no-cache',
|
||||||
|
'--pull-always',
|
||||||
|
'--cache-from',
|
||||||
|
'registry/image1',
|
||||||
|
'--cache-from',
|
||||||
|
'registry/image2',
|
||||||
|
'--cache-to',
|
||||||
|
'registry/image3',
|
||||||
|
'--cache-to',
|
||||||
|
'registry/image4',
|
||||||
|
'.',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user