containers / containers/podman-compose

Merging multiple compose files containing include in wrong order

Open
#1,300 1 comment 1 reaction 0 assignees View on GitHub
bug
Dominant language
Python
Stars
6.2k
Forks
622
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

If you pass multiple compoe files (multiple `-f`) the files get merged in the wrong order.

This only happens if the file which includes other files are not at the last position.

**To Reproduce**

We need a project containing of multiple compose files like
```
/dev.yml
/dev/db.yml
/foo.yml
```

```yaml
# /dev.yml
include:
- ./dev/db.yml
```

```yaml
# /dev/db.yml
services:
db:
image: ubuntu
```

```yaml
# /foo.yml
services:
db:
image: debian
```

Steps to reproduce the behavior:
1. call `podman-compose -f dev.yml -f foo.yml config

**Expected behavior**
The service `db` should have `image: debian`.

**Actual behavior**
The service `db` should have `image: debian`.

**Additional context**

The problem is that includes files are just [appended to the list of files](https://github.com/containers/podman-compose/blob/a1f3befa8ea5c9aa0c84efb9c1f7a267c6cc0c1a/podman_compose.py#L2379). But it should be inserted into the files list after the current processing file!

So the file list looks like
```python
[
"/dev.yml", # first cmd parameter
"/foo.yml", # second cmd parameter
"/dev/db.yml" # the file included in /dev.yml
]
```

But it should look like

```python
[
"/dev.yml", # first cmd parameter
"/dev/db.yml" # the file(s) included in /dev.yml
"/foo.yml", # next cmd parameter
]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.