mirror of
https://github.com/containers/podman-compose.git
synced 2025-08-16 16:41:17 +02:00
Support additional_contexts
Signed-off-by: Otto Liljalaakso <otto.liljalaakso@novatron.fi>
This commit is contained in:
committed by
Povilas Kanapickas
parent
3bb305cef4
commit
cac836b0f5
14
tests/additional_contexts/README.md
Normal file
14
tests/additional_contexts/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
# Test podman-compose with build.additional_contexts
|
||||
|
||||
```
|
||||
podman-compose build
|
||||
podman-compose up
|
||||
podman-compose down
|
||||
```
|
||||
|
||||
expected output would be
|
||||
|
||||
```
|
||||
[dict] | Data for dict
|
||||
[list] | Data for list
|
||||
```
|
1
tests/additional_contexts/data_for_dict/data.txt
Normal file
1
tests/additional_contexts/data_for_dict/data.txt
Normal file
@ -0,0 +1 @@
|
||||
Data for dict
|
1
tests/additional_contexts/data_for_list/data.txt
Normal file
1
tests/additional_contexts/data_for_list/data.txt
Normal file
@ -0,0 +1 @@
|
||||
Data for list
|
3
tests/additional_contexts/project/Dockerfile
Normal file
3
tests/additional_contexts/project/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM busybox
|
||||
COPY --from=data data.txt /data/data.txt
|
||||
CMD ["busybox", "cat", "/data/data.txt"]
|
12
tests/additional_contexts/project/docker-compose.yml
Normal file
12
tests/additional_contexts/project/docker-compose.yml
Normal file
@ -0,0 +1,12 @@
|
||||
version: "3.7"
|
||||
services:
|
||||
dict:
|
||||
build:
|
||||
context: .
|
||||
additional_contexts:
|
||||
data: ../data_for_dict
|
||||
list:
|
||||
build:
|
||||
context: .
|
||||
additional_contexts:
|
||||
- data=../data_for_list
|
44
tests/test_podman_compose_additional_contexts.py
Normal file
44
tests/test_podman_compose_additional_contexts.py
Normal file
@ -0,0 +1,44 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
|
||||
"""Test how additional contexts are passed to podman."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
from .test_podman_compose import podman_compose_path
|
||||
from .test_podman_compose import test_path
|
||||
|
||||
|
||||
def compose_yaml_path():
|
||||
""" "Returns the path to the compose file used for this test module"""
|
||||
return os.path.join(test_path(), "additional_contexts", "project")
|
||||
|
||||
|
||||
class TestComposeBuildAdditionalContexts(unittest.TestCase):
|
||||
def test_build_additional_context(self):
|
||||
"""podman build should receive additional contexts as --build-context
|
||||
|
||||
See additional_context/project/docker-compose.yaml for context paths
|
||||
"""
|
||||
cmd = (
|
||||
"coverage",
|
||||
"run",
|
||||
podman_compose_path(),
|
||||
"--dry-run",
|
||||
"--verbose",
|
||||
"-f",
|
||||
os.path.join(compose_yaml_path(), "docker-compose.yml"),
|
||||
"build",
|
||||
)
|
||||
p = subprocess.run(
|
||||
cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
check=False,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True,
|
||||
)
|
||||
self.assertEqual(p.returncode, 0)
|
||||
self.assertIn("--build-context=data=../data_for_dict", p.stdout)
|
||||
self.assertIn("--build-context=data=../data_for_list", p.stdout)
|
Reference in New Issue
Block a user