mirror of
https://github.com/containers/podman-compose.git
synced 2025-07-01 13:10:24 +02:00
Compare commits
497 Commits
devel-asyn
...
v1.4.0
Author | SHA1 | Date | |
---|---|---|---|
bd29caa797 | |||
f0928dd399 | |||
6c9c09197a | |||
cda84f439f | |||
67616bdaac | |||
7497692b19 | |||
782c44d4c3 | |||
d7762a54f0 | |||
eba2ca2695 | |||
abe5965c9a | |||
9e0da82726 | |||
6acdafd5b1 | |||
8638eb9b6d | |||
e1d938ffa6 | |||
d532e09d7d | |||
1dab256cdd | |||
2a33ef5c79 | |||
5ab734026c | |||
35dc395483 | |||
38a9263424 | |||
cbe9587973 | |||
8bb43100b1 | |||
98f166d2e4 | |||
150ab02446 | |||
ff58a0bff0 | |||
8d899ebb65 | |||
342a39dcfe | |||
d6b8476573 | |||
ae41ef08c3 | |||
da46ee3910 | |||
d80c31f578 | |||
cefa68dc75 | |||
2e46ff0db2 | |||
fbc4c7da80 | |||
11879d3e94 | |||
27cf8da06f | |||
10a30ba24a | |||
a1be62fd31 | |||
15bf02a004 | |||
e45b5d5063 | |||
c46ecb226b | |||
e04b8f3a60 | |||
815450aba9 | |||
92f0a8583a | |||
5f4fc4618c | |||
4d899edeb3 | |||
f9489afaf5 | |||
7d7533772b | |||
65b455f081 | |||
1aa750bacf | |||
98b9bb9f8e | |||
170411de8b | |||
0cf1378cb5 | |||
f5a6df6dc4 | |||
f106ea0c01 | |||
b748c2666c | |||
3973c476c4 | |||
8b1bd0123c | |||
2e7d83f7f0 | |||
52e2912e0b | |||
8ef537e247 | |||
04fcc26a79 | |||
d4760712b7 | |||
7c61f24467 | |||
202c3771a9 | |||
a54f0fa573 | |||
3353697402 | |||
ca1b59c449 | |||
b9f27795c0 | |||
4cd1642be0 | |||
fd401331e5 | |||
37b27fa233 | |||
976847ef9b | |||
c6b3d497d6 | |||
10ad739746 | |||
784d798dac | |||
dd01d039bf | |||
81a0a5933e | |||
c289a3b827 | |||
baccce4f3f | |||
07af8488db | |||
cbc5a8c8b3 | |||
aeaceed7ba | |||
b1eb558b41 | |||
1cdc9e6552 | |||
2f8ed2137c | |||
838957b902 | |||
15380a809d | |||
d4e5859370 | |||
593d7c825e | |||
bfba7ba32d | |||
fe9be2d98f | |||
43a2f1d01f | |||
aa47a373ca | |||
eaec19336f | |||
34bee28bb8 | |||
bfea139362 | |||
4a81bce2a5 | |||
e626f15eff | |||
974250caa5 | |||
29404af723 | |||
d1ba2f4c7d | |||
e03d675b9b | |||
51d180d2d0 | |||
9c905f9012 | |||
bdb3e4e984 | |||
105e390f6b | |||
d79ff01e77 | |||
d9ef3d2cc6 | |||
d23ef4f481 | |||
b685bce400 | |||
7d5bf645f6 | |||
9f7ae38bac | |||
3cee4e015c | |||
498a1994ce | |||
488908f809 | |||
f7bcc4221e | |||
a73df712cc | |||
50dc19f5f8 | |||
9029dce0f6 | |||
a8282c77d6 | |||
f4b775c7e4 | |||
adf30e0475 | |||
41675c3916 | |||
6caf2eae42 | |||
3093b00326 | |||
1c21d655ba | |||
18e5fd64f3 | |||
24bdfd1e17 | |||
c2d3e156c2 | |||
ba95100cff | |||
6022669991 | |||
e29df71d42 | |||
21b9d385b2 | |||
4c17ce2434 | |||
09d54e9dcc | |||
f1dd9b374e | |||
87af67fe94 | |||
f1d663874e | |||
69ffff33f6 | |||
f376700972 | |||
9be3ec985f | |||
6e642dca1f | |||
0f2c717655 | |||
2aa042b9c7 | |||
a177603661 | |||
bc4177fbdc | |||
8206cc3ea2 | |||
60ac5e43b3 | |||
48c6c38fcd | |||
84f1fbd622 | |||
ac5291e10b | |||
9cbc4c1dcd | |||
c63d678887 | |||
6de335beb2 | |||
23799245bd | |||
eda4815715 | |||
cbb0cab814 | |||
7c8696b2b2 | |||
483103ac3a | |||
e9f1029406 | |||
804852b218 | |||
0e3b372a29 | |||
f11e08eaac | |||
62789a2358 | |||
35cf4bcb72 | |||
9964604b17 | |||
61fa24bf21 | |||
ac7ec5c166 | |||
75d7be2b7b | |||
346f7a57f0 | |||
55642247e3 | |||
978a1381bc | |||
4a232f5e32 | |||
aa8c6fd598 | |||
fb0bbd6fe1 | |||
b324029f25 | |||
590c371db2 | |||
16196a1f6d | |||
2dfbb59097 | |||
a34d1d1a31 | |||
d6da65e6c9 | |||
de2c33d7ae | |||
2891be01d7 | |||
a023dc145b | |||
d803c4c3e8 | |||
420d19daf4 | |||
2cfc617f9e | |||
376f0817e6 | |||
054c66b568 | |||
d9fc8e91f2 | |||
145ae47c48 | |||
a67fa0beb5 | |||
3ba0396e7a | |||
973e15ba23 | |||
002c2e400b | |||
626e278794 | |||
a358890d54 | |||
9f3251ff3d | |||
a9cfdb6704 | |||
c0dc3e47fd | |||
41e69be201 | |||
4ae6ccb5c0 | |||
4203f799ee | |||
69e95be2f6 | |||
122a914b9b | |||
db0aad97bd | |||
a3fb4b373a | |||
ab33954f6c | |||
4660feb04a | |||
90f54b9ca5 | |||
7090de3bce | |||
df8fa588a5 | |||
e2ae8bee04 | |||
5c81bbfcb7 | |||
22b0c4b348 | |||
380cf42dcd | |||
deed4d51b0 | |||
08b3ac2633 | |||
f8ea85e3af | |||
0de7e13f1a | |||
da7fd4fe86 | |||
cb294d7519 | |||
351858dbec | |||
8d0dd214ae | |||
229650cba8 | |||
ab832d23c7 | |||
4a7329b9e3 | |||
de3f93c491 | |||
54cc055a5c | |||
f4bf69b68e | |||
5297b004af | |||
fd1fc833b0 | |||
124879a7b9 | |||
368efe2ee3 | |||
eeefd37996 | |||
b7514a0647 | |||
561094954d | |||
ea239c4b77 | |||
9fdee76858 | |||
0a6e0a35e1 | |||
26e6651d6c | |||
462603383c | |||
8411db49d1 | |||
fc90f60bf1 | |||
ed58ac0879 | |||
305f25b4d6 | |||
edadf73d82 | |||
dc04108b3e | |||
348461ca77 | |||
92dbd3690e | |||
a1e9a82693 | |||
9e11c6bfbc | |||
0d24c41afb | |||
585d344d0a | |||
3aa6d4d158 | |||
34f5268e37 | |||
b5eaf314ad | |||
b3c49df6eb | |||
dbbd695463 | |||
1b1d3d8c25 | |||
7d7e64fe5a | |||
3c9c18c6e0 | |||
d0a2a44442 | |||
1e66c28bbb | |||
b6eadd56b1 | |||
d95b4d026b | |||
e2eb883709 | |||
0866492a7e | |||
85050097e5 | |||
daab93b762 | |||
9fe30387ee | |||
0f8348bea7 | |||
55ab3fa7f7 | |||
2091ade7b1 | |||
ca58d7cd58 | |||
3296c8d34f | |||
dab6b1b98d | |||
5bf4c0fdbe | |||
67c5352c3a | |||
5e0f7e5e19 | |||
5040a37d47 | |||
c82859b89f | |||
29195be77c | |||
1c74d6cd11 | |||
9a4af0ce62 | |||
0517b9e34c | |||
24038dace3 | |||
0ea4cbe091 | |||
2056e703d5 | |||
137c6207b2 | |||
4ec57c1013 | |||
d9a3572461 | |||
fa3e0a7772 | |||
0bcf0799b6 | |||
18472b53ac | |||
d38b26bb01 | |||
22a4ad5806 | |||
37e2cb28d4 | |||
0cd3902c5f | |||
6ef759c6fd | |||
16cbcf4152 | |||
67ce900885 | |||
4e9f76768c | |||
84f7fdd7da | |||
405001b990 | |||
6b1aeff55f | |||
f06975b346 | |||
546cad5171 | |||
e07c28d127 | |||
935029dc33 | |||
80b2aa6ed0 | |||
360b85bf2d | |||
650a835eca | |||
82740cc311 | |||
0f645e4c70 | |||
3b15170ccf | |||
3359380ec6 | |||
14f39e5b86 | |||
e799a0b0ea | |||
6d8d3e94fe | |||
65d1fdeaa3 | |||
d905a7c638 | |||
2e8ed2f924 | |||
040b73adab | |||
f3e9a96c96 | |||
04b107805a | |||
2c5d00d3e7 | |||
cac90f69b8 | |||
b513f50f30 | |||
8f618b6fab | |||
cac836b0f5 | |||
3bb305cef4 | |||
09034a0c38 | |||
e668a339ce | |||
0065082db9 | |||
5d4de80ab7 | |||
23ad5c3ef7 | |||
45efe461b0 | |||
4f73f2b79e | |||
1d64f2cf8c | |||
2ce6d1a1e7 | |||
4e22faefd6 | |||
7a2da76ab8 | |||
79865c2e13 | |||
33d7d35a4d | |||
c23a8b2cbd | |||
36a3d3c207 | |||
b202a09501 | |||
35cbc49160 | |||
5c4aa40032 | |||
0ee7c2630a | |||
cef1785cd5 | |||
b4cfef12e9 | |||
b761050b0b | |||
e1d0ea7b4e | |||
1430578568 | |||
8f41cd3cdb | |||
a73dac2e39 | |||
d31a8b124d | |||
5df4e786ee | |||
27e27e9fe9 | |||
70a0e2d003 | |||
58641f0545 | |||
eea8bac496 | |||
09a8a3edf9 | |||
a6c4263738 | |||
9599cc039e | |||
0a6c057486 | |||
2b4ecee082 | |||
77f2e8e5b0 | |||
12d46ca836 | |||
72a94d5185 | |||
2681566580 | |||
62ce087c6e | |||
c97f003732 | |||
c88558b4ec | |||
131010bc9d | |||
1da2f85a90 | |||
cdcedeb6b2 | |||
3e1f7d554b | |||
d7cf0966d3 | |||
e893d06313 | |||
1f35c00694 | |||
9a5b43907f | |||
6c09ce710e | |||
953534a71a | |||
6feff244db | |||
9fd4cf43c1 | |||
65849c95e2 | |||
9baea704d7 | |||
bdff78dcba | |||
45ca1f994f | |||
91fbea3d89 | |||
2743d690d2 | |||
dd34a90068 | |||
6103df78fb | |||
07128f6b37 | |||
f0bae1e2d9 | |||
81d81fb303 | |||
b263dc1a7d | |||
078ee7b649 | |||
a6e3ae7b31 | |||
1e9cf1dff0 | |||
d704622522 | |||
bbfff78e25 | |||
abb0cb1649 | |||
d53df307f8 | |||
c351f99da5 | |||
829cde0de9 | |||
f18c8092cc | |||
43059dc16f | |||
da63048775 | |||
7987a7185e | |||
5e55df890c | |||
fde7995cb8 | |||
c592596a5e | |||
688ee9a104 | |||
c3a152e68f | |||
bd60bc9f21 | |||
9d8b0b8632 | |||
ee013316c0 | |||
f2f5483a74 | |||
c4fa8f7a16 | |||
4c270b9116 | |||
c5f7f550f9 | |||
c98cbaaaf0 | |||
f2f2f15a3b | |||
91d316ff1f | |||
121b5f6ea1 | |||
969edb88d0 | |||
bba1f33d51 | |||
970e4ac4ab | |||
a9c335bf82 | |||
e67c52f2c4 | |||
e0fc9a7546 | |||
2cdfb3e6d4 | |||
60137eb7f9 | |||
a7a993faef | |||
8ec5e0372a | |||
da520e299b | |||
1e9e2ee776 | |||
dcb6cdb55a | |||
0f693ee584 | |||
d468f85fd1 | |||
cf90ab2858 | |||
d2fa80196f | |||
247774822c | |||
6e65a73ab9 | |||
f95ca7aca7 | |||
cdf5961bf2 | |||
0c0e77c246 | |||
e6fc585702 | |||
bb2338e447 | |||
a8db898ac6 | |||
1ba1c364b9 | |||
15ae2140d4 | |||
ed39523342 | |||
4e43606df3 | |||
91052cb2d9 | |||
a6e0092627 | |||
59a1fa3942 | |||
36139fb282 | |||
b0da6f82d3 | |||
b1e4324d41 | |||
94df95acea | |||
3a5a283cf6 | |||
16a90e2bce | |||
7c81044860 | |||
5b571942e0 | |||
de8f545f07 | |||
1a24cde608 | |||
a90da4dfaf | |||
6841619b9c | |||
27c8cebbdc | |||
c84b4c33fc | |||
0614687840 | |||
a494f20e15 | |||
6af7a2d691 | |||
872664b727 | |||
f4dc5f3b93 | |||
ac5034065d | |||
b34f699adb | |||
3d68d2432d | |||
2c6c1be197 | |||
f81cbe39b5 | |||
91737ee0a6 | |||
9d1407ba90 | |||
b65d4a3916 | |||
23fe9e7e1d | |||
7539257ee8 | |||
9e29891aa7 | |||
a967cab02b | |||
a5c354d60b | |||
e4e5b7d461 | |||
e0edd5dac1 | |||
c31b4e2816 |
1
.codespellignore
Normal file
1
.codespellignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
assertIn
|
4
.codespellrc
Normal file
4
.codespellrc
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[codespell]
|
||||||
|
skip = .git,*.pdf,*.svg,requirements.txt,test-requirements.txt
|
||||||
|
# poped - loved variable name
|
||||||
|
ignore-words-list = poped
|
19
.editorconfig
Normal file
19
.editorconfig
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = tab
|
||||||
|
tab_width = 4
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
max_line_length = 100
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.py]
|
||||||
|
indent_style = space
|
||||||
|
|
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -13,8 +13,6 @@ A clear and concise description of what the bug is.
|
|||||||
Please make sure it's not a bug in podman (in that case report it to podman)
|
Please make sure it's not a bug in podman (in that case report it to podman)
|
||||||
or your understanding of docker-compose or how rootless containers work (for example, it's normal for rootless container not to be able to listen for port less than 1024 like 80)
|
or your understanding of docker-compose or how rootless containers work (for example, it's normal for rootless container not to be able to listen for port less than 1024 like 80)
|
||||||
|
|
||||||
please try to reproduce the bug in latest devel branch
|
|
||||||
|
|
||||||
**To Reproduce**
|
**To Reproduce**
|
||||||
Steps to reproduce the behavior:
|
Steps to reproduce the behavior:
|
||||||
1. what is the content of the current working directory (ex. `docker-compose.yml`, `.env`, `Dockerfile`, ...etc.)
|
1. what is the content of the current working directory (ex. `docker-compose.yml`, `.env`, `Dockerfile`, ...etc.)
|
||||||
|
10
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
10
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
## Contributor Checklist:
|
||||||
|
|
||||||
|
If this PR adds a new feature that improves compatibility with docker-compose, please add a link
|
||||||
|
to the exact part of compose spec that the PR touches.
|
||||||
|
|
||||||
|
For any user-visible change please add a release note to newsfragments directory, e.g.
|
||||||
|
newsfragments/my_feature.feature. See newsfragments/README.md for more details.
|
||||||
|
|
||||||
|
All changes require additional unit tests.
|
22
.github/workflows/codespell.yml
vendored
Normal file
22
.github/workflows/codespell.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
name: Codespell
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
codespell:
|
||||||
|
name: Check for spelling errors
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Codespell
|
||||||
|
uses: codespell-project/actions-codespell@v2
|
||||||
|
with:
|
||||||
|
ignore_words_file: .codespellignore
|
41
.github/workflows/pylint.yml
vendored
41
.github/workflows/pylint.yml
vendored
@ -1,41 +0,0 @@
|
|||||||
name: Pylint
|
|
||||||
|
|
||||||
on:
|
|
||||||
- push
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint-black:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Install psf/black requirements
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y python3 python3-venv
|
|
||||||
- uses: psf/black@stable
|
|
||||||
with:
|
|
||||||
options: "--check --verbose"
|
|
||||||
version: "~= 23.3"
|
|
||||||
|
|
||||||
lint-pylint:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
||||||
pip install pylint
|
|
||||||
- name: Analysing the code with pylint
|
|
||||||
run: |
|
|
||||||
python -m compileall podman_compose.py
|
|
||||||
pylint podman_compose.py
|
|
||||||
# pylint $(git ls-files '*.py')
|
|
39
.github/workflows/pytest.yml
vendored
39
.github/workflows/pytest.yml
vendored
@ -1,39 +0,0 @@
|
|||||||
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
|
||||||
|
|
||||||
name: PyTest
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ devel ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ devel ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Set up Python 3.10
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: "3.10"
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt update && apt install podman
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
||||||
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi
|
|
||||||
- name: Lint with flake8
|
|
||||||
run: |
|
|
||||||
# stop the build if there are Python syntax errors or undefined names
|
|
||||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
||||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
|
||||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
||||||
- name: Test with pytest
|
|
||||||
run: |
|
|
||||||
coverage run --source podman_compose -m pytest ./pytests
|
|
||||||
python -m pytest ./tests
|
|
||||||
coverage combine
|
|
||||||
coverage report
|
|
27
.github/workflows/release.yml
vendored
Normal file
27
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
name: Build and Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build binary
|
||||||
|
run: |
|
||||||
|
mkdir -p release/
|
||||||
|
docker build -t podman-compose-bin -v "$PWD/release:/result" .
|
||||||
|
mv "$PWD/release/podman-compose" "$PWD/release/podman-compose-linux-x86"
|
||||||
|
|
||||||
|
- name: Upload release asset
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
files: ./release/podman-compose-linux-x86
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
25
.github/workflows/static-checks.yml
vendored
Normal file
25
.github/workflows/static-checks.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
name: Static checks
|
||||||
|
|
||||||
|
on:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
static-checks:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: docker.io/library/python:3.11-bookworm
|
||||||
|
# cgroupns needed to address the following error:
|
||||||
|
# write /sys/fs/cgroup/cgroup.subtree_control: operation not supported
|
||||||
|
options: --privileged --cgroupns=host
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Analysing the code with ruff
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
pip install -r test-requirements.txt
|
||||||
|
ruff format --check
|
||||||
|
ruff check
|
||||||
|
- name: Analysing the code with pylint
|
||||||
|
run: |
|
||||||
|
pylint podman_compose.py
|
40
.github/workflows/test.yml
vendored
Normal file
40
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
name: Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: "docker.io/library/python:${{ matrix.python-version }}-bookworm"
|
||||||
|
# cgroupns needed to address the following error:
|
||||||
|
# write /sys/fs/cgroup/cgroup.subtree_control: operation not supported
|
||||||
|
options: --privileged --cgroupns=host
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y podman
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pip install -r test-requirements.txt
|
||||||
|
- name: Run integration tests
|
||||||
|
run: |
|
||||||
|
python -m unittest discover -v tests/integration
|
||||||
|
env:
|
||||||
|
TESTS_DEBUG: 1
|
||||||
|
- name: Run unit tests
|
||||||
|
run: |
|
||||||
|
coverage run --source podman_compose -m unittest discover tests/unit
|
||||||
|
- name: Report coverage
|
||||||
|
run: |
|
||||||
|
coverage combine
|
||||||
|
coverage report --format=markdown | tee -a $GITHUB_STEP_SUMMARY
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -47,6 +47,8 @@ coverage.xml
|
|||||||
*.cover
|
*.cover
|
||||||
.hypothesis/
|
.hypothesis/
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
|
test-compose.yaml
|
||||||
|
test-compose-?.yaml
|
||||||
|
|
||||||
# Translations
|
# Translations
|
||||||
*.mo
|
*.mo
|
||||||
@ -103,3 +105,6 @@ venv.bak/
|
|||||||
|
|
||||||
# mypy
|
# mypy
|
||||||
.mypy_cache/
|
.mypy_cache/
|
||||||
|
|
||||||
|
|
||||||
|
.vscode
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
|
default_install_hook_types: [pre-commit, commit-msg]
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: 23.3.0
|
rev: v0.9.6
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: ruff
|
||||||
# It is recommended to specify the latest version of Python
|
|
||||||
# supported by your project here, or alternatively use
|
|
||||||
# pre-commit's default_language_version, see
|
|
||||||
# https://pre-commit.com/#top_level-default_language_version
|
|
||||||
language_version: python3.10
|
|
||||||
types: [python]
|
types: [python]
|
||||||
args: [
|
|
||||||
"--check", # Don't apply changes automatically
|
|
||||||
]
|
|
||||||
- repo: https://github.com/pycqa/flake8
|
- repo: https://github.com/pycqa/flake8
|
||||||
rev: 6.0.0
|
rev: 6.0.0
|
||||||
hooks:
|
hooks:
|
||||||
@ -30,3 +23,12 @@ repos:
|
|||||||
"-sn", # Don't display the score
|
"-sn", # Don't display the score
|
||||||
"--rcfile=.pylintrc", # Link to your config file
|
"--rcfile=.pylintrc", # Link to your config file
|
||||||
]
|
]
|
||||||
|
- repo: https://github.com/codespell-project/codespell
|
||||||
|
rev: v2.2.5
|
||||||
|
hooks:
|
||||||
|
- id: codespell
|
||||||
|
|
||||||
|
- repo: https://github.com/gklein/check_signoff
|
||||||
|
rev: v1.0.5
|
||||||
|
hooks:
|
||||||
|
- id: check-signoff
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[MESSAGES CONTROL]
|
[MESSAGES CONTROL]
|
||||||
# C0111 missing-docstring: missing-class-docstring, missing-function-docstring, missing-method-docstring, missing-module-docstrin
|
# C0111 missing-docstring: missing-class-docstring, missing-function-docstring, missing-method-docstring, missing-module-docstrin
|
||||||
# consider-using-with: we need it for color formatter pipe
|
# consider-using-with: we need it for color formatter pipe
|
||||||
disable=too-many-lines,too-many-branches,too-many-locals,too-many-statements,too-many-arguments,too-many-instance-attributes,fixme,multiple-statements,missing-docstring,line-too-long,consider-using-f-string,consider-using-with,unnecessary-lambda-assignment
|
disable=too-many-lines,too-many-branches,too-many-locals,too-many-statements,too-many-arguments,too-many-instance-attributes,fixme,multiple-statements,missing-docstring,line-too-long,consider-using-f-string,consider-using-with,unnecessary-lambda-assignment,broad-exception-caught
|
||||||
# allow _ for ignored variables
|
# allow _ for ignored variables
|
||||||
# allow generic names like a,b,c and i,j,k,l,m,n and x,y,z
|
# allow generic names like a,b,c and i,j,k,l,m,n and x,y,z
|
||||||
# allow k,v for key/value
|
# allow k,v for key/value
|
||||||
|
161
CONTRIBUTING.md
161
CONTRIBUTING.md
@ -1,70 +1,83 @@
|
|||||||
# Contributing to podman-compose
|
# Contributing to podman-compose
|
||||||
|
|
||||||
## Who can contribute?
|
## Who can contribute?
|
||||||
|
|
||||||
- Users that found a bug
|
- Users that found a bug,
|
||||||
- Users that wants to propose new functionalities or enhancements
|
- Users that want to propose new functionalities or enhancements,
|
||||||
- Users that want to help other users to troubleshoot their environments
|
- Users that want to help other users to troubleshoot their environments,
|
||||||
- Developers that want to fix bugs
|
- Developers that want to fix bugs,
|
||||||
- Developers that want to implement new functionalities or enhancements
|
- Developers that want to implement new functionalities or enhancements.
|
||||||
|
|
||||||
## Branches
|
|
||||||
|
|
||||||
Please request your PR to be merged into the `devel` branch.
|
|
||||||
Changes to the `stable` branch are managed by the repository maintainers.
|
|
||||||
|
|
||||||
## Development environment setup
|
## Development environment setup
|
||||||
|
|
||||||
Note: Some steps are OPTIONAL but all are RECOMMENDED.
|
Note: Some steps are OPTIONAL but all are RECOMMENDED.
|
||||||
|
|
||||||
1. Fork the project repo and clone it
|
1. Fork the project repository and clone it:
|
||||||
```shell
|
|
||||||
$ git clone https://github.com/USERNAME/podman-compose.git
|
```shell
|
||||||
$ cd podman-compose
|
$ git clone https://github.com/USERNAME/podman-compose.git
|
||||||
```
|
$ cd podman-compose
|
||||||
1. (OPTIONAL) Create a python virtual environment. Example using [virtualenv wrapper](https://virtualenvwrapper.readthedocs.io/en/latest/):
|
```
|
||||||
```shell
|
|
||||||
mkvirtualenv podman-compose
|
2. (OPTIONAL) Create a Python virtual environment. Example using
|
||||||
```
|
[virtualenv wrapper](https://virtualenvwrapper.readthedocs.io/en/latest/):
|
||||||
2. Install the project runtime and development requirements
|
|
||||||
```shell
|
```shell
|
||||||
$ pip install '.[devel]'
|
$ mkvirtualenv podman-compose
|
||||||
```
|
```
|
||||||
3. (OPTIONAL) Install `pre-commit` git hook scripts (https://pre-commit.com/#3-install-the-git-hook-scripts)
|
|
||||||
```shell
|
3. Install the project runtime and development requirements:
|
||||||
$ pre-commit install
|
|
||||||
```
|
```shell
|
||||||
4. Create a new branch, develop and add tests when possible
|
$ pip install '.[devel]'
|
||||||
5. Run linting & testing before commiting code. Ensure all the hooks are passing.
|
```
|
||||||
```shell
|
|
||||||
$ pre-commit run --all-files
|
4. (OPTIONAL) Install `pre-commit` git hook scripts
|
||||||
```
|
(https://pre-commit.com/#3-install-the-git-hook-scripts):
|
||||||
6. Run code coverage
|
|
||||||
```shell
|
```shell
|
||||||
coverage run --source podman_compose -m pytest ./pytests
|
$ pre-commit install
|
||||||
python -m pytest ./tests
|
```
|
||||||
coverage combine
|
|
||||||
coverage report
|
5. Create a new branch, develop and add tests when possible.
|
||||||
coverage html
|
6. Run linting and testing before committing code. Ensure all the hooks are passing.
|
||||||
```
|
|
||||||
7. Commit your code to your fork's branch.
|
```shell
|
||||||
- Make sure you include a `Signed-off-by` message in your commits. Read [this guide](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) to learn how to sign your commits
|
$ pre-commit run --all-files
|
||||||
- In the commit message reference the Issue ID that your code fixes and a brief description of the changes. Example: `Fixes #516: allow empty network`
|
```
|
||||||
7. Open a PR to `containers/podman-compose:devel` and wait for a maintainer to review your work.
|
|
||||||
|
7. Run code coverage:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ coverage run --source podman_compose -m unittest discover tests/unit
|
||||||
|
$ python3 -m unittest discover tests/integration
|
||||||
|
$ coverage combine
|
||||||
|
$ coverage report
|
||||||
|
$ coverage html
|
||||||
|
```
|
||||||
|
|
||||||
|
8. Commit your code to your fork's branch.
|
||||||
|
- Make sure you include a `Signed-off-by` message in your commits.
|
||||||
|
Read [this guide](https://github.com/containers/common/blob/main/CONTRIBUTING.md#sign-your-prs)
|
||||||
|
to learn how to sign your commits.
|
||||||
|
- In the commit message, reference the Issue ID that your code fixes and a brief description of
|
||||||
|
the changes.
|
||||||
|
Example: `Fixes #516: Allow empty network`
|
||||||
|
9. Open a pull request to `containers/podman-compose` and wait for a maintainer to review your work.
|
||||||
|
|
||||||
## Adding new commands
|
## Adding new commands
|
||||||
|
|
||||||
To add a command you need to add a function that is decorated
|
To add a command, you need to add a function that is decorated with `@cmd_run`.
|
||||||
with `@cmd_run` passing the compose instance, command name and
|
|
||||||
description. This function must be declared `async` the wrapped
|
|
||||||
function should accept two arguments the compose instance and
|
|
||||||
the command-specific arguments (resulted from python's `argparse`
|
|
||||||
package) inside that command you can run PodMan like this
|
|
||||||
`await compose.podman.run(['inspect', 'something'])`and inside
|
|
||||||
that function you can access `compose.pods` and `compose.containers`
|
|
||||||
...etc. Here is an example
|
|
||||||
|
|
||||||
```
|
The decorated function must be declared `async` and should accept two arguments: The compose
|
||||||
|
instance and the command-specific arguments (resulted from the Python's `argparse` package).
|
||||||
|
|
||||||
|
In this function, you can run Podman (e.g. `await compose.podman.run(['inspect', 'something'])`),
|
||||||
|
access `compose.pods`, `compose.containers` etc.
|
||||||
|
|
||||||
|
Here is an example:
|
||||||
|
|
||||||
|
```python
|
||||||
@cmd_run(podman_compose, 'build', 'build images defined in the stack')
|
@cmd_run(podman_compose, 'build', 'build images defined in the stack')
|
||||||
async def compose_build(compose, args):
|
async def compose_build(compose, args):
|
||||||
await compose.podman.run(['build', 'something'])
|
await compose.podman.run(['build', 'something'])
|
||||||
@ -72,31 +85,36 @@ async def compose_build(compose, args):
|
|||||||
|
|
||||||
## Command arguments parsing
|
## Command arguments parsing
|
||||||
|
|
||||||
Add a function that accept `parser` which is an instance from `argparse`.
|
To add arguments to be parsed by a command, you need to add a function that is decorated with
|
||||||
In side that function you can call `parser.add_argument()`.
|
`@cmd_parse` which accepts the compose instance and the command's name (as a string list or as a
|
||||||
The function decorated with `@cmd_parse` accepting the compose instance,
|
single string).
|
||||||
and command names (as a list or as a string).
|
|
||||||
You can do this multiple times.
|
|
||||||
|
|
||||||
Here is an example
|
The decorated function should accept a single argument: An instance of `argparse`.
|
||||||
|
|
||||||
```
|
In this function, you can call `parser.add_argument()` to add a new argument to the command.
|
||||||
|
|
||||||
|
Note you can add such a function multiple times.
|
||||||
|
|
||||||
|
Here is an example:
|
||||||
|
|
||||||
|
```python
|
||||||
@cmd_parse(podman_compose, 'build')
|
@cmd_parse(podman_compose, 'build')
|
||||||
def compose_build_parse(parser):
|
def compose_build_parse(parser):
|
||||||
parser.add_argument("--pull",
|
parser.add_argument("--pull",
|
||||||
help="attempt to pull a newer version of the image", action='store_true')
|
help="attempt to pull a newer version of the image", action='store_true')
|
||||||
parser.add_argument("--pull-always",
|
parser.add_argument("--pull-always",
|
||||||
help="attempt to pull a newer version of the image, Raise an error even if the image is present locally.", action='store_true')
|
help="Attempt to pull a newer version of the image, "
|
||||||
|
"raise an error even if the image is present locally.",
|
||||||
|
action='store_true')
|
||||||
```
|
```
|
||||||
|
|
||||||
NOTE: `@cmd_parse` should be after `@cmd_run`
|
NOTE: `@cmd_parse` should be after `@cmd_run`.
|
||||||
|
|
||||||
## Calling a command from inside another
|
## Calling a command from another one
|
||||||
|
|
||||||
If you need to call `podman-compose down` from inside `podman-compose up`
|
If you need to call `podman-compose down` from `podman-compose up`, do something like:
|
||||||
do something like:
|
|
||||||
|
|
||||||
```
|
```python
|
||||||
@cmd_run(podman_compose, 'up', 'up desc')
|
@cmd_run(podman_compose, 'up', 'up desc')
|
||||||
async def compose_up(compose, args):
|
async def compose_up(compose, args):
|
||||||
await compose.commands['down'](compose, args)
|
await compose.commands['down'](compose, args)
|
||||||
@ -104,19 +122,14 @@ async def compose_up(compose, args):
|
|||||||
await compose.commands['down'](argparse.Namespace(foo=123))
|
await compose.commands['down'](argparse.Namespace(foo=123))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Missing Commands (help needed)
|
## Missing Commands (help needed)
|
||||||
|
|
||||||
```
|
```
|
||||||
bundle Generate a Docker bundle from the Compose file
|
bundle Generate a Docker bundle from the Compose file
|
||||||
config Validate and view the Compose file
|
|
||||||
create Create services
|
create Create services
|
||||||
events Receive real time events from containers
|
events Receive real time events from containers
|
||||||
images List images
|
images List images
|
||||||
logs View output from containers
|
|
||||||
port Print the public port for a port binding
|
|
||||||
ps List containers
|
|
||||||
rm Remove stopped containers
|
rm Remove stopped containers
|
||||||
run Run a one-off command
|
|
||||||
scale Set number of containers for a service
|
scale Set number of containers for a service
|
||||||
top Display the running processes
|
top Display the running processes
|
||||||
```
|
```
|
||||||
|
30
Dockerfile
Normal file
30
Dockerfile
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Use a base image with necessary build tools
|
||||||
|
FROM python:3.11-slim AS builder
|
||||||
|
|
||||||
|
# Install required packages for building
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
gcc \
|
||||||
|
musl-dev \
|
||||||
|
build-essential \
|
||||||
|
python3-dev \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy the application code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Install PyInstaller
|
||||||
|
RUN pip install pyinstaller
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
# Create a binary with PyInstaller
|
||||||
|
RUN pyinstaller --onefile --clean podman_compose.py
|
||||||
|
|
||||||
|
# Create /result dir in case it is not mounted
|
||||||
|
RUN mkdir -p /result
|
||||||
|
|
||||||
|
# Export binary
|
||||||
|
RUN cp /app/dist/podman_compose /result/podman-compose
|
53
README.md
53
README.md
@ -1,6 +1,5 @@
|
|||||||
# Podman Compose
|
# Podman Compose
|
||||||
## [](https://github.com/containers/podman-compose/actions/workflows/pylint.yml) [](https://github.com/containers/podman-compose/actions/workflows/pytest.yml)
|
## [](https://github.com/containers/podman-compose/actions/workflows/test.yml)
|
||||||
|
|
||||||
|
|
||||||
An implementation of [Compose Spec](https://compose-spec.io/) with [Podman](https://podman.io/) backend.
|
An implementation of [Compose Spec](https://compose-spec.io/) with [Podman](https://podman.io/) backend.
|
||||||
This project focuses on:
|
This project focuses on:
|
||||||
@ -11,7 +10,11 @@ This project focuses on:
|
|||||||
This project only depends on:
|
This project only depends on:
|
||||||
|
|
||||||
* `podman`
|
* `podman`
|
||||||
* [podman dnsname plugin](https://github.com/containers/dnsname): It is usually found in the `podman-plugins` or `podman-dnsname` distro packages, those packages are not pulled by default and you need to install them. This allows containers to be able to resolve each other if they are on the same CNI network.
|
* [podman dnsname plugin](https://github.com/containers/dnsname): It is usually found in
|
||||||
|
the `podman-plugins` or `podman-dnsname` distro packages, those packages are not pulled
|
||||||
|
by default and you need to install them. This allows containers to be able to resolve
|
||||||
|
each other if they are on the same CNI network. This is not necessary when podman is using
|
||||||
|
netavark as a network backend.
|
||||||
* Python3
|
* Python3
|
||||||
* [PyYAML](https://pyyaml.org/)
|
* [PyYAML](https://pyyaml.org/)
|
||||||
* [python-dotenv](https://pypi.org/project/python-dotenv/)
|
* [python-dotenv](https://pypi.org/project/python-dotenv/)
|
||||||
@ -49,9 +52,11 @@ like `hostnet`. If you desire that behavior, pass it the standard way like `netw
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
### Pip
|
||||||
|
|
||||||
Install the latest stable version from PyPI:
|
Install the latest stable version from PyPI:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
pip3 install podman-compose
|
pip3 install podman-compose
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -59,14 +64,39 @@ pass `--user` to install inside regular user home without being root.
|
|||||||
|
|
||||||
Or latest development version from GitHub:
|
Or latest development version from GitHub:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
pip3 install https://github.com/containers/podman-compose/archive/devel.tar.gz
|
pip3 install https://github.com/containers/podman-compose/archive/main.tar.gz
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Homebrew
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brew install podman-compose
|
||||||
|
```
|
||||||
|
|
||||||
|
### Generate binary using docker/podman locally
|
||||||
|
This script will download the repo, generate the binary using [this Dockerfile](https://github.com/containers/podman-compose/blob/main/Dockerfile), and place the binary in the directory where you called this script.
|
||||||
|
```bash
|
||||||
|
sh -c "$(curl -sSL https://raw.githubusercontent.com/containers/podman-compose/main/scripts/download_and_build_podman-compose.sh)"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manual
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -o /usr/local/bin/podman-compose https://raw.githubusercontent.com/containers/podman-compose/main/podman_compose.py
|
||||||
|
chmod +x /usr/local/bin/podman-compose
|
||||||
|
```
|
||||||
|
|
||||||
|
or inside your home
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -o ~/.local/bin/podman-compose https://raw.githubusercontent.com/containers/podman-compose/main/podman_compose.py
|
||||||
|
chmod +x ~/.local/bin/podman-compose
|
||||||
|
```
|
||||||
|
|
||||||
or install from Fedora (starting from f31) repositories:
|
or install from Fedora (starting from f31) repositories:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
sudo dnf install podman-compose
|
sudo dnf install podman-compose
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -75,10 +105,9 @@ sudo dnf install podman-compose
|
|||||||
We have included fully functional sample stacks inside `examples/` directory.
|
We have included fully functional sample stacks inside `examples/` directory.
|
||||||
You can get more examples from [awesome-compose](https://github.com/docker/awesome-compose).
|
You can get more examples from [awesome-compose](https://github.com/docker/awesome-compose).
|
||||||
|
|
||||||
|
|
||||||
A quick example would be
|
A quick example would be
|
||||||
|
|
||||||
```
|
```bash
|
||||||
cd examples/busybox
|
cd examples/busybox
|
||||||
podman-compose --help
|
podman-compose --help
|
||||||
podman-compose up --help
|
podman-compose up --help
|
||||||
@ -103,11 +132,11 @@ There is also AWX 17.1.0
|
|||||||
Inside `tests/` directory we have many useless docker-compose stacks
|
Inside `tests/` directory we have many useless docker-compose stacks
|
||||||
that are meant to test as many cases as we can to make sure we are compatible
|
that are meant to test as many cases as we can to make sure we are compatible
|
||||||
|
|
||||||
### Unit tests with pytest
|
### Unit tests with unittest
|
||||||
run a pytest with following command
|
run a unittest with following command
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
python -m pytest pytests
|
python3 -m unittest discover tests/unit
|
||||||
```
|
```
|
||||||
|
|
||||||
# Contributing guide
|
# Contributing guide
|
||||||
|
47
RELEASING.md
Normal file
47
RELEASING.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
Creating a release
|
||||||
|
==================
|
||||||
|
|
||||||
|
This file contains instructions for maintainers on how to release new versions of podman-compose.
|
||||||
|
|
||||||
|
Step 1: Initialize variables for subsequent steps
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
```
|
||||||
|
export VERSION=1.2.3
|
||||||
|
```
|
||||||
|
|
||||||
|
Step 2: Release notes PR
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
Open a new branch (e.g. `release`) and run the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
./scripts/make_release_notes.sh $VERSION
|
||||||
|
```
|
||||||
|
|
||||||
|
This collects the release notes using the `towncrier` tool and then commits the result.
|
||||||
|
This step is done as a PR so that CI can check for spelling errors and similar issues.
|
||||||
|
|
||||||
|
Certain file names are not properly supported by the `towncrier` tool and it ignores them.
|
||||||
|
Check `newsfragments` directory for any forgotten release notes
|
||||||
|
|
||||||
|
Step 3: Merge the release notes PR
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
Step 4: Perform actual release
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Pull the merge commit created on the `main` branch during the step 2.
|
||||||
|
Then run:
|
||||||
|
|
||||||
|
```
|
||||||
|
./scripts/make_release.sh $VERSION
|
||||||
|
```
|
||||||
|
|
||||||
|
This will create release commit, tag and push everything.
|
||||||
|
|
||||||
|
Step 5: Create a release on Github
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
The release notes must be added manually by drafting a release on the GitHub UI at
|
||||||
|
https://github.com/containers/podman-compose/releases.
|
33
docs/Changelog-1.1.0.md
Normal file
33
docs/Changelog-1.1.0.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
Version v1.1.0 (2024-04-17)
|
||||||
|
===========================
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
|
||||||
|
- Fixed support for values with equals sign in `-e` argument of `run` and `exec` commands.
|
||||||
|
- Fixed duplicate arguments being emitted in `stop` and `restart` commands.
|
||||||
|
- Removed extraneous debug output. `--verbose` flag has been added to preserve verbose output.
|
||||||
|
- Links aliases are now added to service aliases.
|
||||||
|
- Fixed image build process to use defined environmental variables.
|
||||||
|
- Empty list is now allowed to be `COMMAND` and `ENTRYPOINT`.
|
||||||
|
- Environment files are now resolved relative to current working directory.
|
||||||
|
- Exit code of container build is now preserved as return code of `build` command.
|
||||||
|
|
||||||
|
New features
|
||||||
|
------------
|
||||||
|
|
||||||
|
- Added support for `uidmap`, `gidmap`, `http_proxy` and `runtime` service configuration keys.
|
||||||
|
- Added support for `enable_ipv6` network configuration key.
|
||||||
|
- Added `--parallel` option to support parallel pulling and building of images.
|
||||||
|
- Implemented support for maps in `sysctls` container configuration key.
|
||||||
|
- Implemented `stats` command.
|
||||||
|
- Added `--no-normalize` flag to `config` command.
|
||||||
|
- Added support for `include` global configuration key.
|
||||||
|
- Added support for `build` command.
|
||||||
|
- Added support to start containers with multiple networks.
|
||||||
|
- Added support for `profile` argument.
|
||||||
|
- Added support for starting podman in existing network namespace.
|
||||||
|
- Added IPAM driver support.
|
||||||
|
- Added support for file secrets being passed to `podman build` via `--secret` argument.
|
||||||
|
- Added support for multiple networks with separately specified IP and MAC address.
|
||||||
|
- Added support for `service.build.ulimits` when building image.
|
40
docs/Changelog-1.2.0.md
Normal file
40
docs/Changelog-1.2.0.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
Version v1.2.0 (2024-06-26)
|
||||||
|
===========================
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
|
||||||
|
- Fixed handling of `--in-pod` argument. Previously it was hard to provide false value to it.
|
||||||
|
- podman-compose no longer creates pods when registering systemd unit.
|
||||||
|
- Fixed warning `RuntimeWarning: coroutine 'create_pods' was never awaited`
|
||||||
|
- Fixed error when setting up IPAM network with default driver.
|
||||||
|
- Fixed support for having list and dictionary `depends_on` sections in related compose files.
|
||||||
|
- Fixed logging of failed build message.
|
||||||
|
- Fixed support for multiple entries in `include` section.
|
||||||
|
- Fixed environment variable precedence order.
|
||||||
|
|
||||||
|
Changes
|
||||||
|
-------
|
||||||
|
|
||||||
|
- `x-podman` dictionary in container root has been migrated to `x-podman.*` fields in container root.
|
||||||
|
|
||||||
|
New features
|
||||||
|
------------
|
||||||
|
|
||||||
|
- Added support for `--publish` in `podman-compose run`.
|
||||||
|
- Added support for Podman external root filesystem management (`--rootfs` option).
|
||||||
|
- Added support for `podman-compose images` command.
|
||||||
|
- Added support for `env_file` being configured via dictionaries.
|
||||||
|
- Added support for enabling GPU access.
|
||||||
|
- Added support for selinux in verbose mount specification.
|
||||||
|
- Added support for `additional_contexts` section.
|
||||||
|
- Added support for multi-line environment files.
|
||||||
|
- Added support for passing contents of `podman-compose.yml` via stdin.
|
||||||
|
- Added support for specifying the value for `--in-pod` setting in `podman-compose.yml` file.
|
||||||
|
- Added support for environmental secrets.
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Added instructions on how to install podman-compose on Homebrew.
|
||||||
|
- Added explanation that netavark is an alternative to dnsname plugin
|
38
docs/Changelog-1.3.0.md
Normal file
38
docs/Changelog-1.3.0.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
Version 1.3.0 (2025-01-07)
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
|
||||||
|
- Fixed support for de-facto alternative `Dockerfile` names (e.g. `Containerfile`)
|
||||||
|
- Fixed a bug that caused attempts to create already existing pods multiple times.
|
||||||
|
- Fixed compatibility with docker-compose in how symlinks to docker-compose.yml are handled.
|
||||||
|
- Fixed freeze caused by too long log lines without a newline.
|
||||||
|
- Fixed support for `network_mode: none`.
|
||||||
|
- Improved error detection by rejecting service definitions that contain both `network_mode` and
|
||||||
|
`networks` keys, which is not allowed.
|
||||||
|
|
||||||
|
|
||||||
|
Features
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Added support for build labels.
|
||||||
|
- Added support for "platform" property in the build command.
|
||||||
|
- Added support for "ssh" property in the build command.
|
||||||
|
- Added support for cache_from and cache_to fields in build section.
|
||||||
|
- Added support for honoring the condition in the depends_on section of the service, if stated.
|
||||||
|
- Added `x-podman.no_hosts` setting to pass `--no-hosts` to podman run
|
||||||
|
- Added support for compatibility with docker compose for default network behavior when no network
|
||||||
|
defined in service. This is controlled via `default_net_behavior_compat` feature flag.
|
||||||
|
- Added a way to get compatibility of default network names with docker compose.
|
||||||
|
This is selected by setting `default_net_name_compat: true` on `x-podman` global dictionary.
|
||||||
|
- Added support for the `device_cgroup_rules` property in services.
|
||||||
|
- Added support for removing networks in `podman-compose down`.
|
||||||
|
- Added support for network scoped service aliases.
|
||||||
|
- Added support for network level `mac_address` attribute.
|
||||||
|
- Added ability to substitute variables with the environment of the service.
|
||||||
|
|
||||||
|
Misc
|
||||||
|
----
|
||||||
|
|
||||||
|
- Declared compatibility with Python 3.13.
|
39
docs/Changelog-1.4.0.md
Normal file
39
docs/Changelog-1.4.0.md
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
Version 1.4.0 (2025-05-10)
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Bug fixes
|
||||||
|
---------
|
||||||
|
|
||||||
|
- Fixed handling of relative includes and extends in compose files
|
||||||
|
- Fixed error when merging arguments in list and dictionary syntax
|
||||||
|
- Fixed issue where short-lived containers could execute twice when using `up` in detached mode
|
||||||
|
- Fixed `up` command hanging on Podman versions earlier than 4.6.0
|
||||||
|
- Fixed issue where `service_healthy` conditions weren't enforced during `up` command
|
||||||
|
- Fixed support for the `--scale` flag
|
||||||
|
- Fixed bug causing dependent containers to start despite `--no-deps` flag
|
||||||
|
- Fixed port command behavior for dynamic host ports
|
||||||
|
- Fixed interpolation of `COMPOSE_PROJECT_NAME` when set from top-level `name` in compose file
|
||||||
|
- Fixed project name evaluation order to match compose spec
|
||||||
|
- Fixed build context when using git URLs
|
||||||
|
- Fixed `KeyError` when `down` is called with non-existent service
|
||||||
|
- Skip `down` during `up` when no active containers exist
|
||||||
|
- Fixed non-zero exit code on failure when using `up -d`
|
||||||
|
- Fixed SIGINT handling during `up` command for graceful shutdown
|
||||||
|
- Fixed `NotImplementedError` when interrupted on Windows
|
||||||
|
|
||||||
|
Features
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Added `--quiet` flag to `config` command to suppress output
|
||||||
|
- Added support for `pids_limit` and `deploy.resources.limits.pids`
|
||||||
|
- Added `--abort-on-container-failure` option
|
||||||
|
- Added `--rmi` argument to `down` command for image removal
|
||||||
|
- Added support for `x-podman.disable-dns` to disable DNS plugin on defined networks
|
||||||
|
- Added support for `x-podman.dns` to set DNS nameservers for defined networks
|
||||||
|
- Improved file descriptor handling - no longer closes externally created descriptors.
|
||||||
|
This allows descriptors created e.g. via systemd socket activation to be passed to
|
||||||
|
containers.
|
||||||
|
- Added support for `cpuset` configuration
|
||||||
|
- Added support for `reset` and `override` tags when merging compose files
|
||||||
|
- Added support for `x-podman.interface_name` to set network interface names
|
||||||
|
- Added support for `x-podman.pod_args` to override default `--pod-args`
|
194
docs/Extensions.md
Normal file
194
docs/Extensions.md
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
# Podman specific extensions to the docker-compose format
|
||||||
|
|
||||||
|
Podman-compose supports the following extension to the docker-compose format. These extensions
|
||||||
|
are generally specified under fields with "x-podman" prefix in the compose file.
|
||||||
|
|
||||||
|
## Container management
|
||||||
|
|
||||||
|
The following extension keys are available under container configuration:
|
||||||
|
|
||||||
|
* `x-podman.uidmaps` - Run the container in a new user namespace using the supplied UID mapping.
|
||||||
|
|
||||||
|
* `x-podman.gidmaps` - Run the container in a new user namespace using the supplied GID mapping.
|
||||||
|
|
||||||
|
* `x-podman.rootfs` - Run the container without requiring any image management; the rootfs of the
|
||||||
|
container is assumed to be managed externally.
|
||||||
|
|
||||||
|
* `x-podman.no_hosts` - Run the container without creating /etc/hosts file
|
||||||
|
|
||||||
|
For example, the following docker-compose.yml allows running a podman container with externally managed rootfs.
|
||||||
|
```yml
|
||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
my_service:
|
||||||
|
command: ["/bin/busybox"]
|
||||||
|
x-podman.rootfs: "/path/to/rootfs"
|
||||||
|
```
|
||||||
|
|
||||||
|
For explanations of these extensions, please refer to the [Podman Documentation](https://docs.podman.io/).
|
||||||
|
|
||||||
|
## Network management
|
||||||
|
|
||||||
|
The following extension keys are available under network configuration:
|
||||||
|
|
||||||
|
* `x-podman.disable-dns` - Disable the DNS plugin for the network when set to 'true'.
|
||||||
|
* `x-podman.dns` - Set nameservers for the network using supplied addresses (cannot be used with x-podman.disable-dns`).
|
||||||
|
|
||||||
|
For example, the following docker-compose.yml allows all containers on the same network to use the
|
||||||
|
specified nameservers:
|
||||||
|
```yml
|
||||||
|
version: "3"
|
||||||
|
network:
|
||||||
|
my_network:
|
||||||
|
x-podman.dns:
|
||||||
|
- "10.1.2.3"
|
||||||
|
- "10.1.2.4"
|
||||||
|
```
|
||||||
|
|
||||||
|
For explanations of these extensions, please refer to the
|
||||||
|
[Podman network create command Documentation](https://docs.podman.io/en/latest/markdown/podman-network-create.1.html).
|
||||||
|
|
||||||
|
## Per-network MAC-addresses
|
||||||
|
|
||||||
|
Generic docker-compose files support specification of the MAC address on the container level. If the
|
||||||
|
container has multiple network interfaces, the specified MAC address is applied to the first
|
||||||
|
specified network.
|
||||||
|
|
||||||
|
Podman-compose in addition supports the specification of MAC addresses on a per-network basis. This
|
||||||
|
is done by adding a `x-podman.mac_address` key to the network configuration in the container. The
|
||||||
|
value of the `x-podman.mac_address` key is the MAC address to be used for the network interface.
|
||||||
|
|
||||||
|
Note that the [compose spec](https://github.com/compose-spec/compose-spec/blob/main/05-services.md#mac_address)
|
||||||
|
now supports `mac_address` on the network level, so we recommend using
|
||||||
|
the standard `mac_address` key for setting the MAC address. The
|
||||||
|
`x-podman.mac_address` is still supported for backwards compatibility.
|
||||||
|
|
||||||
|
|
||||||
|
Specifying a MAC address for the container and for individual networks at the same time is not
|
||||||
|
supported.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
version: "3"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
net0:
|
||||||
|
driver: "bridge"
|
||||||
|
ipam:
|
||||||
|
config:
|
||||||
|
- subnet: "192.168.0.0/24"
|
||||||
|
net1:
|
||||||
|
driver: "bridge"
|
||||||
|
ipam:
|
||||||
|
config:
|
||||||
|
- subnet: "192.168.1.0/24"
|
||||||
|
|
||||||
|
services:
|
||||||
|
webserver:
|
||||||
|
image: "busybox"
|
||||||
|
command: ["/bin/busybox", "httpd", "-f", "-h", "/etc", "-p", "8001"]
|
||||||
|
networks:
|
||||||
|
net0:
|
||||||
|
ipv4_address: "192.168.0.10"
|
||||||
|
x-podman.mac_address: "02:aa:aa:aa:aa:aa"
|
||||||
|
net1:
|
||||||
|
ipv4_address: "192.168.1.10"
|
||||||
|
mac_address: "02:bb:bb:bb:bb:bb" # mac_address is supported
|
||||||
|
```
|
||||||
|
|
||||||
|
## Per-network interface name
|
||||||
|
|
||||||
|
Using `x-podman.interface_name` within a containers network config you can specify the interface name inside the container.
|
||||||
|
|
||||||
|
## Podman-specific network modes
|
||||||
|
|
||||||
|
Generic docker-compose supports the following values for `network-mode` for a container:
|
||||||
|
|
||||||
|
- `bridge`
|
||||||
|
- `host`
|
||||||
|
- `none`
|
||||||
|
- `service`
|
||||||
|
- `container`
|
||||||
|
|
||||||
|
In addition, podman-compose supports the following podman-specific values for `network-mode`:
|
||||||
|
|
||||||
|
- `slirp4netns[:<options>,...]`
|
||||||
|
- `ns:<options>`
|
||||||
|
- `pasta[:<options>,...]`
|
||||||
|
- `private`
|
||||||
|
|
||||||
|
The options to the network modes are passed to the `--network` option of the `podman create` command
|
||||||
|
as-is.
|
||||||
|
|
||||||
|
|
||||||
|
## Compatibility of default network names between docker-compose and podman-compose
|
||||||
|
|
||||||
|
Current versions of podman-compose may produce different default external network names than
|
||||||
|
docker-compose under certain conditions. Specifically, docker-compose removes dashes (`-` character)
|
||||||
|
from project name.
|
||||||
|
|
||||||
|
To enable compatibility between docker-compose and podman-compose, specify
|
||||||
|
`default_net_name_compat: true` under global `x-podman` key:
|
||||||
|
|
||||||
|
```
|
||||||
|
x-podman:
|
||||||
|
default_net_name_compat: true
|
||||||
|
```
|
||||||
|
|
||||||
|
By default `default_net_name_compat` is `false`. This will change to `true` at some point and the
|
||||||
|
setting will be removed.
|
||||||
|
|
||||||
|
## Compatibility of default network behavior between docker-compose and podman-compose
|
||||||
|
|
||||||
|
When there is no network defined (neither network-mode nor networks) in service,
|
||||||
|
The behavior of default network in docker-compose and podman-compose are different.
|
||||||
|
|
||||||
|
| Top-level networks | podman-compose | docker-compose |
|
||||||
|
| ------------------------------ | -------------------------- | -------------- |
|
||||||
|
| No networks | default | default |
|
||||||
|
| One network named net0 | net0 | default |
|
||||||
|
| Two networks named net0, net1 | podman(`--network=bridge`) | default |
|
||||||
|
| Contains network named default | default | default |
|
||||||
|
|
||||||
|
To enable compatibility between docker-compose and podman-compose, specify
|
||||||
|
`default_net_behavior_compat: true` under global `x-podman` key:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
x-podman:
|
||||||
|
default_net_behavior_compat: true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Custom pods management
|
||||||
|
|
||||||
|
Podman-compose can have containers in pods. This can be controlled by extension key x-podman in_pod.
|
||||||
|
It allows providing custom value for --in-pod and is especially relevant when --userns has to be set.
|
||||||
|
|
||||||
|
For example, the following docker-compose.yml allows using userns_mode by overriding the default
|
||||||
|
value of --in-pod (unless it was specifically provided by "--in-pod=True" in command line interface).
|
||||||
|
```yml
|
||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
cont:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
userns_mode: keep-id:uid=1000
|
||||||
|
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-p", "8080"]
|
||||||
|
|
||||||
|
x-podman:
|
||||||
|
in_pod: false
|
||||||
|
```
|
||||||
|
|
||||||
|
It is also possible to override the default arguments for pod creation that are
|
||||||
|
used when --pod-args is not passed on the command line:
|
||||||
|
```yml
|
||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
cont:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "httpd", "-f", "-p", "8080"]
|
||||||
|
x-podman:
|
||||||
|
pod_args: ["--infra=false", "--share=", "--cpus=1"]
|
||||||
|
```
|
||||||
|
When not set in docker-compose.yml or on the command line, the pod args default
|
||||||
|
to `["--infra=false", "--share="]`.
|
9
examples/docker-inline/docker-compose.yml
Normal file
9
examples/docker-inline/docker-compose.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
dummy:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile_inline: |
|
||||||
|
FROM alpine
|
||||||
|
RUN echo "hello world"
|
@ -1,7 +1,7 @@
|
|||||||
# pylint: disable=import-error
|
# pylint: disable=import-error
|
||||||
# pylint: disable=unused-import
|
# pylint: disable=unused-import
|
||||||
import os
|
|
||||||
import asyncio # noqa: F401
|
import asyncio # noqa: F401
|
||||||
|
import os
|
||||||
|
|
||||||
import aioredis
|
import aioredis
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
11
examples/nvidia-smi/docker-compose.yaml
Normal file
11
examples/nvidia-smi/docker-compose.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
services:
|
||||||
|
test:
|
||||||
|
image: nvidia/cuda:12.3.1-base-ubuntu20.04
|
||||||
|
command: nvidia-smi
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
reservations:
|
||||||
|
devices:
|
||||||
|
- driver: nvidia
|
||||||
|
count: 1
|
||||||
|
capabilities: [gpu]
|
13
newsfragments/README.txt
Normal file
13
newsfragments/README.txt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
This is the directory for news fragments used by towncrier: https://github.com/hawkowl/towncrier
|
||||||
|
|
||||||
|
You create a news fragment in this directory when you make a change, and the file gets removed from
|
||||||
|
this directory when the news is published.
|
||||||
|
|
||||||
|
towncrier has a few standard types of news fragments, signified by the file extension. These are:
|
||||||
|
|
||||||
|
.feature: Signifying a new feature.
|
||||||
|
.bugfix: Signifying a bug fix.
|
||||||
|
.doc: Signifying a documentation improvement.
|
||||||
|
.removal: Signifying a deprecation or removal of public API.
|
||||||
|
.change: Signifying a change of behavior
|
||||||
|
.misc: Miscellaneous change
|
2638
podman_compose.py
2638
podman_compose.py
File diff suppressed because it is too large
Load Diff
55
pyproject.toml
Normal file
55
pyproject.toml
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
[tool.ruff]
|
||||||
|
line-length = 100
|
||||||
|
target-version = "py38"
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
select = ["W", "E", "F", "I"]
|
||||||
|
ignore = [
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.ruff.lint.isort]
|
||||||
|
force-single-line = true
|
||||||
|
|
||||||
|
[tool.ruff.format]
|
||||||
|
preview = true # needed for quote-style
|
||||||
|
quote-style = "preserve"
|
||||||
|
|
||||||
|
[tool.towncrier]
|
||||||
|
package = "podman_compose"
|
||||||
|
package_dir = "master"
|
||||||
|
directory = "newsfragments"
|
||||||
|
filename = "docs/Changelog-new.md"
|
||||||
|
template = "scripts/Changelog-template.jinja"
|
||||||
|
title_format = "Version {version} ({project_date})"
|
||||||
|
[[tool.towncrier.section]]
|
||||||
|
path = ""
|
||||||
|
|
||||||
|
[[tool.towncrier.type]]
|
||||||
|
directory = "feature"
|
||||||
|
name = "Features"
|
||||||
|
showcontent = true
|
||||||
|
|
||||||
|
[[tool.towncrier.type]]
|
||||||
|
directory = "change"
|
||||||
|
name = "Changes"
|
||||||
|
showcontent = true
|
||||||
|
|
||||||
|
[[tool.towncrier.type]]
|
||||||
|
directory = "bugfix"
|
||||||
|
name = "Bug fixes"
|
||||||
|
showcontent = true
|
||||||
|
|
||||||
|
[[tool.towncrier.type]]
|
||||||
|
directory = "doc"
|
||||||
|
name = "Improved Documentation"
|
||||||
|
showcontent = true
|
||||||
|
|
||||||
|
[[tool.towncrier.type]]
|
||||||
|
directory = "removal"
|
||||||
|
name = "Deprecations and Removals"
|
||||||
|
showcontent = true
|
||||||
|
|
||||||
|
[[tool.towncrier.type]]
|
||||||
|
directory = "misc"
|
||||||
|
name = "Misc"
|
||||||
|
showcontent = true
|
@ -1,168 +0,0 @@
|
|||||||
import copy
|
|
||||||
import os
|
|
||||||
import argparse
|
|
||||||
import yaml
|
|
||||||
from podman_compose import normalize_service, PodmanCompose
|
|
||||||
|
|
||||||
|
|
||||||
test_cases_simple = [
|
|
||||||
({"test": "test"}, {"test": "test"}),
|
|
||||||
({"build": "."}, {"build": {"context": "."}}),
|
|
||||||
({"build": "./dir-1"}, {"build": {"context": "./dir-1"}}),
|
|
||||||
({"build": {"context": "./dir-1"}}, {"build": {"context": "./dir-1"}}),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "dockerfile-1"}},
|
|
||||||
{"build": {"dockerfile": "dockerfile-1"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"context": "./dir-1", "dockerfile": "dockerfile-1"}},
|
|
||||||
{"build": {"context": "./dir-1", "dockerfile": "dockerfile-1"}},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def test_normalize_service_simple():
|
|
||||||
for test_case, expected in copy.deepcopy(test_cases_simple):
|
|
||||||
test_original = copy.deepcopy(test_case)
|
|
||||||
test_case = normalize_service(test_case)
|
|
||||||
test_result = expected == test_case
|
|
||||||
if not test_result:
|
|
||||||
print("test: ", test_original)
|
|
||||||
print("expected: ", expected)
|
|
||||||
print("actual: ", test_case)
|
|
||||||
assert test_result
|
|
||||||
|
|
||||||
|
|
||||||
test_cases_sub_dir = [
|
|
||||||
({"test": "test"}, {"test": "test"}),
|
|
||||||
({"build": "."}, {"build": {"context": "./sub_dir/."}}),
|
|
||||||
({"build": "./dir-1"}, {"build": {"context": "./sub_dir/dir-1"}}),
|
|
||||||
({"build": {"context": "./dir-1"}}, {"build": {"context": "./sub_dir/dir-1"}}),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "dockerfile-1"}},
|
|
||||||
{"build": {"context": "./sub_dir", "dockerfile": "dockerfile-1"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"context": "./dir-1", "dockerfile": "dockerfile-1"}},
|
|
||||||
{"build": {"context": "./sub_dir/dir-1", "dockerfile": "dockerfile-1"}},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def test_normalize_service_with_sub_dir():
|
|
||||||
for test_case, expected in copy.deepcopy(test_cases_sub_dir):
|
|
||||||
test_original = copy.deepcopy(test_case)
|
|
||||||
test_case = normalize_service(test_case, sub_dir="./sub_dir")
|
|
||||||
test_result = expected == test_case
|
|
||||||
if not test_result:
|
|
||||||
print("test: ", test_original)
|
|
||||||
print("expected: ", expected)
|
|
||||||
print("actual: ", test_case)
|
|
||||||
assert test_result
|
|
||||||
|
|
||||||
|
|
||||||
test_cases_merges = [
|
|
||||||
({}, {}, {}),
|
|
||||||
({}, {"test": "test"}, {"test": "test"}),
|
|
||||||
({"test": "test"}, {}, {"test": "test"}),
|
|
||||||
({"test": "test-1"}, {"test": "test-2"}, {"test": "test-2"}),
|
|
||||||
({}, {"build": "."}, {"build": {"context": "."}}),
|
|
||||||
({"build": "."}, {}, {"build": {"context": "."}}),
|
|
||||||
({"build": "./dir-1"}, {"build": "./dir-2"}, {"build": {"context": "./dir-2"}}),
|
|
||||||
({}, {"build": {"context": "./dir-1"}}, {"build": {"context": "./dir-1"}}),
|
|
||||||
({"build": {"context": "./dir-1"}}, {}, {"build": {"context": "./dir-1"}}),
|
|
||||||
(
|
|
||||||
{"build": {"context": "./dir-1"}},
|
|
||||||
{"build": {"context": "./dir-2"}},
|
|
||||||
{"build": {"context": "./dir-2"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{},
|
|
||||||
{"build": {"dockerfile": "dockerfile-1"}},
|
|
||||||
{"build": {"dockerfile": "dockerfile-1"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "dockerfile-1"}},
|
|
||||||
{},
|
|
||||||
{"build": {"dockerfile": "dockerfile-1"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "./dockerfile-1"}},
|
|
||||||
{"build": {"dockerfile": "./dockerfile-2"}},
|
|
||||||
{"build": {"dockerfile": "./dockerfile-2"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "./dockerfile-1"}},
|
|
||||||
{"build": {"context": "./dir-2"}},
|
|
||||||
{"build": {"dockerfile": "./dockerfile-1", "context": "./dir-2"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "./dockerfile-1", "context": "./dir-1"}},
|
|
||||||
{"build": {"dockerfile": "./dockerfile-2", "context": "./dir-2"}},
|
|
||||||
{"build": {"dockerfile": "./dockerfile-2", "context": "./dir-2"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "./dockerfile-1"}},
|
|
||||||
{"build": {"dockerfile": "./dockerfile-2", "args": ["ENV1=1"]}},
|
|
||||||
{"build": {"dockerfile": "./dockerfile-2", "args": ["ENV1=1"]}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "./dockerfile-2", "args": ["ENV1=1"]}},
|
|
||||||
{"build": {"dockerfile": "./dockerfile-1"}},
|
|
||||||
{"build": {"dockerfile": "./dockerfile-1", "args": ["ENV1=1"]}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "./dockerfile-2", "args": ["ENV1=1"]}},
|
|
||||||
{"build": {"dockerfile": "./dockerfile-1", "args": ["ENV2=2"]}},
|
|
||||||
{"build": {"dockerfile": "./dockerfile-1", "args": ["ENV1=1", "ENV2=2"]}},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def test__parse_compose_file_when_multiple_composes() -> None:
|
|
||||||
for test_input, test_override, expected_result in copy.deepcopy(test_cases_merges):
|
|
||||||
compose_test_1 = {"services": {"test-service": test_input}}
|
|
||||||
compose_test_2 = {"services": {"test-service": test_override}}
|
|
||||||
dump_yaml(compose_test_1, "test-compose-1.yaml")
|
|
||||||
dump_yaml(compose_test_2, "test-compose-2.yaml")
|
|
||||||
|
|
||||||
podman_compose = PodmanCompose()
|
|
||||||
set_args(podman_compose, ["test-compose-1.yaml", "test-compose-2.yaml"])
|
|
||||||
|
|
||||||
podman_compose._parse_compose_file() # pylint: disable=protected-access
|
|
||||||
|
|
||||||
actual_compose = {}
|
|
||||||
if podman_compose.services:
|
|
||||||
podman_compose.services["test-service"].pop("_deps")
|
|
||||||
actual_compose = podman_compose.services["test-service"]
|
|
||||||
if actual_compose != expected_result:
|
|
||||||
print("compose: ", test_input)
|
|
||||||
print("override: ", test_override)
|
|
||||||
print("expected: ", expected_result)
|
|
||||||
print("actual: ", actual_compose)
|
|
||||||
|
|
||||||
compose_expected = expected_result
|
|
||||||
|
|
||||||
assert compose_expected == actual_compose
|
|
||||||
|
|
||||||
|
|
||||||
def set_args(podman_compose: PodmanCompose, file_names: list[str]) -> None:
|
|
||||||
podman_compose.global_args = argparse.Namespace()
|
|
||||||
podman_compose.global_args.file = file_names
|
|
||||||
podman_compose.global_args.project_name = None
|
|
||||||
podman_compose.global_args.env_file = None
|
|
||||||
podman_compose.global_args.profile = []
|
|
||||||
podman_compose.global_args.in_pod = True
|
|
||||||
podman_compose.global_args.no_normalize = True
|
|
||||||
|
|
||||||
|
|
||||||
def dump_yaml(compose: dict, name: str) -> None:
|
|
||||||
with open(name, "w", encoding="utf-8") as outfile:
|
|
||||||
yaml.safe_dump(compose, outfile, default_flow_style=False)
|
|
||||||
|
|
||||||
|
|
||||||
def test_clean_test_yamls() -> None:
|
|
||||||
test_files = ["test-compose-1.yaml", "test-compose-2.yaml"]
|
|
||||||
for file in test_files:
|
|
||||||
if os.path.exists(file):
|
|
||||||
os.remove(file)
|
|
@ -1,122 +0,0 @@
|
|||||||
import copy
|
|
||||||
import os
|
|
||||||
import argparse
|
|
||||||
import yaml
|
|
||||||
from podman_compose import normalize_service, PodmanCompose
|
|
||||||
|
|
||||||
test_keys = ["command", "entrypoint"]
|
|
||||||
|
|
||||||
test_cases_normalise_pre_merge = [
|
|
||||||
({"$$$": []}, {"$$$": []}),
|
|
||||||
({"$$$": ["sh"]}, {"$$$": ["sh"]}),
|
|
||||||
({"$$$": ["sh", "-c", "date"]}, {"$$$": ["sh", "-c", "date"]}),
|
|
||||||
({"$$$": "sh"}, {"$$$": ["sh"]}),
|
|
||||||
({"$$$": "sleep infinity"}, {"$$$": ["sleep", "infinity"]}),
|
|
||||||
(
|
|
||||||
{"$$$": "bash -c 'sleep infinity'"},
|
|
||||||
{"$$$": ["bash", "-c", "sleep infinity"]},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
test_cases_merges = [
|
|
||||||
({}, {"$$$": []}, {"$$$": []}),
|
|
||||||
({"$$$": []}, {}, {"$$$": []}),
|
|
||||||
({"$$$": []}, {"$$$": "sh-2"}, {"$$$": ["sh-2"]}),
|
|
||||||
({"$$$": "sh-2"}, {"$$$": []}, {"$$$": []}),
|
|
||||||
({}, {"$$$": "sh"}, {"$$$": ["sh"]}),
|
|
||||||
({"$$$": "sh"}, {}, {"$$$": ["sh"]}),
|
|
||||||
({"$$$": "sh-1"}, {"$$$": "sh-2"}, {"$$$": ["sh-2"]}),
|
|
||||||
({"$$$": ["sh-1"]}, {"$$$": "sh-2"}, {"$$$": ["sh-2"]}),
|
|
||||||
({"$$$": "sh-1"}, {"$$$": ["sh-2"]}, {"$$$": ["sh-2"]}),
|
|
||||||
({"$$$": "sh-1"}, {"$$$": ["sh-2", "sh-3"]}, {"$$$": ["sh-2", "sh-3"]}),
|
|
||||||
({"$$$": ["sh-1"]}, {"$$$": ["sh-2", "sh-3"]}, {"$$$": ["sh-2", "sh-3"]}),
|
|
||||||
({"$$$": ["sh-1", "sh-2"]}, {"$$$": ["sh-3", "sh-4"]}, {"$$$": ["sh-3", "sh-4"]}),
|
|
||||||
({}, {"$$$": ["sh-3", "sh 4"]}, {"$$$": ["sh-3", "sh 4"]}),
|
|
||||||
({"$$$": "sleep infinity"}, {"$$$": "sh"}, {"$$$": ["sh"]}),
|
|
||||||
({"$$$": "sh"}, {"$$$": "sleep infinity"}, {"$$$": ["sleep", "infinity"]}),
|
|
||||||
(
|
|
||||||
{},
|
|
||||||
{"$$$": "bash -c 'sleep infinity'"},
|
|
||||||
{"$$$": ["bash", "-c", "sleep infinity"]},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def template_to_expression(base, override, expected, key):
|
|
||||||
base_copy = copy.deepcopy(base)
|
|
||||||
override_copy = copy.deepcopy(override)
|
|
||||||
expected_copy = copy.deepcopy(expected)
|
|
||||||
|
|
||||||
expected_copy[key] = expected_copy.pop("$$$")
|
|
||||||
if "$$$" in base:
|
|
||||||
base_copy[key] = base_copy.pop("$$$")
|
|
||||||
if "$$$" in override:
|
|
||||||
override_copy[key] = override_copy.pop("$$$")
|
|
||||||
return base_copy, override_copy, expected_copy
|
|
||||||
|
|
||||||
|
|
||||||
def test_normalize_service():
|
|
||||||
for test_input_template, expected_template in test_cases_normalise_pre_merge:
|
|
||||||
for key in test_keys:
|
|
||||||
test_input, _, expected = template_to_expression(
|
|
||||||
test_input_template, {}, expected_template, key
|
|
||||||
)
|
|
||||||
test_input = normalize_service(test_input)
|
|
||||||
test_result = expected == test_input
|
|
||||||
if not test_result:
|
|
||||||
print("base_template: ", test_input_template)
|
|
||||||
print("expected: ", expected)
|
|
||||||
print("actual: ", test_input)
|
|
||||||
assert test_result
|
|
||||||
|
|
||||||
|
|
||||||
def test__parse_compose_file_when_multiple_composes() -> None:
|
|
||||||
for base_template, override_template, expected_template in copy.deepcopy(
|
|
||||||
test_cases_merges
|
|
||||||
):
|
|
||||||
for key in test_keys:
|
|
||||||
base, override, expected = template_to_expression(
|
|
||||||
base_template, override_template, expected_template, key
|
|
||||||
)
|
|
||||||
compose_test_1 = {"services": {"test-service": base}}
|
|
||||||
compose_test_2 = {"services": {"test-service": override}}
|
|
||||||
dump_yaml(compose_test_1, "test-compose-1.yaml")
|
|
||||||
dump_yaml(compose_test_2, "test-compose-2.yaml")
|
|
||||||
|
|
||||||
podman_compose = PodmanCompose()
|
|
||||||
set_args(podman_compose, ["test-compose-1.yaml", "test-compose-2.yaml"])
|
|
||||||
|
|
||||||
podman_compose._parse_compose_file() # pylint: disable=protected-access
|
|
||||||
|
|
||||||
actual = {}
|
|
||||||
if podman_compose.services:
|
|
||||||
podman_compose.services["test-service"].pop("_deps")
|
|
||||||
actual = podman_compose.services["test-service"]
|
|
||||||
if actual != expected:
|
|
||||||
print("compose: ", base)
|
|
||||||
print("override: ", override)
|
|
||||||
print("result: ", expected)
|
|
||||||
|
|
||||||
assert expected == actual
|
|
||||||
|
|
||||||
|
|
||||||
def set_args(podman_compose: PodmanCompose, file_names: list[str]) -> None:
|
|
||||||
podman_compose.global_args = argparse.Namespace()
|
|
||||||
podman_compose.global_args.file = file_names
|
|
||||||
podman_compose.global_args.project_name = None
|
|
||||||
podman_compose.global_args.env_file = None
|
|
||||||
podman_compose.global_args.profile = []
|
|
||||||
podman_compose.global_args.in_pod = True
|
|
||||||
podman_compose.global_args.no_normalize = None
|
|
||||||
|
|
||||||
|
|
||||||
def dump_yaml(compose: dict, name: str) -> None:
|
|
||||||
with open(name, "w", encoding="utf-8") as outfile:
|
|
||||||
yaml.safe_dump(compose, outfile, default_flow_style=False)
|
|
||||||
|
|
||||||
|
|
||||||
def test_clean_test_yamls() -> None:
|
|
||||||
test_files = ["test-compose-1.yaml", "test-compose-2.yaml"]
|
|
||||||
for file in test_files:
|
|
||||||
if os.path.exists(file):
|
|
||||||
os.remove(file)
|
|
@ -1,298 +0,0 @@
|
|||||||
# pylint: disable=protected-access
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import copy
|
|
||||||
import os
|
|
||||||
import yaml
|
|
||||||
from podman_compose import (
|
|
||||||
normalize_service,
|
|
||||||
normalize,
|
|
||||||
normalize_final,
|
|
||||||
normalize_service_final,
|
|
||||||
PodmanCompose,
|
|
||||||
)
|
|
||||||
|
|
||||||
cwd = os.path.abspath(".")
|
|
||||||
test_cases_simple_normalization = [
|
|
||||||
({"image": "test-image"}, {"image": "test-image"}),
|
|
||||||
(
|
|
||||||
{"build": "."},
|
|
||||||
{
|
|
||||||
"build": {"context": cwd, "dockerfile": "Dockerfile"},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": "../relative"},
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"context": os.path.normpath(os.path.join(cwd, "../relative")),
|
|
||||||
"dockerfile": "Dockerfile",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": "./relative"},
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"context": os.path.normpath(os.path.join(cwd, "./relative")),
|
|
||||||
"dockerfile": "Dockerfile",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": "/workspace/absolute"},
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"context": "/workspace/absolute",
|
|
||||||
"dockerfile": "Dockerfile",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"dockerfile": "Dockerfile",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"context": cwd,
|
|
||||||
"dockerfile": "Dockerfile",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"context": ".",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"context": cwd,
|
|
||||||
"dockerfile": "Dockerfile",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{
|
|
||||||
"build": {"context": "../", "dockerfile": "test-dockerfile"},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"context": os.path.normpath(os.path.join(cwd, "../")),
|
|
||||||
"dockerfile": "test-dockerfile",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{
|
|
||||||
"build": {"context": ".", "dockerfile": "./dev/test-dockerfile"},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"context": cwd,
|
|
||||||
"dockerfile": "./dev/test-dockerfile",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# [service.build] is normalised after merges
|
|
||||||
#
|
|
||||||
def test_normalize_service_final_returns_absolute_path_in_context() -> None:
|
|
||||||
project_dir = cwd
|
|
||||||
for test_input, expected_service in copy.deepcopy(test_cases_simple_normalization):
|
|
||||||
actual_service = normalize_service_final(test_input, project_dir)
|
|
||||||
assert expected_service == actual_service
|
|
||||||
|
|
||||||
|
|
||||||
def test_normalize_returns_absolute_path_in_context() -> None:
|
|
||||||
project_dir = cwd
|
|
||||||
for test_input, expected_result in copy.deepcopy(test_cases_simple_normalization):
|
|
||||||
compose_test = {"services": {"test-service": test_input}}
|
|
||||||
compose_expected = {"services": {"test-service": expected_result}}
|
|
||||||
actual_compose = normalize_final(compose_test, project_dir)
|
|
||||||
assert compose_expected == actual_compose
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# running full parse over single compose files
|
|
||||||
#
|
|
||||||
def test__parse_compose_file_when_single_compose() -> None:
|
|
||||||
for test_input, expected_result in copy.deepcopy(test_cases_simple_normalization):
|
|
||||||
compose_test = {"services": {"test-service": test_input}}
|
|
||||||
dump_yaml(compose_test, "test-compose.yaml")
|
|
||||||
|
|
||||||
podman_compose = PodmanCompose()
|
|
||||||
set_args(podman_compose, ["test-compose.yaml"], no_normalize=None)
|
|
||||||
|
|
||||||
podman_compose._parse_compose_file()
|
|
||||||
|
|
||||||
actual_compose = {}
|
|
||||||
if podman_compose.services:
|
|
||||||
podman_compose.services["test-service"].pop("_deps")
|
|
||||||
actual_compose = podman_compose.services["test-service"]
|
|
||||||
if actual_compose != expected_result:
|
|
||||||
print("compose: ", test_input)
|
|
||||||
print("result: ", expected_result)
|
|
||||||
|
|
||||||
assert expected_result == actual_compose
|
|
||||||
|
|
||||||
|
|
||||||
test_cases_with_merges = [
|
|
||||||
(
|
|
||||||
{},
|
|
||||||
{"build": "."},
|
|
||||||
{"build": {"context": cwd, "dockerfile": "Dockerfile"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": "."},
|
|
||||||
{},
|
|
||||||
{"build": {"context": cwd, "dockerfile": "Dockerfile"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": "/workspace/absolute"},
|
|
||||||
{"build": "./relative"},
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"context": os.path.normpath(os.path.join(cwd, "./relative")),
|
|
||||||
"dockerfile": "Dockerfile",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": "./relative"},
|
|
||||||
{"build": "/workspace/absolute"},
|
|
||||||
{"build": {"context": "/workspace/absolute", "dockerfile": "Dockerfile"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": "./relative"},
|
|
||||||
{"build": "/workspace/absolute"},
|
|
||||||
{"build": {"context": "/workspace/absolute", "dockerfile": "Dockerfile"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "test-dockerfile"}},
|
|
||||||
{},
|
|
||||||
{"build": {"context": cwd, "dockerfile": "test-dockerfile"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{},
|
|
||||||
{"build": {"dockerfile": "test-dockerfile"}},
|
|
||||||
{"build": {"context": cwd, "dockerfile": "test-dockerfile"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{},
|
|
||||||
{"build": {"dockerfile": "test-dockerfile"}},
|
|
||||||
{"build": {"context": cwd, "dockerfile": "test-dockerfile"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "test-dockerfile-1"}},
|
|
||||||
{"build": {"dockerfile": "test-dockerfile-2"}},
|
|
||||||
{"build": {"context": cwd, "dockerfile": "test-dockerfile-2"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": "/workspace/absolute"},
|
|
||||||
{"build": {"dockerfile": "test-dockerfile"}},
|
|
||||||
{"build": {"context": "/workspace/absolute", "dockerfile": "test-dockerfile"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "test-dockerfile"}},
|
|
||||||
{"build": "/workspace/absolute"},
|
|
||||||
{"build": {"context": "/workspace/absolute", "dockerfile": "test-dockerfile"}},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "./test-dockerfile-1"}},
|
|
||||||
{"build": {"dockerfile": "./test-dockerfile-2", "args": ["ENV1=1"]}},
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"context": cwd,
|
|
||||||
"dockerfile": "./test-dockerfile-2",
|
|
||||||
"args": ["ENV1=1"],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "./test-dockerfile-1", "args": ["ENV1=1"]}},
|
|
||||||
{"build": {"dockerfile": "./test-dockerfile-2"}},
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"context": cwd,
|
|
||||||
"dockerfile": "./test-dockerfile-2",
|
|
||||||
"args": ["ENV1=1"],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{"build": {"dockerfile": "./test-dockerfile-1", "args": ["ENV1=1"]}},
|
|
||||||
{"build": {"dockerfile": "./test-dockerfile-2", "args": ["ENV2=2"]}},
|
|
||||||
{
|
|
||||||
"build": {
|
|
||||||
"context": cwd,
|
|
||||||
"dockerfile": "./test-dockerfile-2",
|
|
||||||
"args": ["ENV1=1", "ENV2=2"],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# running full parse over merged
|
|
||||||
#
|
|
||||||
def test__parse_compose_file_when_multiple_composes() -> None:
|
|
||||||
for test_input, test_override, expected_result in copy.deepcopy(
|
|
||||||
test_cases_with_merges
|
|
||||||
):
|
|
||||||
compose_test_1 = {"services": {"test-service": test_input}}
|
|
||||||
compose_test_2 = {"services": {"test-service": test_override}}
|
|
||||||
dump_yaml(compose_test_1, "test-compose-1.yaml")
|
|
||||||
dump_yaml(compose_test_2, "test-compose-2.yaml")
|
|
||||||
|
|
||||||
podman_compose = PodmanCompose()
|
|
||||||
set_args(
|
|
||||||
podman_compose,
|
|
||||||
["test-compose-1.yaml", "test-compose-2.yaml"],
|
|
||||||
no_normalize=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
podman_compose._parse_compose_file()
|
|
||||||
|
|
||||||
actual_compose = {}
|
|
||||||
if podman_compose.services:
|
|
||||||
podman_compose.services["test-service"].pop("_deps")
|
|
||||||
actual_compose = podman_compose.services["test-service"]
|
|
||||||
if actual_compose != expected_result:
|
|
||||||
print("compose: ", test_input)
|
|
||||||
print("override: ", test_override)
|
|
||||||
print("result: ", expected_result)
|
|
||||||
compose_expected = expected_result
|
|
||||||
|
|
||||||
assert compose_expected == actual_compose
|
|
||||||
|
|
||||||
|
|
||||||
def set_args(
|
|
||||||
podman_compose: PodmanCompose, file_names: list[str], no_normalize: bool
|
|
||||||
) -> None:
|
|
||||||
podman_compose.global_args = argparse.Namespace()
|
|
||||||
podman_compose.global_args.file = file_names
|
|
||||||
podman_compose.global_args.project_name = None
|
|
||||||
podman_compose.global_args.env_file = None
|
|
||||||
podman_compose.global_args.profile = []
|
|
||||||
podman_compose.global_args.in_pod = True
|
|
||||||
podman_compose.global_args.no_normalize = no_normalize
|
|
||||||
|
|
||||||
|
|
||||||
def dump_yaml(compose: dict, name: str) -> None:
|
|
||||||
# Path(Path.cwd()/"subdirectory").mkdir(parents=True, exist_ok=True)
|
|
||||||
with open(name, "w", encoding="utf-8") as outfile:
|
|
||||||
yaml.safe_dump(compose, outfile, default_flow_style=False)
|
|
||||||
|
|
||||||
|
|
||||||
def test_clean_test_yamls() -> None:
|
|
||||||
test_files = ["test-compose-1.yaml", "test-compose-2.yaml", "test-compose.yaml"]
|
|
||||||
for file in test_files:
|
|
||||||
if os.path.exists(file):
|
|
||||||
os.remove(file)
|
|
@ -1,21 +0,0 @@
|
|||||||
# pylint: disable=redefined-outer-name
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from podman_compose import parse_short_mount
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def multi_propagation_mount_str():
|
|
||||||
return "/foo/bar:/baz:U,Z"
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_short_mount_multi_propagation(multi_propagation_mount_str):
|
|
||||||
expected = {
|
|
||||||
"type": "bind",
|
|
||||||
"source": "/foo/bar",
|
|
||||||
"target": "/baz",
|
|
||||||
"bind": {
|
|
||||||
"propagation": "U,Z",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
assert parse_short_mount(multi_propagation_mount_str, "/") == expected
|
|
33
scripts/Changelog-template.jinja
Normal file
33
scripts/Changelog-template.jinja
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{% for section, _ in sections|dictsort(by='key') %}
|
||||||
|
{% set underline = "-" %}
|
||||||
|
{% if section %}
|
||||||
|
{{section}}
|
||||||
|
{{ underline * section|length }}{% set underline = "~" %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% if sections[section] %}
|
||||||
|
{% for category, val in definitions|dictsort if category in sections[section]%}
|
||||||
|
|
||||||
|
{{ definitions[category]['name'] }}
|
||||||
|
{{ underline * definitions[category]['name']|length }}
|
||||||
|
|
||||||
|
{% for text, values in sections[section][category]|dictsort(by='value') %}
|
||||||
|
- {{ text }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if sections[section][category]|length == 0 %}
|
||||||
|
|
||||||
|
No significant changes.
|
||||||
|
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
No significant changes.
|
||||||
|
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
(venv) p12@exec-desktop:~/cod
|
16
scripts/download_and_build_podman-compose.sh
Normal file
16
scripts/download_and_build_podman-compose.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Delete repository dir
|
||||||
|
rm -rf podman-compose-src
|
||||||
|
|
||||||
|
# Clone repository
|
||||||
|
git clone https://github.com/containers/podman-compose podman-compose-src
|
||||||
|
|
||||||
|
# Generate binary
|
||||||
|
sh podman-compose-src/scripts/generate_binary_using_dockerfile.sh
|
||||||
|
|
||||||
|
# Move binary outside repo's dir
|
||||||
|
mv podman-compose-src/podman-compose .
|
||||||
|
|
||||||
|
# Delete repository dir
|
||||||
|
rm -rf podman-compose-src
|
57
scripts/generate_binary_using_dockerfile.sh
Normal file
57
scripts/generate_binary_using_dockerfile.sh
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Find an available container tool (docker or podman)
|
||||||
|
find_container_tool() {
|
||||||
|
if command -v docker > /dev/null 2>&1; then
|
||||||
|
echo "sudo docker"
|
||||||
|
elif command -v podman > /dev/null 2>&1; then
|
||||||
|
echo "podman"
|
||||||
|
else
|
||||||
|
echo "Error: Neither docker nor podman is available." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Determine which container tool to use
|
||||||
|
CONTAINER_TOOL=$(find_container_tool)
|
||||||
|
|
||||||
|
# Locate the directory containing dockerfile (root)
|
||||||
|
PROJECT_ROOT_DIR="$(cd "$(dirname "$0")" && pwd)/.."
|
||||||
|
|
||||||
|
# Check SELinux status and set appropriate mount option
|
||||||
|
check_selinux() {
|
||||||
|
if command -v getenforce > /dev/null 2>&1; then
|
||||||
|
SELINUX_STATUS=$(getenforce)
|
||||||
|
if [ "$SELINUX_STATUS" = "Enforcing" ] || [ "$SELINUX_STATUS" = "Permissive" ]; then
|
||||||
|
echo ":z"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
elif [ -f /sys/fs/selinux/enforce ]; then
|
||||||
|
if [ "$(cat /sys/fs/selinux/enforce)" = "1" ]; then
|
||||||
|
echo ":z"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the SELinux option for volume mounts if SELinux is enforcing or permissive
|
||||||
|
SELINUX=$(check_selinux)
|
||||||
|
|
||||||
|
# Build binary
|
||||||
|
$CONTAINER_TOOL image rm build-podman-compose
|
||||||
|
|
||||||
|
if expr "$CONTAINER_TOOL" : '.*docker.*' >/dev/null; then
|
||||||
|
$CONTAINER_TOOL build -t build-podman-compose "$PROJECT_ROOT_DIR"
|
||||||
|
$CONTAINER_TOOL run --name build-podman-compose build-podman-compose
|
||||||
|
$CONTAINER_TOOL cp build-podman-compose:/result/podman-compose "$PROJECT_ROOT_DIR/podman-compose"
|
||||||
|
$CONTAINER_TOOL container stop build-podman-compose
|
||||||
|
$CONTAINER_TOOL container rm -f build-podman-compose
|
||||||
|
else
|
||||||
|
$CONTAINER_TOOL build -v "$PROJECT_ROOT_DIR:/result$SELINUX" -t build-podman-compose "$PROJECT_ROOT_DIR"
|
||||||
|
fi
|
||||||
|
$CONTAINER_TOOL image rm python:3.11-slim
|
||||||
|
$CONTAINER_TOOL image rm build-podman-compose
|
@ -1,6 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/bin/bash
|
||||||
./scripts/uninstall.sh
|
|
||||||
./scripts/clean_up.sh
|
set -e
|
||||||
python3 setup.py register
|
|
||||||
python3 setup.py sdist bdist_wheel
|
if [ $# -ne 1 ]; then
|
||||||
twine upload dist/*
|
echo "Usage: make_release.sh VERSION"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERSION=$1
|
||||||
|
|
||||||
|
sed "s/__version__ = .*/__version__ = \"$VERSION\"/g" -i podman_compose.py
|
||||||
|
git add podman_compose.py
|
||||||
|
git commit -m "Release $VERSION"
|
||||||
|
|
||||||
|
git tag "v$VERSION" -m "v$VERSION" -s
|
||||||
|
|
||||||
|
git push ssh://github.com/containers/podman-compose main "v$VERSION"
|
||||||
|
14
scripts/make_release_notes.sh
Executable file
14
scripts/make_release_notes.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ $# -ne 1 ]; then
|
||||||
|
echo "Usage: make_release_notes.sh VERSION"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERSION=$1
|
||||||
|
towncrier build --version "$VERSION" --yes
|
||||||
|
git mv "docs/Changelog-new.md" "docs/Changelog-$VERSION.md"
|
||||||
|
git add "newsfragments/"
|
||||||
|
git commit -m "Release notes for $VERSION"
|
6
scripts/make_release_upload.sh
Executable file
6
scripts/make_release_upload.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
./scripts/uninstall.sh
|
||||||
|
./scripts/clean_up.sh
|
||||||
|
python3 setup.py register
|
||||||
|
python3 setup.py sdist bdist_wheel
|
||||||
|
twine upload dist/*
|
@ -6,4 +6,6 @@ version = attr: podman_compose.__version__
|
|||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# The GitHub editor is 127 chars wide
|
# The GitHub editor is 127 chars wide
|
||||||
max-line-length=127
|
max-line-length=127
|
||||||
|
# These are not being followed yet
|
||||||
|
ignore=E222,E231,E272,E713,W503
|
23
setup.py
23
setup.py
@ -1,10 +1,11 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
try:
|
try:
|
||||||
README = open(
|
README = open(os.path.join(os.path.dirname(__file__), "README.md"), encoding="utf-8").read()
|
||||||
os.path.join(os.path.dirname(__file__), "README.md"), encoding="utf-8"
|
|
||||||
).read()
|
|
||||||
except: # noqa: E722 # pylint: disable=bare-except
|
except: # noqa: E722 # pylint: disable=bare-except
|
||||||
README = ""
|
README = ""
|
||||||
|
|
||||||
@ -16,11 +17,11 @@ setup(
|
|||||||
classifiers=[
|
classifiers=[
|
||||||
"Programming Language :: Python",
|
"Programming Language :: Python",
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
"Programming Language :: Python :: 3.7",
|
|
||||||
"Programming Language :: Python :: 3.8",
|
|
||||||
"Programming Language :: Python :: 3.9",
|
"Programming Language :: Python :: 3.9",
|
||||||
"Programming Language :: Python :: 3.10",
|
"Programming Language :: Python :: 3.10",
|
||||||
"Programming Language :: Python :: 3.11",
|
"Programming Language :: Python :: 3.11",
|
||||||
|
"Programming Language :: Python :: 3.12",
|
||||||
|
"Programming Language :: Python :: 3.13",
|
||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 3 - Alpha",
|
||||||
@ -39,20 +40,10 @@ setup(
|
|||||||
"pyyaml",
|
"pyyaml",
|
||||||
"python-dotenv",
|
"python-dotenv",
|
||||||
],
|
],
|
||||||
extras_require={
|
extras_require={"devel": ["ruff", "pre-commit", "coverage", "parameterized"]},
|
||||||
"devel": [
|
|
||||||
"flake8",
|
|
||||||
"black",
|
|
||||||
"pylint",
|
|
||||||
"pre-commit",
|
|
||||||
"coverage"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
# test_suite='tests',
|
# test_suite='tests',
|
||||||
# tests_require=[
|
# tests_require=[
|
||||||
# 'coverage',
|
# 'coverage',
|
||||||
# 'pytest-cov',
|
|
||||||
# 'pytest',
|
|
||||||
# 'tox',
|
# 'tox',
|
||||||
# ]
|
# ]
|
||||||
)
|
)
|
||||||
|
@ -1,9 +1,34 @@
|
|||||||
# The order of packages is significant, because pip processes them in the order
|
-e .
|
||||||
# of appearance. Changing the order has an impact on the overall integration
|
coverage==7.4.3
|
||||||
# process, which may cause wedges in the gate later.
|
parameterized==0.9.0
|
||||||
|
pytest==8.0.2
|
||||||
|
tox==4.13.0
|
||||||
|
ruff==0.3.1
|
||||||
|
pylint==3.1.0
|
||||||
|
|
||||||
coverage
|
# The packages below are transitive dependencies of the packages above and are included here
|
||||||
pytest
|
# to make testing reproducible.
|
||||||
tox
|
# To refresh, create a new virtualenv and do:
|
||||||
black
|
# pip install -r requirements.txt -r test-requirements.txt
|
||||||
flake8
|
# pip freeze > test-requirements.txt
|
||||||
|
# and edit test-requirements.txt to add this comment
|
||||||
|
|
||||||
|
astroid==3.1.0
|
||||||
|
cachetools==5.3.3
|
||||||
|
chardet==5.2.0
|
||||||
|
colorama==0.4.6
|
||||||
|
dill==0.3.8
|
||||||
|
distlib==0.3.8
|
||||||
|
filelock==3.13.1
|
||||||
|
iniconfig==2.0.0
|
||||||
|
isort==5.13.2
|
||||||
|
mccabe==0.7.0
|
||||||
|
packaging==23.2
|
||||||
|
platformdirs==4.2.0
|
||||||
|
pluggy==1.4.0
|
||||||
|
pyproject-api==1.6.1
|
||||||
|
python-dotenv==1.0.1
|
||||||
|
PyYAML==6.0.1
|
||||||
|
requests
|
||||||
|
tomlkit==0.12.4
|
||||||
|
virtualenv==20.26.6
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
# Test podman-compose with build
|
|
||||||
|
|
||||||
```
|
|
||||||
podman-compose build
|
|
||||||
podman-compose up -d
|
|
||||||
curl http://localhost:8080/index.txt
|
|
||||||
curl http://localhost:8000/index.txt
|
|
||||||
podman inspect my-busybox-httpd2
|
|
||||||
podman-compose down
|
|
||||||
```
|
|
||||||
|
|
||||||
expected output would be something like
|
|
||||||
|
|
||||||
```
|
|
||||||
2019-09-03T15:16:38+0000
|
|
||||||
ALT buildno=2 port 8000 2019-09-03T15:16:38+0000
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
as you can see we were able to override buildno to be 2 instead of 1,
|
|
||||||
and httpd_port to 8000.
|
|
||||||
|
|
||||||
NOTE: build labels are not passed to `podman build`
|
|
@ -1,22 +0,0 @@
|
|||||||
# Test podman-compose with build (fail scenario)
|
|
||||||
|
|
||||||
```shell
|
|
||||||
podman-compose build || echo $?
|
|
||||||
```
|
|
||||||
|
|
||||||
expected output would be something like
|
|
||||||
|
|
||||||
```
|
|
||||||
STEP 1/3: FROM busybox
|
|
||||||
STEP 2/3: RUN this_command_does_not_exist
|
|
||||||
/bin/sh: this_command_does_not_exist: not found
|
|
||||||
Error: building at STEP "RUN this_command_does_not_exist": while running runtime: exit status 127
|
|
||||||
|
|
||||||
exit code: 127
|
|
||||||
```
|
|
||||||
|
|
||||||
Expected `podman-compose` exit code:
|
|
||||||
```shell
|
|
||||||
echo $?
|
|
||||||
127
|
|
||||||
```
|
|
@ -1,26 +0,0 @@
|
|||||||
"""conftest.py
|
|
||||||
|
|
||||||
Defines global pytest fixtures available to all tests.
|
|
||||||
"""
|
|
||||||
# pylint: disable=redefined-outer-name
|
|
||||||
from pathlib import Path
|
|
||||||
import os
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def base_path():
|
|
||||||
"""Returns the base path for the project"""
|
|
||||||
return Path(__file__).parent.parent
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def test_path(base_path):
|
|
||||||
"""Returns the path to the tests directory"""
|
|
||||||
return os.path.join(base_path, "tests")
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def podman_compose_path(base_path):
|
|
||||||
"""Returns the path to the podman compose script"""
|
|
||||||
return os.path.join(base_path, "podman_compose.py")
|
|
@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
```
|
|
||||||
podman-compose run --rm sleep /bin/sh -c 'wget -O - http://web:8000/hosts'
|
|
||||||
```
|
|
@ -1,25 +0,0 @@
|
|||||||
version: "3.7"
|
|
||||||
services:
|
|
||||||
web:
|
|
||||||
image: busybox
|
|
||||||
command: ["/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"]
|
|
||||||
tmpfs:
|
|
||||||
- /run
|
|
||||||
- /tmp
|
|
||||||
sleep:
|
|
||||||
image: busybox
|
|
||||||
command: ["/bin/busybox", "sh", "-c", "sleep 3600"]
|
|
||||||
depends_on:
|
|
||||||
- "web"
|
|
||||||
tmpfs:
|
|
||||||
- /run
|
|
||||||
- /tmp
|
|
||||||
sleep2:
|
|
||||||
image: busybox
|
|
||||||
command: ["/bin/busybox", "sh", "-c", "sleep 3600"]
|
|
||||||
depends_on:
|
|
||||||
- sleep
|
|
||||||
tmpfs:
|
|
||||||
- /run
|
|
||||||
- /tmp
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
running the following commands should always give podman-rocks-123
|
|
||||||
|
|
||||||
```
|
|
||||||
podman-compose -f project/container-compose.yaml --env-file env-files/project-1.env up
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
podman-compose -f $(pwd)/project/container-compose.yaml --env-file $(pwd)/env-files/project-1.env up
|
|
||||||
```
|
|
@ -1 +0,0 @@
|
|||||||
ZZVAR1=podman-rocks-123
|
|
@ -1,5 +0,0 @@
|
|||||||
running the following command should give myval2
|
|
||||||
|
|
||||||
```
|
|
||||||
podman_compose run -l monkey -e ZZVAR1=myval2 env-test
|
|
||||||
```
|
|
@ -1,9 +0,0 @@
|
|||||||
version: '3'
|
|
||||||
|
|
||||||
services:
|
|
||||||
env-test:
|
|
||||||
image: busybox
|
|
||||||
command: sh -c "export | grep ZZ"
|
|
||||||
environment:
|
|
||||||
- ZZVAR1=myval1
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
We have service named sh1 that exits with code 1 and sh2 that exists with code 2
|
|
||||||
|
|
||||||
```
|
|
||||||
podman-compose up --exit-code-from=sh1
|
|
||||||
echo $?
|
|
||||||
```
|
|
||||||
|
|
||||||
the above should give 1.
|
|
||||||
|
|
||||||
```
|
|
||||||
podman-compose up --exit-code-from=sh2
|
|
||||||
echo $?
|
|
||||||
```
|
|
||||||
|
|
||||||
the above should give 2.
|
|
@ -1,21 +0,0 @@
|
|||||||
version: "3"
|
|
||||||
services:
|
|
||||||
too_long:
|
|
||||||
image: busybox
|
|
||||||
command: ["/bin/busybox", "sh", "-c", "sleep 3600; exit 0"]
|
|
||||||
tmpfs:
|
|
||||||
- /run
|
|
||||||
- /tmp
|
|
||||||
sh1:
|
|
||||||
image: busybox
|
|
||||||
command: ["/bin/busybox", "sh", "-c", "sleep 5; exit 1"]
|
|
||||||
tmpfs:
|
|
||||||
- /run
|
|
||||||
- /tmp
|
|
||||||
sh2:
|
|
||||||
image: busybox
|
|
||||||
command: ["/bin/busybox", "sh", "-c", "sleep 5; exit 2"]
|
|
||||||
tmpfs:
|
|
||||||
- /run
|
|
||||||
- /tmp
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
FROM busybox as base
|
|
@ -1,7 +0,0 @@
|
|||||||
version: '3.6'
|
|
||||||
|
|
||||||
services:
|
|
||||||
web:
|
|
||||||
image: busybox
|
|
||||||
command: ["/bin/busybox", "httpd", "-f", "-h", ".", "-p", "8003"]
|
|
||||||
|
|
12
tests/integration/__init__.py
Normal file
12
tests/integration/__init__.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
def create_base_test_image():
|
||||||
|
subprocess.check_call(
|
||||||
|
['podman', 'build', '-t', 'nopush/podman-compose-test', '.'],
|
||||||
|
cwd=os.path.join(os.path.dirname(__file__), "base_image"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
create_base_test_image()
|
11
tests/integration/abort/docker-compose-fail-first.yaml
Normal file
11
tests/integration/abort/docker-compose-fail-first.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
sh1:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 1; exit 1"]
|
||||||
|
sh2:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 2; exit 0"]
|
||||||
|
sh3:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3; exit 0"]
|
11
tests/integration/abort/docker-compose-fail-none.yaml
Normal file
11
tests/integration/abort/docker-compose-fail-none.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
sh1:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 1; exit 0"]
|
||||||
|
sh2:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 2; exit 0"]
|
||||||
|
sh3:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3; exit 0"]
|
11
tests/integration/abort/docker-compose-fail-second.yaml
Normal file
11
tests/integration/abort/docker-compose-fail-second.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
sh1:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 1; exit 0"]
|
||||||
|
sh2:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 2; exit 1"]
|
||||||
|
sh3:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3; exit 0"]
|
@ -0,0 +1,11 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
sh1:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 1; exit 1"]
|
||||||
|
sh2:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 1; exit 0"]
|
||||||
|
sh3:
|
||||||
|
image: nopush/podman-compose-test
|
||||||
|
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 2; exit 0"]
|
46
tests/integration/abort/test_podman_compose_abort.py
Normal file
46
tests/integration/abort/test_podman_compose_abort.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from parameterized import parameterized
|
||||||
|
|
||||||
|
from tests.integration.test_utils import RunSubprocessMixin
|
||||||
|
from tests.integration.test_utils import podman_compose_path
|
||||||
|
from tests.integration.test_utils import test_path
|
||||||
|
|
||||||
|
|
||||||
|
def compose_yaml_path(failure_order):
|
||||||
|
return os.path.join(test_path(), "abort", f"docker-compose-fail-{failure_order}.yaml")
|
||||||
|
|
||||||
|
|
||||||
|
class TestComposeAbort(unittest.TestCase, RunSubprocessMixin):
|
||||||
|
@parameterized.expand([
|
||||||
|
("exit", "first", 0),
|
||||||
|
("failure", "first", 1),
|
||||||
|
("exit", "second", 0),
|
||||||
|
("failure", "second", 1),
|
||||||
|
("exit", "simultaneous", 0),
|
||||||
|
("failure", "simultaneous", 1),
|
||||||
|
("exit", "none", 0),
|
||||||
|
("failure", "none", 0),
|
||||||
|
])
|
||||||
|
def test_abort(self, abort_type, failure_order, expected_exit_code):
|
||||||
|
try:
|
||||||
|
self.run_subprocess_assert_returncode(
|
||||||
|
[
|
||||||
|
podman_compose_path(),
|
||||||
|
"-f",
|
||||||
|
compose_yaml_path(failure_order),
|
||||||
|
"up",
|
||||||
|
f"--abort-on-container-{abort_type}",
|
||||||
|
],
|
||||||
|
expected_exit_code,
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
self.run_subprocess_assert_returncode([
|
||||||
|
podman_compose_path(),
|
||||||
|
"-f",
|
||||||
|
compose_yaml_path(failure_order),
|
||||||
|
"down",
|
||||||
|
])
|
14
tests/integration/additional_contexts/README.md
Normal file
14
tests/integration/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/integration/additional_contexts/__init__.py
Normal file
1
tests/integration/additional_contexts/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
Data for dict
|
@ -0,0 +1 @@
|
|||||||
|
Data for list
|
3
tests/integration/additional_contexts/project/Dockerfile
Normal file
3
tests/integration/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"]
|
@ -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
|
@ -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 tests.integration.test_utils import podman_compose_path
|
||||||
|
from tests.integration.test_utils 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)
|
6
tests/integration/base_image/Dockerfile
Normal file
6
tests/integration/base_image/Dockerfile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
FROM docker.io/library/debian:bookworm-slim
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y \
|
||||||
|
dumb-init \
|
||||||
|
busybox \
|
||||||
|
wget
|
1
tests/integration/build/__init__.py
Normal file
1
tests/integration/build/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
1
tests/integration/build/git_url_context/__init__.py
Normal file
1
tests/integration/build/git_url_context/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
test_context:
|
||||||
|
build:
|
||||||
|
context: https://github.com/mokibit/test-git-url-as-context.git
|
||||||
|
image: test-git-url-as-context
|
||||||
|
test_context_inline:
|
||||||
|
build: https://github.com/mokibit/test-git-url-as-context.git
|
||||||
|
image: test-git-url-as-context-inline
|
@ -0,0 +1,55 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
import os
|
||||||
|
from parameterized import parameterized
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from tests.integration.test_utils import podman_compose_path
|
||||||
|
from tests.integration.test_utils import test_path
|
||||||
|
from tests.integration.test_utils import RunSubprocessMixin
|
||||||
|
|
||||||
|
|
||||||
|
def compose_yaml_path():
|
||||||
|
""" "Returns the path to the compose file used for this test module"""
|
||||||
|
base_path = os.path.join(test_path(), "build/git_url_context")
|
||||||
|
return os.path.join(base_path, "docker-compose.yml")
|
||||||
|
|
||||||
|
|
||||||
|
class TestComposeBuildGitUrlAsContext(unittest.TestCase, RunSubprocessMixin):
|
||||||
|
@parameterized.expand([
|
||||||
|
("git_url_context_test_context_1", "data_1.txt", b'test1\r\n'),
|
||||||
|
("git_url_context_test_context_1", "data_2.txt", b'test2\r\n'),
|
||||||
|
("git_url_context_test_context_inline_1", "data_1.txt", b'test1\r\n'),
|
||||||
|
("git_url_context_test_context_inline_1", "data_2.txt", b'test2\r\n'),
|
||||||
|
])
|
||||||
|
def test_build_git_url_as_context(self, container_name, file_name, output):
|
||||||
|
# test if container can access specific files from git repository when git url is used as
|
||||||
|
# a build context
|
||||||
|
try:
|
||||||
|
out, _ = self.run_subprocess_assert_returncode([
|
||||||
|
podman_compose_path(),
|
||||||
|
"-f",
|
||||||
|
compose_yaml_path(),
|
||||||
|
"up",
|
||||||
|
"-d",
|
||||||
|
])
|
||||||
|
|
||||||
|
out, _ = self.run_subprocess_assert_returncode([
|
||||||
|
"podman",
|
||||||
|
"exec",
|
||||||
|
"-ti",
|
||||||
|
f"{container_name}",
|
||||||
|
"sh",
|
||||||
|
"-c",
|
||||||
|
f"cat {file_name}",
|
||||||
|
])
|
||||||
|
self.assertEqual(out, output)
|
||||||
|
finally:
|
||||||
|
out, _ = self.run_subprocess_assert_returncode([
|
||||||
|
podman_compose_path(),
|
||||||
|
"-f",
|
||||||
|
compose_yaml_path(),
|
||||||
|
"down",
|
||||||
|
"-t",
|
||||||
|
"0",
|
||||||
|
])
|
65
tests/integration/build/test_podman_compose_build.py
Normal file
65
tests/integration/build/test_podman_compose_build.py
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from tests.integration.test_utils import podman_compose_path
|
||||||
|
from tests.integration.test_utils import test_path
|
||||||
|
from tests.integration.test_utils import RunSubprocessMixin
|
||||||
|
|
||||||
|
|
||||||
|
def compose_yaml_path():
|
||||||
|
""" "Returns the path to the compose file used for this test module"""
|
||||||
|
base_path = os.path.join(test_path(), "build")
|
||||||
|
return os.path.join(base_path, "docker-compose.yml")
|
||||||
|
|
||||||
|
|
||||||
|
class TestComposeBuild(unittest.TestCase, RunSubprocessMixin):
|
||||||
|
def test_build(self):
|
||||||
|
try:
|
||||||
|
self.run_subprocess_assert_returncode([
|
||||||
|
podman_compose_path(),
|
||||||
|
"-f",
|
||||||
|
compose_yaml_path(),
|
||||||
|
"build",
|
||||||
|
"--no-cache",
|
||||||
|
])
|
||||||
|
|
||||||
|
self.run_subprocess_assert_returncode([
|
||||||
|
podman_compose_path(),
|
||||||
|
"-f",
|
||||||
|
compose_yaml_path(),
|
||||||
|
"up",
|
||||||
|
"-d",
|
||||||
|
])
|
||||||
|
|
||||||
|
request = requests.get('http://localhost:8080/index.txt')
|
||||||
|
self.assertEqual(request.status_code, 200)
|
||||||
|
|
||||||
|
alt_request_success = False
|
||||||
|
try:
|
||||||
|
# FIXME: suspicious behaviour, too often ends up in error
|
||||||
|
alt_request = requests.get('http://localhost:8000/index.txt')
|
||||||
|
self.assertEqual(alt_request.status_code, 200)
|
||||||
|
self.assertIn("ALT buildno=2 port=8000 ", alt_request.text)
|
||||||
|
alt_request_success = True
|
||||||
|
except requests.exceptions.ConnectionError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if alt_request_success:
|
||||||
|
output, _ = self.run_subprocess_assert_returncode([
|
||||||
|
"podman",
|
||||||
|
"inspect",
|
||||||
|
"my-busybox-httpd2",
|
||||||
|
])
|
||||||
|
self.assertIn("httpd_port=8000", str(output))
|
||||||
|
self.assertIn("buildno=2", str(output))
|
||||||
|
finally:
|
||||||
|
self.run_subprocess_assert_returncode([
|
||||||
|
podman_compose_path(),
|
||||||
|
"-f",
|
||||||
|
compose_yaml_path(),
|
||||||
|
"down",
|
||||||
|
])
|
1
tests/integration/build_fail/__init__.py
Normal file
1
tests/integration/build_fail/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
@ -0,0 +1,30 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from tests.integration.test_utils import RunSubprocessMixin
|
||||||
|
from tests.integration.test_utils import podman_compose_path
|
||||||
|
from tests.integration.test_utils import test_path
|
||||||
|
|
||||||
|
|
||||||
|
def compose_yaml_path():
|
||||||
|
""" "Returns the path to the compose file used for this test module"""
|
||||||
|
base_path = os.path.join(test_path(), "build_fail")
|
||||||
|
return os.path.join(base_path, "docker-compose.yml")
|
||||||
|
|
||||||
|
|
||||||
|
class TestComposeBuildFail(unittest.TestCase, RunSubprocessMixin):
|
||||||
|
def test_build_fail(self):
|
||||||
|
output, error = self.run_subprocess_assert_returncode(
|
||||||
|
[
|
||||||
|
podman_compose_path(),
|
||||||
|
"-f",
|
||||||
|
compose_yaml_path(),
|
||||||
|
"build",
|
||||||
|
],
|
||||||
|
expected_returncode=127,
|
||||||
|
)
|
||||||
|
self.assertIn("RUN this_command_does_not_exist", str(output))
|
||||||
|
self.assertIn("this_command_does_not_exist: not found", str(error))
|
||||||
|
self.assertIn("while running runtime: exit status 127", str(error))
|
3
tests/integration/build_fail_multi/bad/Dockerfile
Normal file
3
tests/integration/build_fail_multi/bad/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
FROM busybox
|
||||||
|
|
||||||
|
RUN false
|
8
tests/integration/build_fail_multi/docker-compose.yml
Normal file
8
tests/integration/build_fail_multi/docker-compose.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
bad:
|
||||||
|
build:
|
||||||
|
context: bad
|
||||||
|
good:
|
||||||
|
build:
|
||||||
|
context: good
|
3
tests/integration/build_fail_multi/good/Dockerfile
Normal file
3
tests/integration/build_fail_multi/good/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
FROM busybox
|
||||||
|
#ensure that this build finishes second so that it has a chance to overwrite the return code
|
||||||
|
RUN sleep 0.5
|
@ -0,0 +1,31 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from tests.integration.test_utils import RunSubprocessMixin
|
||||||
|
from tests.integration.test_utils import podman_compose_path
|
||||||
|
from tests.integration.test_utils import test_path
|
||||||
|
|
||||||
|
|
||||||
|
def compose_yaml_path():
|
||||||
|
""" "Returns the path to the compose file used for this test module"""
|
||||||
|
base_path = os.path.join(test_path(), "build_fail_multi")
|
||||||
|
return os.path.join(base_path, "docker-compose.yml")
|
||||||
|
|
||||||
|
|
||||||
|
class TestComposeBuildFailMulti(unittest.TestCase, RunSubprocessMixin):
|
||||||
|
def test_build_fail_multi(self):
|
||||||
|
output, error = self.run_subprocess_assert_returncode(
|
||||||
|
[
|
||||||
|
podman_compose_path(),
|
||||||
|
"-f",
|
||||||
|
compose_yaml_path(),
|
||||||
|
"build",
|
||||||
|
# prevent the successful build from being cached to ensure it runs long enough
|
||||||
|
"--no-cache",
|
||||||
|
],
|
||||||
|
expected_returncode=1,
|
||||||
|
)
|
||||||
|
self.assertIn("RUN false", str(output))
|
||||||
|
self.assertIn("while running runtime: exit status 1", str(error))
|
0
tests/integration/build_labels/__init__.py
Normal file
0
tests/integration/build_labels/__init__.py
Normal file
1
tests/integration/build_labels/context/Dockerfile
Normal file
1
tests/integration/build_labels/context/Dockerfile
Normal file
@ -0,0 +1 @@
|
|||||||
|
FROM busybox
|
22
tests/integration/build_labels/docker-compose.yml
Normal file
22
tests/integration/build_labels/docker-compose.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
test_build_labels_map:
|
||||||
|
build:
|
||||||
|
context: ./context
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
labels:
|
||||||
|
com.example.description: "Accounting webapp"
|
||||||
|
com.example.department: "Finance"
|
||||||
|
com.example.label-with-empty-value: ""
|
||||||
|
image: my-busybox-build-labels-map
|
||||||
|
command: env
|
||||||
|
test_build_labels_array:
|
||||||
|
build:
|
||||||
|
context: ./context
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
labels:
|
||||||
|
- "com.example.description=Accounting webapp"
|
||||||
|
- "com.example.department=Finance"
|
||||||
|
- "com.example.label-with-empty-value"
|
||||||
|
image: my-busybox-build-labels-array
|
||||||
|
command: env
|
60
tests/integration/build_labels/test_build_labels.py
Normal file
60
tests/integration/build_labels/test_build_labels.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from tests.integration.test_utils import RunSubprocessMixin
|
||||||
|
from tests.integration.test_utils import podman_compose_path
|
||||||
|
from tests.integration.test_utils import test_path
|
||||||
|
|
||||||
|
|
||||||
|
class TestBuildLabels(unittest.TestCase, RunSubprocessMixin):
|
||||||
|
def test_build_labels(self):
|
||||||
|
"""The build context can contain labels which should be added to the resulting image. They
|
||||||
|
can be either an array or a map.
|
||||||
|
"""
|
||||||
|
|
||||||
|
compose_path = os.path.join(test_path(), "build_labels/docker-compose.yml")
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.run_subprocess_assert_returncode([
|
||||||
|
podman_compose_path(),
|
||||||
|
"-f",
|
||||||
|
compose_path,
|
||||||
|
"build",
|
||||||
|
"test_build_labels_map",
|
||||||
|
"test_build_labels_array",
|
||||||
|
])
|
||||||
|
|
||||||
|
expected_labels = {
|
||||||
|
"com.example.department": "Finance",
|
||||||
|
"com.example.description": "Accounting webapp",
|
||||||
|
"com.example.label-with-empty-value": "",
|
||||||
|
}
|
||||||
|
|
||||||
|
out, _ = self.run_subprocess_assert_returncode([
|
||||||
|
"podman",
|
||||||
|
"inspect",
|
||||||
|
"my-busybox-build-labels-map",
|
||||||
|
"my-busybox-build-labels-array",
|
||||||
|
])
|
||||||
|
|
||||||
|
images = json.loads(out)
|
||||||
|
self.assertEqual(len(images), 2)
|
||||||
|
labels_map = images[0].get("Config", {}).get("Labels", {})
|
||||||
|
labels_array = images[1].get("Config", {}).get("Labels", {})
|
||||||
|
for k, v in expected_labels.items():
|
||||||
|
self.assertIn(k, labels_map)
|
||||||
|
self.assertEqual(labels_map[k], v)
|
||||||
|
self.assertIn(k, labels_array)
|
||||||
|
self.assertEqual(labels_array[k], v)
|
||||||
|
|
||||||
|
finally:
|
||||||
|
self.run_subprocess_assert_returncode([
|
||||||
|
"podman",
|
||||||
|
"rmi",
|
||||||
|
"my-busybox-build-labels-map",
|
||||||
|
"my-busybox-build-labels-array",
|
||||||
|
])
|
9
tests/integration/build_secrets/Dockerfile
Normal file
9
tests/integration/build_secrets/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM busybox
|
||||||
|
|
||||||
|
RUN --mount=type=secret,required=true,id=build_secret \
|
||||||
|
ls -l /run/secrets/ && cat /run/secrets/build_secret
|
||||||
|
|
||||||
|
RUN --mount=type=secret,required=true,id=build_secret,target=/tmp/secret \
|
||||||
|
ls -l /run/secrets/ /tmp/ && cat /tmp/secret
|
||||||
|
|
||||||
|
CMD [ 'echo', 'nothing here' ]
|
1
tests/integration/build_secrets/__init__.py
Normal file
1
tests/integration/build_secrets/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
22
tests/integration/build_secrets/docker-compose.yaml
Normal file
22
tests/integration/build_secrets/docker-compose.yaml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
test:
|
||||||
|
image: test
|
||||||
|
secrets:
|
||||||
|
- run_secret # implicitly mount to /run/secrets/run_secret
|
||||||
|
- source: run_secret
|
||||||
|
target: /tmp/run_secret2 # explicit mount point
|
||||||
|
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
secrets:
|
||||||
|
- build_secret # can be mounted in Dockerfile with "RUN --mount=type=secret,id=build_secret"
|
||||||
|
- source: build_secret
|
||||||
|
target: build_secret2 # rename to build_secret2
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
build_secret:
|
||||||
|
file: ./my_secret
|
||||||
|
run_secret:
|
||||||
|
file: ./my_secret
|
18
tests/integration/build_secrets/docker-compose.yaml.invalid
Normal file
18
tests/integration/build_secrets/docker-compose.yaml.invalid
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
test:
|
||||||
|
image: test
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
secrets:
|
||||||
|
# invalid target argument
|
||||||
|
#
|
||||||
|
# According to https://github.com/compose-spec/compose-spec/blob/master/build.md, target is
|
||||||
|
# supposed to be the "name of a *file* to be mounted in /run/secrets/". Not a path.
|
||||||
|
- source: build_secret
|
||||||
|
target: /build_secret
|
||||||
|
|
||||||
|
secrets:
|
||||||
|
build_secret:
|
||||||
|
file: ./my_secret
|
@ -0,0 +1,90 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
|
||||||
|
"""Test how secrets in files are passed to podman."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from tests.integration.test_utils import podman_compose_path
|
||||||
|
from tests.integration.test_utils 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(), "build_secrets")
|
||||||
|
|
||||||
|
|
||||||
|
class TestComposeBuildSecrets(unittest.TestCase):
|
||||||
|
def test_run_secret(self):
|
||||||
|
"""podman run should receive file secrets as --volume
|
||||||
|
|
||||||
|
See build_secrets/docker-compose.yaml for secret names and mount points (aka targets)
|
||||||
|
|
||||||
|
"""
|
||||||
|
cmd = (
|
||||||
|
"coverage",
|
||||||
|
"run",
|
||||||
|
podman_compose_path(),
|
||||||
|
"--dry-run",
|
||||||
|
"--verbose",
|
||||||
|
"-f",
|
||||||
|
os.path.join(compose_yaml_path(), "docker-compose.yaml"),
|
||||||
|
"run",
|
||||||
|
"test",
|
||||||
|
)
|
||||||
|
p = subprocess.run(
|
||||||
|
cmd, stdout=subprocess.PIPE, check=False, stderr=subprocess.STDOUT, text=True
|
||||||
|
)
|
||||||
|
self.assertEqual(p.returncode, 0)
|
||||||
|
secret_path = os.path.join(compose_yaml_path(), "my_secret")
|
||||||
|
self.assertIn(f"--volume {secret_path}:/run/secrets/run_secret:ro,rprivate,rbind", p.stdout)
|
||||||
|
self.assertIn(f"--volume {secret_path}:/tmp/run_secret2:ro,rprivate,rbind", p.stdout)
|
||||||
|
|
||||||
|
def test_build_secret(self):
|
||||||
|
"""podman build should receive secrets as --secret, so that they can be used inside the
|
||||||
|
Dockerfile in "RUN --mount=type=secret ..." commands.
|
||||||
|
|
||||||
|
"""
|
||||||
|
cmd = (
|
||||||
|
"coverage",
|
||||||
|
"run",
|
||||||
|
podman_compose_path(),
|
||||||
|
"--dry-run",
|
||||||
|
"--verbose",
|
||||||
|
"-f",
|
||||||
|
os.path.join(compose_yaml_path(), "docker-compose.yaml"),
|
||||||
|
"build",
|
||||||
|
)
|
||||||
|
p = subprocess.run(
|
||||||
|
cmd, stdout=subprocess.PIPE, check=False, stderr=subprocess.STDOUT, text=True
|
||||||
|
)
|
||||||
|
self.assertEqual(p.returncode, 0)
|
||||||
|
secret_path = os.path.join(compose_yaml_path(), "my_secret")
|
||||||
|
self.assertIn(f"--secret id=build_secret,src={secret_path}", p.stdout)
|
||||||
|
self.assertIn(f"--secret id=build_secret2,src={secret_path}", p.stdout)
|
||||||
|
|
||||||
|
def test_invalid_build_secret(self):
|
||||||
|
"""build secrets in docker-compose file can only have a target argument without directory
|
||||||
|
component
|
||||||
|
|
||||||
|
"""
|
||||||
|
cmd = (
|
||||||
|
"coverage",
|
||||||
|
"run",
|
||||||
|
podman_compose_path(),
|
||||||
|
"--dry-run",
|
||||||
|
"--verbose",
|
||||||
|
"-f",
|
||||||
|
os.path.join(compose_yaml_path(), "docker-compose.yaml.invalid"),
|
||||||
|
"build",
|
||||||
|
)
|
||||||
|
p = subprocess.run(
|
||||||
|
cmd, stdout=subprocess.PIPE, check=False, stderr=subprocess.STDOUT, text=True
|
||||||
|
)
|
||||||
|
self.assertNotEqual(p.returncode, 0)
|
||||||
|
self.assertIn(
|
||||||
|
'ValueError: ERROR: Build secret "build_secret" has invalid target "/build_secret"',
|
||||||
|
p.stdout,
|
||||||
|
)
|
16
tests/integration/build_ssh/context/Dockerfile
Normal file
16
tests/integration/build_ssh/context/Dockerfile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Base image
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
# Install OpenSSH client
|
||||||
|
RUN apk add openssh
|
||||||
|
|
||||||
|
# Test the SSH agents during the build
|
||||||
|
|
||||||
|
RUN echo -n "default: " >> /result.log
|
||||||
|
RUN --mount=type=ssh ssh-add -L >> /result.log
|
||||||
|
|
||||||
|
RUN echo -n "id1: " >> /result.log
|
||||||
|
RUN --mount=type=ssh,id=id1 ssh-add -L >> /result.log
|
||||||
|
|
||||||
|
RUN echo -n "id2: " >> /result.log
|
||||||
|
RUN --mount=type=ssh,id=id2 ssh-add -L >> /result.log
|
26
tests/integration/build_ssh/docker-compose.yml
Normal file
26
tests/integration/build_ssh/docker-compose.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
test_build_ssh_map:
|
||||||
|
build:
|
||||||
|
context: ./context
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ssh:
|
||||||
|
default:
|
||||||
|
id1: "./id_ed25519_dummy"
|
||||||
|
id2: "./agent_dummy.sock"
|
||||||
|
image: my-alpine-build-ssh-map
|
||||||
|
command:
|
||||||
|
- cat
|
||||||
|
- /result.log
|
||||||
|
test_build_ssh_array:
|
||||||
|
build:
|
||||||
|
context: ./context
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ssh:
|
||||||
|
- default
|
||||||
|
- "id1=./id_ed25519_dummy"
|
||||||
|
- "id2=./agent_dummy.sock"
|
||||||
|
image: my-alpine-build-ssh-array
|
||||||
|
command:
|
||||||
|
- cat
|
||||||
|
- /result.log
|
7
tests/integration/build_ssh/id_ed25519_dummy
Normal file
7
tests/integration/build_ssh/id_ed25519_dummy
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||||
|
QyNTUxOQAAACBWELzfWvraCAeo0rOM2OxTGqWZx7fNBCglK/1oS8FLpgAAAJhzHuERcx7h
|
||||||
|
EQAAAAtzc2gtZWQyNTUxOQAAACBWELzfWvraCAeo0rOM2OxTGqWZx7fNBCglK/1oS8FLpg
|
||||||
|
AAAEAEIrYvY3jJ2IvAnUa5jIrVe8UG+7G7PzWzZqqBQykZllYQvN9a+toIB6jSs4zY7FMa
|
||||||
|
pZnHt80EKCUr/WhLwUumAAAADnJpbmdvQGJuZHRib3gyAQIDBAUGBw==
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user