The current implementation of the method DependsOnContainer.MarshalYAML()
transform the short syntax into the long syntax. More about booth version
types of depends_on is described here:
- https://docs.docker.com/reference/compose-file/services/#short-syntax-1
- https://docs.docker.com/reference/compose-file/services/#long-syntax-1
Other applications are not compatible with the long syntax. For this reason the
MarshalYAML method has been adapted to take care of the specific syntax.
As documented of the long syntax, `depends_on.<dependency>.condition: service_started`
is the same as `depends_on: [ 'dependency' ]`, the long syntax will be shortened
when no other condition type of a dependency is specified.
This PR supports the extended pattern of `depends_on`. If the short version of
`depends_on` is defined, it will be migrated to the extended version like the
example below:
```yaml
services:
web:
depends_on
- database
services:
web:
depends_on:
database:
condition: service_started
```
All three types of merging strategies are supported.
The following patch adapts the logic of the merge strategy existing and last
win for service ports.
In the past, the complete object has been replaced based on the merge strategy.
This behavior has been adapted, that each port should now considered
individually per strategy.
Both strategies now focus on the src port of the host system. With a last-win,
the dest port of the container is overwritten with an existing src port.
```diff
service:
my-app:
ports:
- - 0.0.0.0:8080:80
+ - 0.0.0.0:8080:8080
- 0.0.0.0:8443:8443
```
The situation is different with the existing win strategy. There, the destination
port can no longer be changed once there is a connection with a sourc port.
The normal dcmerge did not work, as the check and addition was only
possible if at least one attribute such as service, network or volume
was presentThe normal dcmerge did not work, as the check and addition
was only possible if at least one attribute such as service, network or
volume was present.
The logic was adjusted.
The logic was adjusted.