You've already forked dcmerge
Compare commits
99 Commits
Author | SHA1 | Date | |
---|---|---|---|
63a54e130d
|
|||
ef1c7f25a3
|
|||
cc9c98b84d
|
|||
9f29df1311
|
|||
1d8a8d7b76 | |||
3e73692f28
|
|||
7a0c89c8b7 | |||
3c56ae6e5e
|
|||
ed7622a34f
|
|||
967c20c638
|
|||
c23633a385
|
|||
68db80a05a
|
|||
6761dbf419
|
|||
ab282e5173
|
|||
003db26fe5
|
|||
f8b4fe9af6
|
|||
2c91222753
|
|||
b45f8181aa
|
|||
13301cb367
|
|||
0a68b2d8e7
|
|||
54af4469a4
|
|||
dc15512229
|
|||
5fa0991bc2
|
|||
efb5fba9a9
|
|||
c8894de28c
|
|||
da34769ff3
|
|||
1a9fa39c94
|
|||
554c73bd7b
|
|||
ea0bb14ac4
|
|||
20b4f12dd1
|
|||
f2dc3d5174
|
|||
37de3302c6
|
|||
57dff5ff36
|
|||
f0f5e586d9
|
|||
0cd81642bb
|
|||
e6e3b0d4fc
|
|||
e66b2045f2
|
|||
141779c2a0
|
|||
c2ad246c32
|
|||
e1a7f3b900
|
|||
5417844dcc
|
|||
63030b3523
|
|||
168026c4ac
|
|||
992941abdc
|
|||
e8093e7266
|
|||
a04c5f9606
|
|||
7edd465bc6
|
|||
c62c747551
|
|||
900e5535ed | |||
dc329229e1
|
|||
49b1cfb1fe
|
|||
910172cc94
|
|||
04455e02b4
|
|||
e2c38f76b7
|
|||
4c67cb4198
|
|||
5c3ba383b6
|
|||
bbade1e4f9
|
|||
4085619557
|
|||
a1b8695aae
|
|||
934997b20a
|
|||
702c1ac4b6
|
|||
ea5269027d
|
|||
6ced20b951
|
|||
a6b4fd0afc
|
|||
07288bf752
|
|||
e09eaebfb3
|
|||
6224a9d38f
|
|||
2da0b01a44
|
|||
7628004096 | |||
19f70937e9 | |||
d8e064d873 | |||
7cb4c5634c | |||
86695b62ec | |||
dc861f13b1 | |||
9a3c64e91a | |||
610dd87a4b | |||
165cd6a778 | |||
2f9a7d0dd5 | |||
b83efda648
|
|||
5dea30fec0
|
|||
3d97ee0ab8
|
|||
8b68c9587c
|
|||
669ebd0f25 | |||
8f794494a2 | |||
8e411cc486
|
|||
d7e8970860 | |||
8603eca0b5 | |||
d8ada5578b
|
|||
4f5d115926 | |||
dac3be4e2d | |||
173637693f | |||
3ba641aa12 | |||
768a49319d | |||
66f5fff92a | |||
b6b2e069cd | |||
2c738d0417 | |||
46dd067b48
|
|||
9669685997 | |||
9a76f3432a |
292
.drone.yml
292
.drone.yml
@ -11,12 +11,12 @@ platform:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: markdown lint
|
- name: markdown lint
|
||||||
commands:
|
commands:
|
||||||
- markdownlint *.md
|
- markdownlint *.md
|
||||||
image: git.cryptic.systems/volker.raschek/markdownlint:0.35.0
|
image: git.cryptic.systems/volker.raschek/markdownlint:0.44.0
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: 150
|
cpu: 150
|
||||||
@ -34,7 +34,7 @@ steps:
|
|||||||
from_secret: smtp_username
|
from_secret: smtp_username
|
||||||
SMTP_PASSWORD:
|
SMTP_PASSWORD:
|
||||||
from_secret: smtp_password
|
from_secret: smtp_password
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: 150
|
cpu: 150
|
||||||
@ -62,46 +62,18 @@ platform:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: unit-test
|
- name: unit-test
|
||||||
commands:
|
commands:
|
||||||
- go test -v ./...
|
- go test -v ./...
|
||||||
image: docker.io/library/golang:1.21.0
|
image: docker.io/library/golang:1.24.2
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
exclude:
|
exclude:
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: unit-test-arm-v7
|
|
||||||
|
|
||||||
clone:
|
|
||||||
disable: true
|
|
||||||
|
|
||||||
platform:
|
|
||||||
arch: arm
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: clone
|
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
|
||||||
|
|
||||||
- name: unit-test
|
|
||||||
commands:
|
|
||||||
- go test -v ./...
|
|
||||||
image: docker.io/library/golang:1.21.0
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
event:
|
|
||||||
include:
|
|
||||||
- pull_request
|
|
||||||
- push
|
|
||||||
exclude:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
@ -115,12 +87,12 @@ platform:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: unit-test
|
- name: unit-test
|
||||||
commands:
|
commands:
|
||||||
- go test -v ./...
|
- go test -v ./...
|
||||||
image: docker.io/library/golang:1.21.0
|
image: docker.io/library/golang:1.24.2
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
@ -148,10 +120,10 @@ platform:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
image: docker.io/plugins/docker:20.10.9
|
image: docker.io/plugins/docker:20.18.8
|
||||||
settings:
|
settings:
|
||||||
auto_tag: false
|
auto_tag: false
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
@ -181,74 +153,7 @@ steps:
|
|||||||
from_secret: smtp_username
|
from_secret: smtp_username
|
||||||
SMTP_PASSWORD:
|
SMTP_PASSWORD:
|
||||||
from_secret: smtp_password
|
from_secret: smtp_password
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- changed
|
|
||||||
- failure
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
branch:
|
|
||||||
exclude:
|
|
||||||
- master
|
|
||||||
event:
|
|
||||||
- pull_request
|
|
||||||
- push
|
|
||||||
repo:
|
|
||||||
- volker.raschek/dcmerge
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: dry-run-arm-v7
|
|
||||||
|
|
||||||
clone:
|
|
||||||
disable: true
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- linter
|
|
||||||
- unit-test-arm-v7
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: arm
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: clone
|
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
|
||||||
|
|
||||||
- name: build
|
|
||||||
image: docker.io/plugins/docker:20.10.9
|
|
||||||
settings:
|
|
||||||
auto_tag: false
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
dry_run: true
|
|
||||||
force_tag: true
|
|
||||||
no_cache: true
|
|
||||||
purge: true
|
|
||||||
mirror:
|
|
||||||
from_secret: docker_io_mirror
|
|
||||||
registry: git.cryptic.systems
|
|
||||||
repo: git.cryptic.systems/volker.raschek/dcmerge
|
|
||||||
tags: latest-arm-v7
|
|
||||||
username:
|
|
||||||
from_secret: git_cryptic_systems_container_registry_user
|
|
||||||
password:
|
|
||||||
from_secret: git_cryptic_systems_container_registry_password
|
|
||||||
|
|
||||||
- name: email-notification
|
|
||||||
environment:
|
|
||||||
SMTP_FROM_ADDRESS:
|
|
||||||
from_secret: smtp_from_address
|
|
||||||
SMTP_FROM_NAME:
|
|
||||||
from_secret: smtp_from_name
|
|
||||||
SMTP_HOST:
|
|
||||||
from_secret: smtp_host
|
|
||||||
SMTP_USERNAME:
|
|
||||||
from_secret: smtp_username
|
|
||||||
SMTP_PASSWORD:
|
|
||||||
from_secret: smtp_password
|
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
|
||||||
when:
|
when:
|
||||||
status:
|
status:
|
||||||
- changed
|
- changed
|
||||||
@ -282,10 +187,10 @@ platform:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
image: docker.io/plugins/docker:20.10.9
|
image: docker.io/plugins/docker:20.18.8
|
||||||
settings:
|
settings:
|
||||||
auto_tag: false
|
auto_tag: false
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
@ -315,7 +220,7 @@ steps:
|
|||||||
from_secret: smtp_username
|
from_secret: smtp_username
|
||||||
SMTP_PASSWORD:
|
SMTP_PASSWORD:
|
||||||
from_secret: smtp_password
|
from_secret: smtp_password
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||||
when:
|
when:
|
||||||
status:
|
status:
|
||||||
- changed
|
- changed
|
||||||
@ -349,10 +254,10 @@ platform:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
image: docker.io/plugins/docker:20.10.9
|
image: docker.io/plugins/docker:20.18.8
|
||||||
settings:
|
settings:
|
||||||
auto_tag: false
|
auto_tag: false
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
@ -381,72 +286,7 @@ steps:
|
|||||||
from_secret: smtp_username
|
from_secret: smtp_username
|
||||||
SMTP_PASSWORD:
|
SMTP_PASSWORD:
|
||||||
from_secret: smtp_password
|
from_secret: smtp_password
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- changed
|
|
||||||
- failure
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
branch:
|
|
||||||
- master
|
|
||||||
event:
|
|
||||||
- cron
|
|
||||||
- push
|
|
||||||
repo:
|
|
||||||
- volker.raschek/dcmerge
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: latest-arm-v7
|
|
||||||
|
|
||||||
clone:
|
|
||||||
disable: true
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- linter
|
|
||||||
- unit-test-arm-v7
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: arm
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: clone
|
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
|
||||||
|
|
||||||
- name: build
|
|
||||||
image: docker.io/plugins/docker:20.10.9
|
|
||||||
settings:
|
|
||||||
auto_tag: false
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
force_tag: true
|
|
||||||
no_cache: true
|
|
||||||
purge: true
|
|
||||||
mirror:
|
|
||||||
from_secret: docker_io_mirror
|
|
||||||
registry: git.cryptic.systems
|
|
||||||
repo: git.cryptic.systems/volker.raschek/dcmerge
|
|
||||||
tags: latest-arm-v7
|
|
||||||
username:
|
|
||||||
from_secret: git_cryptic_systems_container_registry_user
|
|
||||||
password:
|
|
||||||
from_secret: git_cryptic_systems_container_registry_password
|
|
||||||
|
|
||||||
- name: email-notification
|
|
||||||
environment:
|
|
||||||
SMTP_FROM_ADDRESS:
|
|
||||||
from_secret: smtp_from_address
|
|
||||||
SMTP_FROM_NAME:
|
|
||||||
from_secret: smtp_from_name
|
|
||||||
SMTP_HOST:
|
|
||||||
from_secret: smtp_host
|
|
||||||
SMTP_USERNAME:
|
|
||||||
from_secret: smtp_username
|
|
||||||
SMTP_PASSWORD:
|
|
||||||
from_secret: smtp_password
|
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
|
||||||
when:
|
when:
|
||||||
status:
|
status:
|
||||||
- changed
|
- changed
|
||||||
@ -479,10 +319,10 @@ platform:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
image: docker.io/plugins/docker:20.10.9
|
image: docker.io/plugins/docker:20.18.8
|
||||||
settings:
|
settings:
|
||||||
auto_tag: false
|
auto_tag: false
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
@ -511,7 +351,7 @@ steps:
|
|||||||
from_secret: smtp_username
|
from_secret: smtp_username
|
||||||
SMTP_PASSWORD:
|
SMTP_PASSWORD:
|
||||||
from_secret: smtp_password
|
from_secret: smtp_password
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||||
when:
|
when:
|
||||||
status:
|
status:
|
||||||
- changed
|
- changed
|
||||||
@ -536,7 +376,6 @@ clone:
|
|||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- latest-amd64
|
- latest-amd64
|
||||||
- latest-arm-v7
|
|
||||||
- latest-arm64-v8
|
- latest-arm64-v8
|
||||||
|
|
||||||
# docker.io/plugins/manifest only for amd64 architectures available
|
# docker.io/plugins/manifest only for amd64 architectures available
|
||||||
@ -546,7 +385,7 @@ node_selector:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: build-manifest
|
- name: build-manifest
|
||||||
image: docker.io/plugins/manifest:1.4.0
|
image: docker.io/plugins/manifest:1.4.0
|
||||||
@ -571,7 +410,7 @@ steps:
|
|||||||
from_secret: smtp_username
|
from_secret: smtp_username
|
||||||
SMTP_PASSWORD:
|
SMTP_PASSWORD:
|
||||||
from_secret: smtp_password
|
from_secret: smtp_password
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: 150
|
cpu: 150
|
||||||
@ -603,7 +442,7 @@ depends_on:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: latest-sync
|
- name: latest-sync
|
||||||
commands:
|
commands:
|
||||||
@ -617,7 +456,7 @@ steps:
|
|||||||
from_secret: container_image_registry_user
|
from_secret: container_image_registry_user
|
||||||
DEST_CRED_PASSWORD:
|
DEST_CRED_PASSWORD:
|
||||||
from_secret: container_image_registry_password
|
from_secret: container_image_registry_password
|
||||||
image: quay.io/skopeo/stable:v1.13.1
|
image: quay.io/skopeo/stable:v1.18.0
|
||||||
|
|
||||||
- name: email-notification
|
- name: email-notification
|
||||||
environment:
|
environment:
|
||||||
@ -631,7 +470,7 @@ steps:
|
|||||||
from_secret: smtp_username
|
from_secret: smtp_username
|
||||||
SMTP_PASSWORD:
|
SMTP_PASSWORD:
|
||||||
from_secret: smtp_password
|
from_secret: smtp_password
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: 150
|
cpu: 150
|
||||||
@ -664,10 +503,10 @@ platform:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
image: docker.io/plugins/docker:20.10.9
|
image: docker.io/plugins/docker:20.18.8
|
||||||
settings:
|
settings:
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: amd64
|
auto_tag_suffix: amd64
|
||||||
@ -698,67 +537,7 @@ steps:
|
|||||||
from_secret: smtp_username
|
from_secret: smtp_username
|
||||||
SMTP_PASSWORD:
|
SMTP_PASSWORD:
|
||||||
from_secret: smtp_password
|
from_secret: smtp_password
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- changed
|
|
||||||
- failure
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
repo:
|
|
||||||
- volker.raschek/dcmerge
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: tagged-arm-v7
|
|
||||||
|
|
||||||
clone:
|
|
||||||
disable: true
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: arm
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: clone
|
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
|
||||||
|
|
||||||
- name: build
|
|
||||||
image: docker.io/plugins/docker:20.10.9
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: arm-v7
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
force_tag: true
|
|
||||||
no_cache: true
|
|
||||||
purge: true
|
|
||||||
mirror:
|
|
||||||
from_secret: docker_io_mirror
|
|
||||||
registry: git.cryptic.systems
|
|
||||||
repo: git.cryptic.systems/volker.raschek/dcmerge
|
|
||||||
username:
|
|
||||||
from_secret: git_cryptic_systems_container_registry_user
|
|
||||||
password:
|
|
||||||
from_secret: git_cryptic_systems_container_registry_password
|
|
||||||
build_args:
|
|
||||||
- VERSION=${DRONE_TAG}
|
|
||||||
|
|
||||||
- name: email-notification
|
|
||||||
environment:
|
|
||||||
SMTP_FROM_ADDRESS:
|
|
||||||
from_secret: smtp_from_address
|
|
||||||
SMTP_FROM_NAME:
|
|
||||||
from_secret: smtp_from_name
|
|
||||||
SMTP_HOST:
|
|
||||||
from_secret: smtp_host
|
|
||||||
SMTP_USERNAME:
|
|
||||||
from_secret: smtp_username
|
|
||||||
SMTP_PASSWORD:
|
|
||||||
from_secret: smtp_password
|
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
|
||||||
when:
|
when:
|
||||||
status:
|
status:
|
||||||
- changed
|
- changed
|
||||||
@ -784,10 +563,10 @@ platform:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
image: docker.io/plugins/docker:20.10.9
|
image: docker.io/plugins/docker:20.18.8
|
||||||
settings:
|
settings:
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: arm64-v8
|
auto_tag_suffix: arm64-v8
|
||||||
@ -818,7 +597,7 @@ steps:
|
|||||||
from_secret: smtp_username
|
from_secret: smtp_username
|
||||||
SMTP_PASSWORD:
|
SMTP_PASSWORD:
|
||||||
from_secret: smtp_password
|
from_secret: smtp_password
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||||
when:
|
when:
|
||||||
status:
|
status:
|
||||||
- changed
|
- changed
|
||||||
@ -840,7 +619,6 @@ clone:
|
|||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- tagged-amd64
|
- tagged-amd64
|
||||||
- tagged-arm-v7
|
|
||||||
- tagged-arm64-v8
|
- tagged-arm64-v8
|
||||||
|
|
||||||
# docker.io/plugins/manifest only for amd64 architectures available
|
# docker.io/plugins/manifest only for amd64 architectures available
|
||||||
@ -850,7 +628,7 @@ node_selector:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: build-manifest
|
- name: build-manifest
|
||||||
image: docker.io/plugins/manifest:1.4.0
|
image: docker.io/plugins/manifest:1.4.0
|
||||||
@ -875,7 +653,7 @@ steps:
|
|||||||
from_secret: smtp_username
|
from_secret: smtp_username
|
||||||
SMTP_PASSWORD:
|
SMTP_PASSWORD:
|
||||||
from_secret: smtp_password
|
from_secret: smtp_password
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: 150
|
cpu: 150
|
||||||
@ -904,7 +682,7 @@ depends_on:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: git.cryptic.systems/volker.raschek/git:1.2.1
|
image: git.cryptic.systems/volker.raschek/git:1.4.0
|
||||||
|
|
||||||
- name: tagged-sync
|
- name: tagged-sync
|
||||||
commands:
|
commands:
|
||||||
@ -918,7 +696,7 @@ steps:
|
|||||||
from_secret: container_image_registry_user
|
from_secret: container_image_registry_user
|
||||||
DEST_CRED_PASSWORD:
|
DEST_CRED_PASSWORD:
|
||||||
from_secret: container_image_registry_password
|
from_secret: container_image_registry_password
|
||||||
image: quay.io/skopeo/stable:v1.13.1
|
image: quay.io/skopeo/stable:v1.18.0
|
||||||
|
|
||||||
- name: email-notification
|
- name: email-notification
|
||||||
environment:
|
environment:
|
||||||
@ -932,7 +710,7 @@ steps:
|
|||||||
from_secret: smtp_username
|
from_secret: smtp_username
|
||||||
SMTP_PASSWORD:
|
SMTP_PASSWORD:
|
||||||
from_secret: smtp_password
|
from_secret: smtp_password
|
||||||
image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
|
image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: 150
|
cpu: 150
|
||||||
|
51
.gitea/workflows/release.yml
Normal file
51
.gitea/workflows/release.yml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: [ "*" ]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on:
|
||||||
|
- ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4.2.2
|
||||||
|
- uses: docker/setup-qemu-action@v3.6.0
|
||||||
|
- uses: actions/setup-go@v5.4.0
|
||||||
|
with:
|
||||||
|
go-version: stable
|
||||||
|
- uses: docker/login-action@v3.4.0
|
||||||
|
with:
|
||||||
|
registry: git.cryptic.systems
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }}
|
||||||
|
- env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }}
|
||||||
|
GONOSUMDB: ${{ vars.GONOSUMDB }}
|
||||||
|
GOPROXY: ${{ vars.GOPROXY }}
|
||||||
|
uses: goreleaser/goreleaser-action@v6.2.1
|
||||||
|
with:
|
||||||
|
version: "~> v2"
|
||||||
|
args: release --clean
|
||||||
|
|
||||||
|
sync-container-image:
|
||||||
|
needs: release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Copy images to docker.io
|
||||||
|
run: |
|
||||||
|
TAG=$(echo ${{ github.ref_name }} | sed 's/v//gm')
|
||||||
|
|
||||||
|
apt-get update --yes
|
||||||
|
apt-get install --yes skopeo
|
||||||
|
skopeo copy \
|
||||||
|
--all \
|
||||||
|
--dest-password ${{ secrets.DOCKER_IO_PASSWORD }} \
|
||||||
|
--dest-username ${{ secrets.DOCKER_IO_USERNAME }} \
|
||||||
|
--src-password ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }} \
|
||||||
|
--src-username volker.raschek \
|
||||||
|
docker://git.cryptic.systems/volker.raschek/dcmerge-goreleaser:${TAG} \
|
||||||
|
docker://docker.io/volkerraschek/dcmerge-goreleaser:${TAG}
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
dcmerge
|
dcmerge
|
||||||
|
coverage.txt
|
154
.goreleaser.yaml
Normal file
154
.goreleaser.yaml
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
project_name: dcmerge
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- formats: [ "tar.xz" ]
|
||||||
|
files:
|
||||||
|
- README.md
|
||||||
|
- LICENSE
|
||||||
|
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy
|
||||||
|
|
||||||
|
builds:
|
||||||
|
- main: main.go
|
||||||
|
binary: >-
|
||||||
|
{{ .ProjectName }}-
|
||||||
|
{{- .Version }}-
|
||||||
|
{{- .Os }}-
|
||||||
|
{{- if eq .Arch "amd64" }}amd64
|
||||||
|
{{- else if eq .Arch "amd64_v1" }}amd64
|
||||||
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
|
{{- if .Arm }}-{{ .Arm }}{{ end }}
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
- GONOSUMDB={{ .Env.GONOSUMDB }}
|
||||||
|
- GOPROXY={{ .Env.GOPROXY }}
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
- arm
|
||||||
|
- arm64
|
||||||
|
goarm:
|
||||||
|
- "6"
|
||||||
|
- "7"
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X 'main.version={{ trimprefix .Tag "v" }}'
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- '^chore'
|
||||||
|
- '^docs'
|
||||||
|
- '^test'
|
||||||
|
- Merge pull request
|
||||||
|
- Merge branch
|
||||||
|
- go mod tidy
|
||||||
|
format: "{{.SHA}}: {{.Message}} (@{{.AuthorUsername}})"
|
||||||
|
groups:
|
||||||
|
- title: Features
|
||||||
|
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
|
||||||
|
order: 0
|
||||||
|
- title: "Bug fixes"
|
||||||
|
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
|
||||||
|
order: 1
|
||||||
|
- title: Others
|
||||||
|
order: 999
|
||||||
|
sort: asc
|
||||||
|
use: git
|
||||||
|
|
||||||
|
dockers:
|
||||||
|
- build_flag_templates:
|
||||||
|
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
|
||||||
|
- --label=org.opencontainers.image.description={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.revision={{ .FullCommit }}
|
||||||
|
- --label=org.opencontainers.image.source={{ .GitURL }}
|
||||||
|
- --label=org.opencontainers.image.title={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
|
||||||
|
- --platform=linux/amd64
|
||||||
|
- --pull
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
goarch: amd64
|
||||||
|
goos: linux
|
||||||
|
image_templates:
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-amd64'
|
||||||
|
skip_push: false
|
||||||
|
use: buildx
|
||||||
|
|
||||||
|
- build_flag_templates:
|
||||||
|
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
|
||||||
|
- --label=org.opencontainers.image.description={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.revision={{ .FullCommit }}
|
||||||
|
- --label=org.opencontainers.image.source={{ .GitURL }}
|
||||||
|
- --label=org.opencontainers.image.title={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
|
||||||
|
- --platform=linux/arm/v6
|
||||||
|
- --pull
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
goarch: arm
|
||||||
|
goarm: "6"
|
||||||
|
goos: linux
|
||||||
|
image_templates:
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v6'
|
||||||
|
skip_push: false
|
||||||
|
use: buildx
|
||||||
|
|
||||||
|
- build_flag_templates:
|
||||||
|
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
|
||||||
|
- --label=org.opencontainers.image.description={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.revision={{ .FullCommit }}
|
||||||
|
- --label=org.opencontainers.image.source={{ .GitURL }}
|
||||||
|
- --label=org.opencontainers.image.title={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
|
||||||
|
- --platform=linux/arm/v7
|
||||||
|
- --pull
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
goarch: arm
|
||||||
|
goarm: "7"
|
||||||
|
goos: linux
|
||||||
|
image_templates:
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v7'
|
||||||
|
skip_push: false
|
||||||
|
use: buildx
|
||||||
|
|
||||||
|
- build_flag_templates:
|
||||||
|
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
|
||||||
|
- --label=org.opencontainers.image.description={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.revision={{ .FullCommit }}
|
||||||
|
- --label=org.opencontainers.image.source={{ .GitURL }}
|
||||||
|
- --label=org.opencontainers.image.title={{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
|
||||||
|
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
|
||||||
|
- --platform=linux/arm64
|
||||||
|
- --pull
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
goarch: arm64
|
||||||
|
goos: linux
|
||||||
|
image_templates:
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm64'
|
||||||
|
skip_push: false
|
||||||
|
use: buildx
|
||||||
|
|
||||||
|
docker_manifests:
|
||||||
|
- name_template: 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}'
|
||||||
|
image_templates:
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-amd64'
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v6'
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v7'
|
||||||
|
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm64'
|
||||||
|
|
||||||
|
gitea_urls:
|
||||||
|
api: https://git.cryptic.systems/api/v1
|
||||||
|
download: https://git.cryptic.systems
|
||||||
|
|
||||||
|
version: 2
|
@ -45,11 +45,11 @@ MD012:
|
|||||||
# MD013/line-length - Line length
|
# MD013/line-length - Line length
|
||||||
MD013:
|
MD013:
|
||||||
# Number of characters
|
# Number of characters
|
||||||
line_length: 80
|
line_length: 120
|
||||||
# Number of characters for headings
|
# Number of characters for headings
|
||||||
heading_line_length: 80
|
heading_line_length: 120
|
||||||
# Number of characters for code blocks
|
# Number of characters for code blocks
|
||||||
code_block_line_length: 80
|
code_block_line_length: 120
|
||||||
# Include code blocks
|
# Include code blocks
|
||||||
code_blocks: false
|
code_blocks: false
|
||||||
# Include tables
|
# Include tables
|
||||||
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"rewrap.wrappingColumn": 120,
|
||||||
|
}
|
19
Dockerfile
19
Dockerfile
@ -1,20 +1,5 @@
|
|||||||
FROM docker.io/library/golang:1.21.0-alpine3.18 AS build
|
FROM scratch AS build
|
||||||
|
|
||||||
RUN apk add git make
|
COPY dcmerge-* /usr/bin/dcmerge
|
||||||
|
|
||||||
WORKDIR /workspace
|
|
||||||
ADD ./ /workspace
|
|
||||||
|
|
||||||
RUN make install \
|
|
||||||
DESTDIR=/cache \
|
|
||||||
PREFIX=/usr \
|
|
||||||
VERSION=${VERSION}
|
|
||||||
|
|
||||||
FROM docker.io/library/alpine:3.18.3
|
|
||||||
|
|
||||||
COPY --from=build /cache /
|
|
||||||
|
|
||||||
WORKDIR /workspace
|
|
||||||
VOLUME [ "/workspace" ]
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/usr/bin/dcmerge" ]
|
ENTRYPOINT [ "/usr/bin/dcmerge" ]
|
33
README.md
33
README.md
@ -3,22 +3,18 @@
|
|||||||
[](https://drone.cryptic.systems/volker.raschek/dcmerge)
|
[](https://drone.cryptic.systems/volker.raschek/dcmerge)
|
||||||
[](https://hub.docker.com/r/volkerraschek/dcmerge)
|
[](https://hub.docker.com/r/volkerraschek/dcmerge)
|
||||||
|
|
||||||
`dcmerge` is a small program to merge docker-compose files from multiple
|
`dcmerge` is a small program to merge docker-compose files from multiple sources. It is available via RPM and docker.
|
||||||
sources. It is available via RPM and docker.
|
|
||||||
|
|
||||||
The dynamic pattern of a docker-compose file, that for example `environments`
|
The dynamic pattern of a docker-compose file, that for example `environments` can be specified as a string slice or a
|
||||||
can be specified as a string slice or a list of objects is currently not
|
list of objects is currently not supported. `dcmerge` expect a strict pattern layout. The `environments`, `ports` and
|
||||||
supported. `dcmerge` expect a strict pattern layout. The `environments`, `ports`
|
`volumes` must be declared as a slice of strings.
|
||||||
and `volumes` must be declared as a slice of strings.
|
|
||||||
|
|
||||||
Dockercompose file can be read-in from different sources. Currently are the
|
Dockercompose file can be read-in from different sources. Currently are the following sources supported:
|
||||||
following sources supported:
|
|
||||||
|
|
||||||
- File
|
- File
|
||||||
- HTTP/HTTPS
|
- HTTP/HTTPS
|
||||||
|
|
||||||
Furthermore, `dcmerge` support different ways to merge multiple docker-compose
|
Furthermore, `dcmerge` support different ways to merge multiple docker-compose files.
|
||||||
files.
|
|
||||||
|
|
||||||
- The default merge, add missing secrets, services, networks and volumes.
|
- The default merge, add missing secrets, services, networks and volumes.
|
||||||
- The existing-win merge, add and protect existing attributes.
|
- The existing-win merge, add and protect existing attributes.
|
||||||
@ -26,9 +22,8 @@ files.
|
|||||||
|
|
||||||
## default
|
## default
|
||||||
|
|
||||||
Merge only missing secrets, services, networks and volumes without respecting
|
Merge only missing secrets, services, networks and volumes **without respecting their attributes**. For example, when
|
||||||
their attributes. For example, when the service `app` is already declared, it is
|
the service `app` is already declared, it is not possible to add the service `app` twice. The second service will be
|
||||||
not possible to add the service `app` twice. The second service will be
|
|
||||||
completely skipped.
|
completely skipped.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@ -68,10 +63,9 @@ services:
|
|||||||
|
|
||||||
## existing-win
|
## existing-win
|
||||||
|
|
||||||
The existing-win merge protects existing attributes. For example there are two
|
The existing-win merge protects existing attributes. For example there are two different docker-compose files, but booth
|
||||||
different docker-compose files, but booth has the same environment variable
|
has the same environment variable `CLIENT_SECRET` defined with different values. The first declaration of the attribute
|
||||||
`CLIENT_SECRET` defined with different values. The first declaration of the
|
wins and is for overwriting protected.
|
||||||
attribute wins and is for overwriting protected.
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
@ -99,9 +93,8 @@ services:
|
|||||||
|
|
||||||
## last-win
|
## last-win
|
||||||
|
|
||||||
The last-win merge overwrite recursive existing attributes. For example there
|
The last-win merge overwrite recursive existing attributes. For example there are two different docker-compose files,
|
||||||
are two different docker-compose files, but booth has the same environment
|
but booth has the same environment variable `CLIENT_SECRET` defined with different values. The last passed
|
||||||
variable `CLIENT_SECRET` defined with different values. The last passed
|
|
||||||
docker-compose file which contains this environment wins.
|
docker-compose file which contains this environment wins.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"git.cryptic.systems/volker.raschek/dcmerge/pkg/domain/dockerCompose"
|
"git.cryptic.systems/volker.raschek/dcmerge/pkg/domain/dockerCompose"
|
||||||
"git.cryptic.systems/volker.raschek/dcmerge/pkg/fetcher"
|
"git.cryptic.systems/volker.raschek/dcmerge/pkg/fetcher"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Execute(version string) error {
|
func Execute(version string) error {
|
||||||
@ -18,7 +18,7 @@ func Execute(version string) error {
|
|||||||
Long: "To load completions",
|
Long: "To load completions",
|
||||||
DisableFlagsInUseLine: true,
|
DisableFlagsInUseLine: true,
|
||||||
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
||||||
Args: cobra.ExactValidArgs(1),
|
Args: cobra.MatchAll(cobra.ExactArgs(1)),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
switch args[0] {
|
switch args[0] {
|
||||||
case "bash":
|
case "bash":
|
||||||
@ -100,10 +100,12 @@ func run(cmd *cobra.Command, args []string) error {
|
|||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
yamlEncoder := yaml.NewEncoder(f)
|
yamlEncoder := yaml.NewEncoder(f)
|
||||||
|
yamlEncoder.SetIndent(2)
|
||||||
return yamlEncoder.Encode(dockerComposeConfig)
|
return yamlEncoder.Encode(dockerComposeConfig)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
yamlEncoder := yaml.NewEncoder(os.Stdout)
|
yamlEncoder := yaml.NewEncoder(os.Stdout)
|
||||||
|
yamlEncoder.SetIndent(2)
|
||||||
return yamlEncoder.Encode(dockerComposeConfig)
|
return yamlEncoder.Encode(dockerComposeConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
go.mod
9
go.mod
@ -3,15 +3,14 @@ module git.cryptic.systems/volker.raschek/dcmerge
|
|||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/spf13/cobra v1.7.0
|
github.com/spf13/cobra v1.9.1
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.10.0
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.6 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
|
||||||
)
|
)
|
||||||
|
16
go.sum
16
go.sum
@ -1,4 +1,4 @@
|
|||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
@ -6,15 +6,13 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf
|
|||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
|
||||||
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
|
||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
@ -12,12 +12,6 @@ manifests:
|
|||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: linux
|
os: linux
|
||||||
-
|
|
||||||
image: git.cryptic.systems/volker.raschek/dcmerge:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-arm-v7
|
|
||||||
platform:
|
|
||||||
architecture: arm
|
|
||||||
os: linux
|
|
||||||
variant: v7
|
|
||||||
-
|
-
|
||||||
image: git.cryptic.systems/volker.raschek/dcmerge:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-arm64-v8
|
image: git.cryptic.systems/volker.raschek/dcmerge:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-arm64-v8
|
||||||
platform:
|
platform:
|
||||||
|
@ -2,7 +2,10 @@ package dockerCompose
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -66,26 +69,38 @@ func (c *Config) ExistsVolume(name string) bool {
|
|||||||
|
|
||||||
// Merge adds only a missing network, secret, service and volume.
|
// Merge adds only a missing network, secret, service and volume.
|
||||||
func (c *Config) Merge(config *Config) {
|
func (c *Config) Merge(config *Config) {
|
||||||
for name, network := range c.Networks {
|
for name, network := range config.Networks {
|
||||||
if !c.ExistsNetwork(name) {
|
if !c.ExistsNetwork(name) {
|
||||||
|
if c.Networks == nil {
|
||||||
|
c.Networks = make(map[string]*Network)
|
||||||
|
}
|
||||||
c.Networks[name] = network
|
c.Networks[name] = network
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, secret := range c.Secrets {
|
for name, secret := range config.Secrets {
|
||||||
if !c.ExistsSecret(name) {
|
if !c.ExistsSecret(name) {
|
||||||
|
if c.Secrets == nil {
|
||||||
|
c.Secrets = make(map[string]*Secret)
|
||||||
|
}
|
||||||
c.Secrets[name] = secret
|
c.Secrets[name] = secret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, service := range c.Services {
|
for name, service := range config.Services {
|
||||||
if !c.ExistsService(name) {
|
if !c.ExistsService(name) {
|
||||||
|
if c.Services == nil {
|
||||||
|
c.Services = make(map[string]*Service)
|
||||||
|
}
|
||||||
c.Services[name] = service
|
c.Services[name] = service
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, volume := range c.Volumes {
|
for name, volume := range config.Volumes {
|
||||||
if !c.ExistsVolume(name) {
|
if !c.ExistsVolume(name) {
|
||||||
|
if c.Volumes == nil {
|
||||||
|
c.Volumes = make(map[string]*Volume)
|
||||||
|
}
|
||||||
c.Volumes[name] = volume
|
c.Volumes[name] = volume
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -518,13 +533,14 @@ func NewSecret() *Secret {
|
|||||||
type Service struct {
|
type Service struct {
|
||||||
CapabilitiesAdd []string `json:"cap_add,omitempty" yaml:"cap_add,omitempty"`
|
CapabilitiesAdd []string `json:"cap_add,omitempty" yaml:"cap_add,omitempty"`
|
||||||
CapabilitiesDrop []string `json:"cap_drop,omitempty" yaml:"cap_drop,omitempty"`
|
CapabilitiesDrop []string `json:"cap_drop,omitempty" yaml:"cap_drop,omitempty"`
|
||||||
|
DependsOnContainer *DependsOnContainer `json:"depends_on,omitempty" yaml:"depends_on,omitempty"`
|
||||||
Deploy *ServiceDeploy `json:"deploy,omitempty" yaml:"deploy,omitempty"`
|
Deploy *ServiceDeploy `json:"deploy,omitempty" yaml:"deploy,omitempty"`
|
||||||
Environments []string `json:"environment,omitempty" yaml:"environment,omitempty"`
|
Environments []string `json:"environment,omitempty" yaml:"environment,omitempty"`
|
||||||
ExtraHosts []string `json:"extra_hosts,omitempty" yaml:"extra_hosts,omitempty"`
|
ExtraHosts []string `json:"extra_hosts,omitempty" yaml:"extra_hosts,omitempty"`
|
||||||
Image string `json:"image,omitempty" yaml:"image,omitempty"`
|
Image string `json:"image,omitempty" yaml:"image,omitempty"`
|
||||||
Labels []string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
Labels []string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||||
Networks map[string]*ServiceNetwork `json:"networks,omitempty" yaml:"networks,omitempty"`
|
Networks map[string]*ServiceNetwork `json:"networks,omitempty" yaml:"networks,omitempty"`
|
||||||
Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"`
|
Ports []Port `json:"ports,omitempty" yaml:"ports,omitempty"`
|
||||||
Secrets []string `json:"secrets,omitempty" yaml:"secrets,omitempty"`
|
Secrets []string `json:"secrets,omitempty" yaml:"secrets,omitempty"`
|
||||||
ULimits *ServiceULimits `json:"ulimits,omitempty" yaml:"ulimits,omitempty"`
|
ULimits *ServiceULimits `json:"ulimits,omitempty" yaml:"ulimits,omitempty"`
|
||||||
Volumes []string `json:"volumes,omitempty" yaml:"volumes,omitempty"`
|
Volumes []string `json:"volumes,omitempty" yaml:"volumes,omitempty"`
|
||||||
@ -555,39 +571,22 @@ func (s *Service) ExistsLabel(name string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExistsPort returns true if the port definition is already present.
|
// ExistsPort returns true if the port definition is already present. The port defines a mapping between the host system
|
||||||
func (s *Service) ExistsPort(src string, dest string, protocol string) bool {
|
// port and the container port. It is also possible to specify the individual ip address of the host system or the
|
||||||
for _, port := range s.Ports {
|
// container. Additionally, the protocol can be specified as suffix.
|
||||||
s, d, p := splitStringInPort(port)
|
//
|
||||||
if s == src && d == dest && p == protocol {
|
// // Example
|
||||||
|
// s := new(Service)
|
||||||
|
// b := s.ExistsPort("80:80")
|
||||||
|
// b = s.ExistsPort("0.0.0.0:80:80/tcp")
|
||||||
|
// b = s.ExistsPort("0.0.0.0:80:80/tcp")
|
||||||
|
// b = s.ExistsPort("192.168.178.10:80:172.25.18.20:80/tcp")
|
||||||
|
func (s *Service) ExistsPort(port string) bool {
|
||||||
|
for _, p := range s.Ports {
|
||||||
|
if string(p) == port {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// ExistsDestinationPort returns true if the destination port is already used.
|
|
||||||
func (s *Service) ExistsDestinationPort(dest string) bool {
|
|
||||||
for _, port := range s.Ports {
|
|
||||||
_, d, _ := splitStringInPort(port)
|
|
||||||
if d == dest {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// ExistsSourcePort returns true if the source port is already used.
|
|
||||||
func (s *Service) ExistsSourcePort(src string) bool {
|
|
||||||
for _, port := range s.Ports {
|
|
||||||
s, _, _ := splitStringInPort(port)
|
|
||||||
if s == src {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,6 +643,7 @@ func (s *Service) Equal(equalable Equalable) bool {
|
|||||||
default:
|
default:
|
||||||
return equalSlice(s.CapabilitiesAdd, service.CapabilitiesAdd) &&
|
return equalSlice(s.CapabilitiesAdd, service.CapabilitiesAdd) &&
|
||||||
equalSlice(s.CapabilitiesDrop, service.CapabilitiesDrop) &&
|
equalSlice(s.CapabilitiesDrop, service.CapabilitiesDrop) &&
|
||||||
|
s.DependsOnContainer.Equal(service.DependsOnContainer) &&
|
||||||
s.Deploy.Equal(service.Deploy) &&
|
s.Deploy.Equal(service.Deploy) &&
|
||||||
equalSlice(s.Environments, service.Environments) &&
|
equalSlice(s.Environments, service.Environments) &&
|
||||||
equalSlice(s.ExtraHosts, service.ExtraHosts) &&
|
equalSlice(s.ExtraHosts, service.ExtraHosts) &&
|
||||||
@ -675,6 +675,7 @@ func (s *Service) MergeExistingWin(service *Service) {
|
|||||||
default:
|
default:
|
||||||
s.mergeExistingWinCapabilitiesAdd(service.CapabilitiesAdd)
|
s.mergeExistingWinCapabilitiesAdd(service.CapabilitiesAdd)
|
||||||
s.mergeExistingWinCapabilitiesDrop(service.CapabilitiesDrop)
|
s.mergeExistingWinCapabilitiesDrop(service.CapabilitiesDrop)
|
||||||
|
s.mergeExistingWinDependsOnContainer(service.DependsOnContainer)
|
||||||
s.mergeExistingWinDeploy(service.Deploy)
|
s.mergeExistingWinDeploy(service.Deploy)
|
||||||
s.mergeExistingWinEnvironments(service.Environments)
|
s.mergeExistingWinEnvironments(service.Environments)
|
||||||
s.mergeExistingWinExtraHosts(service.ExtraHosts)
|
s.mergeExistingWinExtraHosts(service.ExtraHosts)
|
||||||
@ -708,6 +709,7 @@ func (s *Service) MergeLastWin(service *Service) {
|
|||||||
default:
|
default:
|
||||||
s.mergeLastWinCapabilitiesAdd(service.CapabilitiesAdd)
|
s.mergeLastWinCapabilitiesAdd(service.CapabilitiesAdd)
|
||||||
s.mergeLastWinCapabilitiesDrop(service.CapabilitiesDrop)
|
s.mergeLastWinCapabilitiesDrop(service.CapabilitiesDrop)
|
||||||
|
s.mergeLastWinDependsOnContainer(service.DependsOnContainer)
|
||||||
s.mergeLastWinDeploy(service.Deploy)
|
s.mergeLastWinDeploy(service.Deploy)
|
||||||
s.mergeLastWinEnvironments(service.Environments)
|
s.mergeLastWinEnvironments(service.Environments)
|
||||||
s.mergeLastWinExtraHosts(service.ExtraHosts)
|
s.mergeLastWinExtraHosts(service.ExtraHosts)
|
||||||
@ -737,6 +739,26 @@ func (s *Service) mergeExistingWinCapabilitiesDrop(capabilitiesDrop []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Service) mergeExistingWinDependsOnContainer(dependsOnContainer *DependsOnContainer) {
|
||||||
|
switch {
|
||||||
|
case s.DependsOnContainer != nil && dependsOnContainer == nil:
|
||||||
|
fallthrough
|
||||||
|
case s.DependsOnContainer == nil && dependsOnContainer == nil:
|
||||||
|
return
|
||||||
|
case s.DependsOnContainer == nil && dependsOnContainer != nil:
|
||||||
|
s.DependsOnContainer = dependsOnContainer
|
||||||
|
default:
|
||||||
|
for name, depOn := range dependsOnContainer.DependsOn {
|
||||||
|
if !ExistsInMap(s.DependsOnContainer.DependsOn, name) && depOn != nil {
|
||||||
|
if s.DependsOnContainer.DependsOn == nil {
|
||||||
|
s.DependsOnContainer.DependsOn = make(map[string]*ServiceDependsOn)
|
||||||
|
}
|
||||||
|
s.DependsOnContainer.DependsOn[name] = depOn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Service) mergeExistingWinDeploy(deploy *ServiceDeploy) {
|
func (s *Service) mergeExistingWinDeploy(deploy *ServiceDeploy) {
|
||||||
switch {
|
switch {
|
||||||
case s.Deploy == nil && deploy != nil:
|
case s.Deploy == nil && deploy != nil:
|
||||||
@ -834,7 +856,7 @@ func (s *Service) mergeExistingWinNetworks(networks map[string]*ServiceNetwork)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) mergeExistingWinPorts(ports []string) {
|
func (s *Service) mergeExistingWinPorts(ports []Port) {
|
||||||
switch {
|
switch {
|
||||||
case s.Ports == nil && ports != nil:
|
case s.Ports == nil && ports != nil:
|
||||||
s.Ports = ports
|
s.Ports = ports
|
||||||
@ -843,16 +865,34 @@ func (s *Service) mergeExistingWinPorts(ports []string) {
|
|||||||
case s.Ports == nil && ports == nil:
|
case s.Ports == nil && ports == nil:
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
for _, port := range ports {
|
LOOP:
|
||||||
if len(port) <= 0 {
|
for i := range ports {
|
||||||
continue
|
if len(ports[i]) <= 0 {
|
||||||
|
continue LOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
src, dest, protocol := splitStringInPort(port)
|
newPort := Port(ports[i])
|
||||||
if !s.ExistsDestinationPort(dest) {
|
|
||||||
s.SetPort(src, dest, protocol)
|
for j := range s.Ports {
|
||||||
|
existingPort := Port(s.Ports[j])
|
||||||
|
switch {
|
||||||
|
case newPort.existsSrcIP() && existingPort.existsSrcIP() &&
|
||||||
|
newPort.getSrc() == existingPort.getSrc():
|
||||||
|
continue LOOP
|
||||||
|
case !newPort.existsSrcIP() && existingPort.existsSrcIP() &&
|
||||||
|
newPort.getSrcPort() == existingPort.getSrcPort():
|
||||||
|
continue LOOP
|
||||||
|
case newPort.existsSrcIP() && !existingPort.existsSrcIP() &&
|
||||||
|
newPort.getSrcPort() == existingPort.getSrcPort():
|
||||||
|
continue LOOP
|
||||||
|
case !newPort.existsSrcIP() && !existingPort.existsSrcIP() &&
|
||||||
|
newPort.getSrcPort() == existingPort.getSrcPort():
|
||||||
|
continue LOOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.Ports = append(s.Ports, ports[i])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -913,12 +953,30 @@ func (s *Service) mergeLastWinCapabilitiesDrop(capabilitiesDrop []string) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !existsInSlice(s.CapabilitiesAdd, capabilityDrop) {
|
if !existsInSlice(s.CapabilitiesDrop, capabilityDrop) {
|
||||||
s.CapabilitiesDrop = append(s.CapabilitiesDrop, capabilityDrop)
|
s.CapabilitiesDrop = append(s.CapabilitiesDrop, capabilityDrop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Service) mergeLastWinDependsOnContainer(dependsOnContainer *DependsOnContainer) {
|
||||||
|
switch {
|
||||||
|
case s.DependsOnContainer != nil && dependsOnContainer == nil:
|
||||||
|
fallthrough
|
||||||
|
case s.DependsOnContainer == nil && dependsOnContainer == nil:
|
||||||
|
return
|
||||||
|
case s.DependsOnContainer == nil && dependsOnContainer != nil:
|
||||||
|
s.DependsOnContainer = dependsOnContainer
|
||||||
|
default:
|
||||||
|
for name, depOn := range dependsOnContainer.DependsOn {
|
||||||
|
if s.DependsOnContainer.DependsOn == nil {
|
||||||
|
s.DependsOnContainer.DependsOn = make(map[string]*ServiceDependsOn)
|
||||||
|
}
|
||||||
|
s.DependsOnContainer.DependsOn[name] = depOn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Service) mergeLastWinDeploy(deploy *ServiceDeploy) {
|
func (s *Service) mergeLastWinDeploy(deploy *ServiceDeploy) {
|
||||||
switch {
|
switch {
|
||||||
case s.Deploy == nil && deploy != nil:
|
case s.Deploy == nil && deploy != nil:
|
||||||
@ -1018,7 +1076,7 @@ func (s *Service) mergeLastWinNetworks(networks map[string]*ServiceNetwork) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) mergeLastWinPorts(ports []string) {
|
func (s *Service) mergeLastWinPorts(ports []Port) {
|
||||||
switch {
|
switch {
|
||||||
case s.Ports == nil && ports != nil:
|
case s.Ports == nil && ports != nil:
|
||||||
s.Ports = ports
|
s.Ports = ports
|
||||||
@ -1027,13 +1085,11 @@ func (s *Service) mergeLastWinPorts(ports []string) {
|
|||||||
case s.Ports == nil && ports == nil:
|
case s.Ports == nil && ports == nil:
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
for _, port := range ports {
|
for i := range ports {
|
||||||
if len(port) <= 0 {
|
if len(ports[i]) <= 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
s.SetPort(string(ports[i]))
|
||||||
src, dest, protocol := splitStringInPort(port)
|
|
||||||
s.SetPort(src, dest, protocol)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1096,8 +1152,7 @@ func (s *Service) RemoveEnvironment(name string) {
|
|||||||
s.Environments = environments
|
s.Environments = environments
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveLabel remove all found labels from the internal slice matching by the
|
// RemoveLabel remove all found labels from the internal slice matching by the passed name.
|
||||||
// passed name.
|
|
||||||
func (s *Service) RemoveLabel(name string) {
|
func (s *Service) RemoveLabel(name string) {
|
||||||
labels := make([]string, 0)
|
labels := make([]string, 0)
|
||||||
for _, label := range s.Labels {
|
for _, label := range s.Labels {
|
||||||
@ -1109,25 +1164,47 @@ func (s *Service) RemoveLabel(name string) {
|
|||||||
s.Labels = labels
|
s.Labels = labels
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemovePort remove all found ports from the internal slice matching by the
|
// RemovePortByDst remove all found ports from the internal slice matching by the passed destination. The destination
|
||||||
// passed dest port.
|
// can contains only the destination port, but also the destination ip address.
|
||||||
func (s *Service) RemovePort(dest string) {
|
//
|
||||||
ports := make([]string, 0)
|
// // Example
|
||||||
|
// s := new(Service)
|
||||||
|
// s.RemovePortByDst("8080")
|
||||||
|
// s.RemovePortByDst("172.25.18.20:8080")
|
||||||
|
func (s *Service) RemovePortByDst(dest string) {
|
||||||
|
ports := make([]Port, 0)
|
||||||
for _, port := range s.Ports {
|
for _, port := range s.Ports {
|
||||||
srcPort, destPort, protocol := splitStringInPort(port)
|
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case destPort == dest && len(protocol) <= 0:
|
case port.getDst() == dest:
|
||||||
s.Ports = append(s.Ports, fmt.Sprintf("%s%s%s", srcPort, portDelimiter, destPort))
|
continue
|
||||||
case destPort == dest && len(protocol) > 0:
|
default:
|
||||||
s.Ports = append(s.Ports, fmt.Sprintf("%s%s%s%s%s", srcPort, portDelimiter, destPort, portProtocolDelimiter, protocol))
|
ports = append(ports, port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.Ports = ports
|
s.Ports = ports
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveVolume remove all found volumes from the internal slice matching by the
|
// RemovePortBySrc remove all found ports from the internal slice matching by the passed source. The source can contains
|
||||||
// dest path.
|
// only the source port, but also the source ip address.
|
||||||
|
//
|
||||||
|
// // Example
|
||||||
|
// s := new(Service)
|
||||||
|
// s.RemovePortBySrc("8080")
|
||||||
|
// s.RemovePortBySrc("192.168.178.10:8080")
|
||||||
|
func (s *Service) RemovePortBySrc(src string) {
|
||||||
|
ports := make([]Port, 0)
|
||||||
|
for _, port := range s.Ports {
|
||||||
|
switch {
|
||||||
|
case port.getSrc() == src:
|
||||||
|
continue
|
||||||
|
default:
|
||||||
|
ports = append(ports, port)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.Ports = ports
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveVolume remove all found volumes from the internal slice matching by the dest path.
|
||||||
func (s *Service) RemoveVolume(dest string) {
|
func (s *Service) RemoveVolume(dest string) {
|
||||||
volumes := make([]string, 0)
|
volumes := make([]string, 0)
|
||||||
for _, volume := range s.Volumes {
|
for _, volume := range s.Volumes {
|
||||||
@ -1155,14 +1232,16 @@ func (s *Service) SetLabel(name string, value string) {
|
|||||||
s.Labels = append(s.Labels, fmt.Sprintf("%s%s%s", name, labelDelimiter, value))
|
s.Labels = append(s.Labels, fmt.Sprintf("%s%s%s", name, labelDelimiter, value))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPort add or overwrite an existing port.
|
// SetPort add or overwrite an existing source port.
|
||||||
func (s *Service) SetPort(src string, dest string, protocol string) {
|
//
|
||||||
s.RemovePort(dest)
|
// // Example
|
||||||
if len(protocol) <= 0 {
|
// s := new(Service)
|
||||||
s.Ports = append(s.Ports, fmt.Sprintf("%s%s%s", src, volumeDelimiter, dest))
|
// s.SetPort("0.0.0.0:443:172.25.18.20:8443/tcp") // Add new port
|
||||||
} else {
|
// s.SetPort("0.0.0.0:443:10.254.611.66:443/tcp") // Overwrite port determined by source port
|
||||||
s.Ports = append(s.Ports, fmt.Sprintf("%s%s%s%s%s", src, portDelimiter, dest, portProtocolDelimiter, protocol))
|
func (s *Service) SetPort(port string) {
|
||||||
}
|
newPort := Port(port)
|
||||||
|
s.RemovePortBySrc(newPort.getSrc())
|
||||||
|
s.Ports = append(s.Ports, newPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetVolume add or overwrite an existing volume.
|
// SetVolume add or overwrite an existing volume.
|
||||||
@ -1175,6 +1254,88 @@ func (s *Service) SetVolume(src string, dest string, perm string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
ServiceDependsOnConditionServiceCompletedSuccessfully string = "service_completed_successfully"
|
||||||
|
ServiceDependsOnConditionServiceHealthy string = "service_healthy"
|
||||||
|
ServiceDependsOnConditionServiceStarted string = "service_started"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DependsOnContainer is a wrapper to handle different YAML type formats of DependsOn.
|
||||||
|
type DependsOnContainer struct {
|
||||||
|
Slice []string
|
||||||
|
DependsOn map[string]*ServiceDependsOn
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equal returns true if the passed equalable is equal
|
||||||
|
func (sdoc *DependsOnContainer) Equal(equalable Equalable) bool {
|
||||||
|
serviceDependsOnContainer, ok := equalable.(*DependsOnContainer)
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case sdoc == nil && serviceDependsOnContainer == nil:
|
||||||
|
return true
|
||||||
|
case sdoc != nil && serviceDependsOnContainer == nil:
|
||||||
|
fallthrough
|
||||||
|
case sdoc == nil && serviceDependsOnContainer != nil:
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return equalSlice(sdoc.Slice, serviceDependsOnContainer.Slice) &&
|
||||||
|
EqualStringMap(sdoc.DependsOn, serviceDependsOnContainer.DependsOn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalYAML implements the MarshalYAML interface to customize the behavior when being marshaled into a YAML document.
|
||||||
|
func (sdoc *DependsOnContainer) MarshalYAML() (interface{}, error) {
|
||||||
|
var foundAnotherCondition bool = false
|
||||||
|
var dependencyNames []string
|
||||||
|
|
||||||
|
for dependencyName, dependencyDefinition := range sdoc.DependsOn {
|
||||||
|
if dependencyDefinition.Condition == ServiceDependsOnConditionServiceStarted {
|
||||||
|
dependencyNames = append(dependencyNames, dependencyName)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
foundAnotherCondition = true
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case foundAnotherCondition:
|
||||||
|
return sdoc.DependsOn, nil
|
||||||
|
case !foundAnotherCondition && len(dependencyNames) > 0:
|
||||||
|
return dependencyNames, nil
|
||||||
|
default:
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalYAML implements the UnmarshalYAML interface to customize the behavior when being unmarshaled into a YAML
|
||||||
|
// document.
|
||||||
|
func (sdoc *DependsOnContainer) UnmarshalYAML(value *yaml.Node) error {
|
||||||
|
if sdoc.DependsOn == nil {
|
||||||
|
sdoc.DependsOn = make(map[string]*ServiceDependsOn)
|
||||||
|
}
|
||||||
|
|
||||||
|
if sdoc.Slice == nil {
|
||||||
|
sdoc.Slice = make([]string, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := value.Decode(&sdoc.Slice); err == nil {
|
||||||
|
for _, s := range sdoc.Slice {
|
||||||
|
sdoc.DependsOn[s] = &ServiceDependsOn{
|
||||||
|
Condition: ServiceDependsOnConditionServiceStarted,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := value.Decode(sdoc.DependsOn); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// NewService returns an empty initialized Service.
|
// NewService returns an empty initialized Service.
|
||||||
func NewService() *Service {
|
func NewService() *Service {
|
||||||
return &Service{
|
return &Service{
|
||||||
@ -1185,13 +1346,38 @@ func NewService() *Service {
|
|||||||
ExtraHosts: make([]string, 0),
|
ExtraHosts: make([]string, 0),
|
||||||
Labels: make([]string, 0),
|
Labels: make([]string, 0),
|
||||||
Networks: make(map[string]*ServiceNetwork),
|
Networks: make(map[string]*ServiceNetwork),
|
||||||
Ports: make([]string, 0),
|
Ports: make([]Port, 0),
|
||||||
Secrets: make([]string, 0),
|
Secrets: make([]string, 0),
|
||||||
ULimits: new(ServiceULimits),
|
ULimits: new(ServiceULimits),
|
||||||
Volumes: make([]string, 0),
|
Volumes: make([]string, 0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ServiceDependsOn struct {
|
||||||
|
Condition string `yaml:"condition,omitempty"`
|
||||||
|
Restart string `yaml:"restart,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equal returns true if the passed equalable is equal
|
||||||
|
func (sdo *ServiceDependsOn) Equal(equalable Equalable) bool {
|
||||||
|
serviceDependsOn, ok := equalable.(*ServiceDependsOn)
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case sdo == nil && serviceDependsOn == nil:
|
||||||
|
return true
|
||||||
|
case sdo != nil && serviceDependsOn == nil:
|
||||||
|
fallthrough
|
||||||
|
case sdo == nil && serviceDependsOn != nil:
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return sdo.Condition == serviceDependsOn.Condition &&
|
||||||
|
sdo.Restart == serviceDependsOn.Restart
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type ServiceDeploy struct {
|
type ServiceDeploy struct {
|
||||||
Resources *ServiceDeployResources `json:"resources" yaml:"resources"`
|
Resources *ServiceDeployResources `json:"resources" yaml:"resources"`
|
||||||
}
|
}
|
||||||
@ -1873,7 +2059,7 @@ func (v *Volume) MergeLastWin(volume *Volume) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Volume) mergeExistingWinExternal(external bool) {
|
func (v *Volume) mergeExistingWinExternal(_ bool) {
|
||||||
if v.External {
|
if v.External {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1926,17 +2112,35 @@ func splitStringInKeyValue(s, sep string) (string, string) {
|
|||||||
return key, value
|
return key, value
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitStringInPort(s string) (string, string, string) {
|
// splitStringInPortMapping parses a string and returns the src, dest port including an optional protocol.
|
||||||
parts := strings.Split(s, portDelimiter)
|
//
|
||||||
src := parts[0]
|
// // Example
|
||||||
rest := parts[1]
|
// s, d, p := splitStringInPortMapping("80:80/tcp")
|
||||||
|
// // Output: "80" "80" "tcp"
|
||||||
|
// s, d, p := splitStringInPortMapping("0.0.0.0:80:80/tcp")
|
||||||
|
// // Output: "0.0.0.0:80" "80" "tcp"
|
||||||
|
//
|
||||||
|
// Deprecated: Instead of using the splitStringInPortMapping function, use the method of the type Port{}.
|
||||||
|
func splitStringInPortMapping(s string) (string, string, string) {
|
||||||
|
p := Port(s)
|
||||||
|
|
||||||
parts = strings.Split(rest, portProtocolDelimiter)
|
var src string
|
||||||
if len(parts) == 2 {
|
switch {
|
||||||
return src, parts[0], parts[1]
|
case p.existsSrcIP() && p.existsSrcPort():
|
||||||
|
src = fmt.Sprintf("%s:%s", p.getSrcIP(), p.getSrcPort())
|
||||||
|
case !p.existsSrcIP():
|
||||||
|
src = p.getSrcPort()
|
||||||
}
|
}
|
||||||
|
|
||||||
return src, parts[0], ""
|
var dst string
|
||||||
|
switch {
|
||||||
|
case p.existsDstIP() && p.existsDstPort():
|
||||||
|
dst = fmt.Sprintf("%s:%s", p.getDstIP(), p.getDstPort())
|
||||||
|
case !p.existsDstIP():
|
||||||
|
dst = p.getDstPort()
|
||||||
|
}
|
||||||
|
|
||||||
|
return src, dst, p.getProtocol()
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitStringInVolume(s string) (string, string, string) {
|
func splitStringInVolume(s string) (string, string, string) {
|
||||||
@ -1949,3 +2153,131 @@ func splitStringInVolume(s string) (string, string, string) {
|
|||||||
}
|
}
|
||||||
return src, dest, ""
|
return src, dest, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
regExpPort = regexp.MustCompile(`^((?<srcIP>([\d]{1,3}\.){3}[\d]{1,3}):)?(?<srcPort>[\d]{1,5}):((?<dstIP>([\d]{1,3}\.){3}[\d]{1,3}):)?(?<dstPort>[\d]{1,5})(\/(?<protocol>[a-z]*))?$`)
|
||||||
|
)
|
||||||
|
|
||||||
|
type Port string
|
||||||
|
|
||||||
|
// existsDstPort returns true, if the port string contains a trailing destination port definition.
|
||||||
|
func (p Port) existsDstPort() bool {
|
||||||
|
return len(p.getDstPort()) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// existsDstIP returns true, if the port string contains a trailing destination ip definition.
|
||||||
|
func (p Port) existsDstIP() bool {
|
||||||
|
return len(p.getDstIP()) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// existsProtocol returns true, if the port string contains a protocol definition.
|
||||||
|
func (p Port) existsProtocol() bool {
|
||||||
|
return len(p.getProtocol()) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// existsSrcIP returns true, if the port string contains a leading src ip definition.
|
||||||
|
func (p Port) existsSrcIP() bool {
|
||||||
|
return len(p.getSrcIP()) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// existsSrcPort returns true, if the port string contains a leading src port definition.
|
||||||
|
func (p Port) existsSrcPort() bool {
|
||||||
|
return len(p.getSrcPort()) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// getDst returns the concatenation of the destination ip and port. If the destination ip is empty, only the port will
|
||||||
|
// be returned.
|
||||||
|
func (p Port) getDst() string {
|
||||||
|
switch {
|
||||||
|
case p.existsDstIP():
|
||||||
|
return fmt.Sprintf("%s%s%s", p.getDstIP(), portDelimiter, p.getDstPort())
|
||||||
|
default:
|
||||||
|
return p.getDstPort()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// getSrcIP returns the destination ip, if the port string contains a destination ip definition.
|
||||||
|
func (p Port) getDstIP() string {
|
||||||
|
matches := regExpPort.FindStringSubmatch(string(p))
|
||||||
|
i := regExpPort.SubexpIndex("dstIP")
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case len(matches) <= 0:
|
||||||
|
return ""
|
||||||
|
case i < 0:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return matches[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
// getSrcPort returns the destination port, if the port string contains an destination port definition.
|
||||||
|
func (p Port) getDstPort() string {
|
||||||
|
matches := regExpPort.FindStringSubmatch(string(p))
|
||||||
|
i := regExpPort.SubexpIndex("dstPort")
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case len(matches) <= 0:
|
||||||
|
return ""
|
||||||
|
case i < 0:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return matches[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
// getProtocol returns the protocol, if the port string contains a protocol definition.
|
||||||
|
func (p Port) getProtocol() string {
|
||||||
|
matches := regExpPort.FindStringSubmatch(string(p))
|
||||||
|
i := regExpPort.SubexpIndex("protocol")
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case len(matches) <= 0:
|
||||||
|
return ""
|
||||||
|
case i < 0:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return matches[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
// getSrc returns the concatenation of the source ip and port. If the source ip is empty, only the port will be
|
||||||
|
// returned.
|
||||||
|
func (p Port) getSrc() string {
|
||||||
|
switch {
|
||||||
|
case p.existsSrcIP():
|
||||||
|
return fmt.Sprintf("%s%s%s", p.getSrcIP(), portDelimiter, p.getSrcPort())
|
||||||
|
default:
|
||||||
|
return p.getSrcPort()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// getSrcIP returns the source ip, if the port string contains an src ip definition.
|
||||||
|
func (p Port) getSrcIP() string {
|
||||||
|
matches := regExpPort.FindStringSubmatch(string(p))
|
||||||
|
i := regExpPort.SubexpIndex("srcIP")
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case len(matches) <= 0:
|
||||||
|
return ""
|
||||||
|
case i < 0:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return matches[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
// getSrcPort returns the source port, if the port string contains an src port definition.
|
||||||
|
func (p Port) getSrcPort() string {
|
||||||
|
matches := regExpPort.FindStringSubmatch(string(p))
|
||||||
|
i := regExpPort.SubexpIndex("srcPort")
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case len(matches) <= 0:
|
||||||
|
return ""
|
||||||
|
case i < 0:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return matches[i]
|
||||||
|
}
|
||||||
|
418
pkg/domain/dockerCompose/config_intern_test.go
Normal file
418
pkg/domain/dockerCompose/config_intern_test.go
Normal file
@ -0,0 +1,418 @@
|
|||||||
|
package dockerCompose
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_splitStringInPortMapping(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
s string
|
||||||
|
expectedSrc string
|
||||||
|
expectedDst string
|
||||||
|
expectedProtocol string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
s: "53:53",
|
||||||
|
expectedSrc: "53",
|
||||||
|
expectedDst: "53",
|
||||||
|
expectedProtocol: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:53",
|
||||||
|
expectedSrc: "0.0.0.0:53",
|
||||||
|
expectedDst: "53",
|
||||||
|
expectedProtocol: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:10.11.12.13:53",
|
||||||
|
expectedSrc: "0.0.0.0:53",
|
||||||
|
expectedDst: "10.11.12.13:53",
|
||||||
|
expectedProtocol: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:10.11.12.13:53/tcp",
|
||||||
|
expectedSrc: "0.0.0.0:53",
|
||||||
|
expectedDst: "10.11.12.13:53",
|
||||||
|
expectedProtocol: "tcp",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, testCase := range testCases {
|
||||||
|
actualSrc, actualDst, actualProtocol := splitStringInPortMapping(testCase.s)
|
||||||
|
require.Equal(testCase.expectedSrc, actualSrc, "TestCase %v", i)
|
||||||
|
require.Equal(testCase.expectedDst, actualDst, "TestCase %v", i)
|
||||||
|
require.Equal(testCase.expectedProtocol, actualProtocol, "TestCase %v", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPort_DstIP(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
s string
|
||||||
|
expectedBool bool
|
||||||
|
expectedString string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
s: "",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53/tcp",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53/udp",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:0.0.0.0:53",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "0.0.0.0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:0.0.0.0:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "0.0.0.0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:0.0.0.0:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "0.0.0.0",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
s: "10.11.12.13:53",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:10.11.12.13:53",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "10.11.12.13",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:10.11.12.13:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "10.11.12.13",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:10.11.12.13:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "10.11.12.13",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, testCase := range testCases {
|
||||||
|
p := Port(testCase.s)
|
||||||
|
require.Equal(testCase.expectedBool, p.existsDstIP(), "TestCase %v", i)
|
||||||
|
require.Equal(testCase.expectedString, p.getDstIP(), "TestCase %v", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPort_DstPort(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
s string
|
||||||
|
expectedBool bool
|
||||||
|
expectedString string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
s: "",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
s: "53:0.0.0.0:53",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:0.0.0.0:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:0.0.0.0:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
s: "53:10.11.12.13:53",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:10.11.12.13:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:10.11.12.13:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, testCase := range testCases {
|
||||||
|
p := Port(testCase.s)
|
||||||
|
require.Equal(testCase.expectedBool, p.existsDstPort(), "TestCase %v", i)
|
||||||
|
require.Equal(testCase.expectedString, p.getDstPort(), "TestCase %v", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPort_Protocol(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
s string
|
||||||
|
expectedBool bool
|
||||||
|
expectedString string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
s: "0",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53/tcp",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53/udp",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "tcp",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "udp",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "tcp",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "udp",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "tcp",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:11.12.13.14:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "tcp",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:11.12.13.14:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "udp",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, testCase := range testCases {
|
||||||
|
p := Port(testCase.s)
|
||||||
|
require.Equal(testCase.expectedBool, p.existsProtocol(), "TestCase %v", i)
|
||||||
|
require.Equal(testCase.expectedString, p.getProtocol(), "TestCase %v", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPort_SrcIP(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
s string
|
||||||
|
expectedBool bool
|
||||||
|
expectedString string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
s: "",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53/tcp",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53/udp",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:53",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "0.0.0.0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "0.0.0.0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "0.0.0.0",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
s: "10.11.12.13:53",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "10.11.12.13:53:53",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "10.11.12.13",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "10.11.12.13:53:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "10.11.12.13",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "10.11.12.13:53:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "10.11.12.13",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, testCase := range testCases {
|
||||||
|
p := Port(testCase.s)
|
||||||
|
require.Equal(testCase.expectedBool, p.existsSrcIP(), "TestCase %v", i)
|
||||||
|
require.Equal(testCase.expectedString, p.getSrcIP(), "TestCase %v", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPort_SrcPort(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
s string
|
||||||
|
expectedBool bool
|
||||||
|
expectedString string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
s: "",
|
||||||
|
expectedBool: false,
|
||||||
|
expectedString: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "53:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:53",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "0.0.0.0:53:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
s: "10.11.12.13:53:53",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "10.11.12.13:53:53/tcp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: "10.11.12.13:53:53/udp",
|
||||||
|
expectedBool: true,
|
||||||
|
expectedString: "53",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, testCase := range testCases {
|
||||||
|
p := Port(testCase.s)
|
||||||
|
require.Equal(testCase.expectedBool, p.existsSrcPort(), "TestCase %v", i)
|
||||||
|
require.Equal(testCase.expectedString, p.getSrcPort(), "TestCase %v", i)
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,90 @@
|
|||||||
package dockerCompose_test
|
package dockerCompose_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"embed"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.cryptic.systems/volker.raschek/dcmerge/pkg/domain/dockerCompose"
|
"git.cryptic.systems/volker.raschek/dcmerge/pkg/domain/dockerCompose"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:embed test/assets/merge
|
||||||
|
var testAssetsMerge embed.FS
|
||||||
|
|
||||||
|
func TestConfig_Merge(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
testAssetPath := "test/assets/merge"
|
||||||
|
|
||||||
|
testAssetMergeDirEntries, err := testAssetsMerge.ReadDir(testAssetPath)
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
// iterate over testcase directories
|
||||||
|
for i, mergeDirEntry := range testAssetMergeDirEntries {
|
||||||
|
if !mergeDirEntry.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// iterate over files in testcase directories
|
||||||
|
testCaseAssetPath := testAssetPath + "/" + mergeDirEntry.Name()
|
||||||
|
testCaseDirEntries, err := testAssetsMerge.ReadDir(testCaseAssetPath)
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
expectedDockerComposeConfig := &dockerCompose.Config{}
|
||||||
|
dockerComposeConfigs := []*dockerCompose.Config{}
|
||||||
|
for _, testCaseDirEntry := range testCaseDirEntries {
|
||||||
|
if testCaseDirEntry.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
dockerComposeConfigFile := testAssetPath + "/" + mergeDirEntry.Name() + "/" + testCaseDirEntry.Name()
|
||||||
|
b, err := testAssetsMerge.ReadFile(dockerComposeConfigFile)
|
||||||
|
require.NoError(err)
|
||||||
|
yamlDecoder := yaml.NewDecoder(bytes.NewReader(b))
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case strings.HasPrefix(testCaseDirEntry.Name(), "expectedResult"):
|
||||||
|
err = yamlDecoder.Decode(expectedDockerComposeConfig)
|
||||||
|
require.NoError(err)
|
||||||
|
case strings.HasSuffix(testCaseDirEntry.Name(), ".yml") || strings.HasSuffix(testCaseDirEntry.Name(), ".yaml"):
|
||||||
|
dockerComposeConfig := &dockerCompose.Config{}
|
||||||
|
err = yamlDecoder.Decode(dockerComposeConfig)
|
||||||
|
require.NoError(err)
|
||||||
|
dockerComposeConfigs = append(dockerComposeConfigs, dockerComposeConfig)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actualDockerComposeConfig := &dockerCompose.Config{}
|
||||||
|
for _, dockerComposeConfig := range dockerComposeConfigs {
|
||||||
|
actualDockerComposeConfig.Merge(dockerComposeConfig)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedBytes := make([]byte, 0)
|
||||||
|
expectedBytesBuffer := bytes.NewBuffer(expectedBytes)
|
||||||
|
yamlEncoder := yaml.NewEncoder(expectedBytesBuffer)
|
||||||
|
err = yamlEncoder.Encode(expectedDockerComposeConfig)
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
err = yamlEncoder.Close()
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
actualBytes := make([]byte, 0)
|
||||||
|
actualBytesBuffer := bytes.NewBuffer(actualBytes)
|
||||||
|
yamlEncoder = yaml.NewEncoder(actualBytesBuffer)
|
||||||
|
err = yamlEncoder.Encode(actualDockerComposeConfig)
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
err = yamlEncoder.Close()
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
require.Equal(expectedBytesBuffer.String(), actualBytesBuffer.String(), "TestCase %v", i)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func TestNetwork_Equal(t *testing.T) {
|
func TestNetwork_Equal(t *testing.T) {
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
@ -225,13 +303,14 @@ func TestService_Equal(t *testing.T) {
|
|||||||
equalableA: &dockerCompose.Service{
|
equalableA: &dockerCompose.Service{
|
||||||
CapabilitiesAdd: []string{},
|
CapabilitiesAdd: []string{},
|
||||||
CapabilitiesDrop: []string{},
|
CapabilitiesDrop: []string{},
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{},
|
||||||
Deploy: nil,
|
Deploy: nil,
|
||||||
Environments: []string{},
|
Environments: []string{},
|
||||||
ExtraHosts: []string{},
|
ExtraHosts: []string{},
|
||||||
Image: "",
|
Image: "",
|
||||||
Labels: []string{},
|
Labels: []string{},
|
||||||
Networks: map[string]*dockerCompose.ServiceNetwork{},
|
Networks: map[string]*dockerCompose.ServiceNetwork{},
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
Secrets: []string{},
|
Secrets: []string{},
|
||||||
ULimits: nil,
|
ULimits: nil,
|
||||||
Volumes: []string{},
|
Volumes: []string{},
|
||||||
@ -239,13 +318,14 @@ func TestService_Equal(t *testing.T) {
|
|||||||
equalableB: &dockerCompose.Service{
|
equalableB: &dockerCompose.Service{
|
||||||
CapabilitiesAdd: []string{},
|
CapabilitiesAdd: []string{},
|
||||||
CapabilitiesDrop: []string{},
|
CapabilitiesDrop: []string{},
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{},
|
||||||
Deploy: nil,
|
Deploy: nil,
|
||||||
Environments: []string{},
|
Environments: []string{},
|
||||||
ExtraHosts: []string{},
|
ExtraHosts: []string{},
|
||||||
Image: "",
|
Image: "",
|
||||||
Labels: []string{},
|
Labels: []string{},
|
||||||
Networks: map[string]*dockerCompose.ServiceNetwork{},
|
Networks: map[string]*dockerCompose.ServiceNetwork{},
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
Secrets: []string{},
|
Secrets: []string{},
|
||||||
ULimits: nil,
|
ULimits: nil,
|
||||||
Volumes: []string{},
|
Volumes: []string{},
|
||||||
@ -288,6 +368,79 @@ func TestService_Equal(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedResult: false,
|
expectedResult: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
equalableA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{Slice: []string{"app"}},
|
||||||
|
},
|
||||||
|
equalableB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: nil,
|
||||||
|
},
|
||||||
|
expectedResult: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
equalableA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{Slice: []string{"app"}},
|
||||||
|
},
|
||||||
|
equalableB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{},
|
||||||
|
},
|
||||||
|
expectedResult: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
equalableA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{Slice: []string{"app"}},
|
||||||
|
},
|
||||||
|
equalableB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{Slice: []string{}},
|
||||||
|
},
|
||||||
|
expectedResult: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
equalableA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{Slice: []string{"app"}},
|
||||||
|
},
|
||||||
|
equalableB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{Slice: []string{"app"}},
|
||||||
|
},
|
||||||
|
expectedResult: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
equalableA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
equalableB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{},
|
||||||
|
},
|
||||||
|
expectedResult: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
equalableA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
equalableB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{},
|
||||||
|
},
|
||||||
|
expectedResult: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
equalableA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
equalableB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{}},
|
||||||
|
},
|
||||||
|
expectedResult: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
equalableA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
equalableB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
expectedResult: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
equalableA: &dockerCompose.Service{
|
equalableA: &dockerCompose.Service{
|
||||||
Deploy: &dockerCompose.ServiceDeploy{},
|
Deploy: &dockerCompose.ServiceDeploy{},
|
||||||
@ -398,19 +551,19 @@ func TestService_Equal(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
equalableA: &dockerCompose.Service{
|
equalableA: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80/tcp"},
|
Ports: []dockerCompose.Port{"80:80/tcp"},
|
||||||
},
|
},
|
||||||
equalableB: &dockerCompose.Service{
|
equalableB: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80/tcp"},
|
Ports: []dockerCompose.Port{"80:80/tcp"},
|
||||||
},
|
},
|
||||||
expectedResult: true,
|
expectedResult: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
equalableA: &dockerCompose.Service{
|
equalableA: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80/tcp"},
|
Ports: []dockerCompose.Port{"80:80/tcp"},
|
||||||
},
|
},
|
||||||
equalableB: &dockerCompose.Service{
|
equalableB: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80/udp"},
|
Ports: []dockerCompose.Port{"80:80/udp"},
|
||||||
},
|
},
|
||||||
expectedResult: false,
|
expectedResult: false,
|
||||||
},
|
},
|
||||||
@ -575,6 +728,52 @@ func TestService_MergeExistingWin(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// DependsOn
|
||||||
|
{
|
||||||
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{},
|
||||||
|
},
|
||||||
|
expectedService: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{},
|
||||||
|
},
|
||||||
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
expectedService: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
expectedService: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: nil,
|
||||||
|
},
|
||||||
|
expectedService: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
// Deploy
|
// Deploy
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
@ -1042,13 +1241,13 @@ func TestService_MergeExistingWin(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: nil,
|
Ports: nil,
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1056,65 +1255,102 @@ func TestService_MergeExistingWin(t *testing.T) {
|
|||||||
Ports: nil,
|
Ports: nil,
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{"10080:80"},
|
Ports: []dockerCompose.Port{"80:8080"},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80/tcp"},
|
Ports: []dockerCompose.Port{"80:80/tcp"},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80/tcp"},
|
Ports: []dockerCompose.Port{"80:80/tcp"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{"10080:80/udp"},
|
Ports: []dockerCompose.Port{"80:80/udp"},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"0.0.0.0:15005:5005/tcp",
|
||||||
|
"0.0.0.0:18080:8080/tcp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{"0.0.0.0:6300:6300/tcp"},
|
||||||
|
},
|
||||||
|
expectedService: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"0.0.0.0:15005:5005/tcp",
|
||||||
|
"0.0.0.0:18080:8080/tcp",
|
||||||
|
"0.0.0.0:6300:6300/tcp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"0.0.0.0:15005:5005/tcp",
|
||||||
|
"0.0.0.0:18080:8080/tcp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"15005:15005",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedService: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"0.0.0.0:15005:5005/tcp",
|
||||||
|
"0.0.0.0:18080:8080/tcp",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1476,6 +1712,52 @@ func TestService_MergeLastWin(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// DependsOn
|
||||||
|
{
|
||||||
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{},
|
||||||
|
},
|
||||||
|
expectedService: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{},
|
||||||
|
},
|
||||||
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
expectedService: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
expectedService: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: nil,
|
||||||
|
},
|
||||||
|
expectedService: &dockerCompose.Service{
|
||||||
|
DependsOnContainer: &dockerCompose.DependsOnContainer{DependsOn: map[string]*dockerCompose.ServiceDependsOn{"app": {Condition: "service_started"}}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
// Deploy
|
// Deploy
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
@ -1904,13 +2186,13 @@ func TestService_MergeLastWin(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: nil,
|
Ports: nil,
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1918,76 +2200,113 @@ func TestService_MergeLastWin(t *testing.T) {
|
|||||||
Ports: nil,
|
Ports: nil,
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{},
|
Ports: []dockerCompose.Port{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{"10080:80"},
|
Ports: []dockerCompose.Port{"80:10080"},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{"10080:80"},
|
Ports: []dockerCompose.Port{"80:10080"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80/tcp"},
|
Ports: []dockerCompose.Port{"80:80/tcp"},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{"10080:80/udp"},
|
Ports: []dockerCompose.Port{"80:80/udp"},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{"10080:80/udp"},
|
Ports: []dockerCompose.Port{"80:80/udp"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serviceDeploymentA: &dockerCompose.Service{
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
},
|
},
|
||||||
serviceDeploymentB: &dockerCompose.Service{
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
Ports: []string{""},
|
Ports: []dockerCompose.Port{""},
|
||||||
},
|
},
|
||||||
expectedService: &dockerCompose.Service{
|
expectedService: &dockerCompose.Service{
|
||||||
Ports: []string{"80:80"},
|
Ports: []dockerCompose.Port{"80:80"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"0.0.0.0:15005:5005/tcp",
|
||||||
|
"0.0.0.0:18080:8080/tcp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{"0.0.0.0:6300:6300/tcp"},
|
||||||
|
},
|
||||||
|
expectedService: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"0.0.0.0:15005:5005/tcp",
|
||||||
|
"0.0.0.0:18080:8080/tcp",
|
||||||
|
"0.0.0.0:6300:6300/tcp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
serviceDeploymentA: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"0.0.0.0:15005:5005/tcp",
|
||||||
|
"0.0.0.0:18080:8080/tcp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
serviceDeploymentB: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"0.0.0.0:15005:15005",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedService: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"0.0.0.0:15005:15005",
|
||||||
|
"0.0.0.0:18080:8080/tcp",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -2260,6 +2579,203 @@ func TestService_MergeLastWin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestService_RemovePortByDst(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
s *dockerCompose.Service
|
||||||
|
removePortsByDst []string
|
||||||
|
expectedPorts []dockerCompose.Port
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"80:80/tcp",
|
||||||
|
"0.0.0.0:443:172.25.18.20:443/tcp",
|
||||||
|
"10.11.12.13:53:53/tcp",
|
||||||
|
"10.11.12.13:53:53/udp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
removePortsByDst: []string{
|
||||||
|
"53",
|
||||||
|
},
|
||||||
|
expectedPorts: []dockerCompose.Port{
|
||||||
|
"80:80/tcp",
|
||||||
|
"0.0.0.0:443:172.25.18.20:443/tcp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"80:80/tcp",
|
||||||
|
"0.0.0.0:443:172.25.18.20:443/tcp",
|
||||||
|
"10.11.12.13:53:53/tcp",
|
||||||
|
"10.11.12.13:53:53/udp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
removePortsByDst: []string{
|
||||||
|
"172.25.18.20:443",
|
||||||
|
},
|
||||||
|
expectedPorts: []dockerCompose.Port{
|
||||||
|
"80:80/tcp",
|
||||||
|
"10.11.12.13:53:53/tcp",
|
||||||
|
"10.11.12.13:53:53/udp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"0.0.0.0:443:443/tcp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
removePortsByDst: []string{
|
||||||
|
"443",
|
||||||
|
},
|
||||||
|
expectedPorts: []dockerCompose.Port{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, testCase := range testCases {
|
||||||
|
for _, removePortByDst := range testCase.removePortsByDst {
|
||||||
|
testCase.s.RemovePortByDst(removePortByDst)
|
||||||
|
}
|
||||||
|
require.Equal(testCase.expectedPorts, testCase.s.Ports, "TestCase %v", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestService_RemovePortBySrc(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
s *dockerCompose.Service
|
||||||
|
removePortsBySrc []string
|
||||||
|
expectedPorts []dockerCompose.Port
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"80:80/tcp",
|
||||||
|
"0.0.0.0:443:172.25.18.20:443/tcp",
|
||||||
|
"10.11.12.13:53:53/tcp",
|
||||||
|
"10.11.12.13:53:53/udp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
removePortsBySrc: []string{
|
||||||
|
"10.11.12.13:53",
|
||||||
|
},
|
||||||
|
expectedPorts: []dockerCompose.Port{
|
||||||
|
"80:80/tcp",
|
||||||
|
"0.0.0.0:443:172.25.18.20:443/tcp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"80:80/tcp",
|
||||||
|
"0.0.0.0:443:172.25.18.20:443/tcp",
|
||||||
|
"10.11.12.13:53:53/tcp",
|
||||||
|
"10.11.12.13:53:53/udp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
removePortsBySrc: []string{
|
||||||
|
"0.0.0.0:443",
|
||||||
|
},
|
||||||
|
expectedPorts: []dockerCompose.Port{
|
||||||
|
"80:80/tcp",
|
||||||
|
"10.11.12.13:53:53/tcp",
|
||||||
|
"10.11.12.13:53:53/udp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{
|
||||||
|
"0.0.0.0:443:443/tcp",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
removePortsBySrc: []string{
|
||||||
|
"0.0.0.0:443",
|
||||||
|
},
|
||||||
|
expectedPorts: []dockerCompose.Port{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, testCase := range testCases {
|
||||||
|
for _, removePortBySrc := range testCase.removePortsBySrc {
|
||||||
|
testCase.s.RemovePortBySrc(removePortBySrc)
|
||||||
|
}
|
||||||
|
require.Equal(testCase.expectedPorts, testCase.s.Ports, "TestCase %v", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestService_SetPort(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
s *dockerCompose.Service
|
||||||
|
setPorts []string
|
||||||
|
expectedPorts []dockerCompose.Port
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{"8080:8080"},
|
||||||
|
},
|
||||||
|
setPorts: []string{},
|
||||||
|
expectedPorts: []dockerCompose.Port{"8080:8080"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{"8080:8080"},
|
||||||
|
},
|
||||||
|
setPorts: []string{"8080:8080"},
|
||||||
|
expectedPorts: []dockerCompose.Port{"8080:8080"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{"8080:8080"},
|
||||||
|
},
|
||||||
|
setPorts: []string{"8080:80"},
|
||||||
|
expectedPorts: []dockerCompose.Port{"8080:80"},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{"0.0.0.0:8080:8080"},
|
||||||
|
},
|
||||||
|
setPorts: []string{},
|
||||||
|
expectedPorts: []dockerCompose.Port{"0.0.0.0:8080:8080"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{"0.0.0.0:8080:8080"},
|
||||||
|
},
|
||||||
|
setPorts: []string{"0.0.0.0:8080:8080"},
|
||||||
|
expectedPorts: []dockerCompose.Port{"0.0.0.0:8080:8080"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{"0.0.0.0:8080:8080"},
|
||||||
|
},
|
||||||
|
setPorts: []string{"0.0.0.0:8080:80"},
|
||||||
|
expectedPorts: []dockerCompose.Port{"0.0.0.0:8080:80"},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
s: &dockerCompose.Service{
|
||||||
|
Ports: []dockerCompose.Port{"0.0.0.0:8080:8080", "0.0.0.0:8443:8443"},
|
||||||
|
},
|
||||||
|
setPorts: []string{"0.0.0.0:8080:80"},
|
||||||
|
expectedPorts: []dockerCompose.Port{"0.0.0.0:8080:80", "0.0.0.0:8443:8443"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, testCase := range testCases {
|
||||||
|
for _, setPort := range testCase.setPorts {
|
||||||
|
testCase.s.SetPort(setPort)
|
||||||
|
}
|
||||||
|
require.ElementsMatch(testCase.expectedPorts, testCase.s.Ports, "TestCase %v", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSecretDeploy_Equal(t *testing.T) {
|
func TestSecretDeploy_Equal(t *testing.T) {
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
services:
|
||||||
|
frontend:
|
||||||
|
depends_on:
|
||||||
|
backend:
|
||||||
|
condition: service_started
|
||||||
|
image: library/frontend:latest
|
@ -0,0 +1,3 @@
|
|||||||
|
services:
|
||||||
|
backend:
|
||||||
|
image: library/backend:latest
|
@ -0,0 +1,7 @@
|
|||||||
|
services:
|
||||||
|
backend:
|
||||||
|
image: library/backend:latest
|
||||||
|
frontend:
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
image: library/frontend:latest
|
@ -0,0 +1,5 @@
|
|||||||
|
services:
|
||||||
|
frontend:
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
image: library/frontend:latest
|
@ -0,0 +1,3 @@
|
|||||||
|
services:
|
||||||
|
backend:
|
||||||
|
image: library/backend:latest
|
@ -0,0 +1,7 @@
|
|||||||
|
services:
|
||||||
|
backend:
|
||||||
|
image: library/backend:latest
|
||||||
|
frontend:
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
image: library/frontend:latest
|
@ -0,0 +1,6 @@
|
|||||||
|
services:
|
||||||
|
frontend:
|
||||||
|
depends_on:
|
||||||
|
backend:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
image: library/frontend:latest
|
@ -0,0 +1,3 @@
|
|||||||
|
services:
|
||||||
|
backend:
|
||||||
|
image: library/backend:latest
|
@ -0,0 +1,8 @@
|
|||||||
|
services:
|
||||||
|
backend:
|
||||||
|
image: library/backend:latest
|
||||||
|
frontend:
|
||||||
|
depends_on:
|
||||||
|
backend:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
image: library/frontend:latest
|
@ -8,7 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"git.cryptic.systems/volker.raschek/dcmerge/pkg/domain/dockerCompose"
|
"git.cryptic.systems/volker.raschek/dcmerge/pkg/domain/dockerCompose"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Fetch(urls ...string) ([]*dockerCompose.Config, error) {
|
func Fetch(urls ...string) ([]*dockerCompose.Config, error) {
|
||||||
@ -75,7 +75,7 @@ func getDockerComposeViaHTTP(url string) (*dockerCompose.Config, error) {
|
|||||||
func readDockerComposeFromFile(name string) (*dockerCompose.Config, error) {
|
func readDockerComposeFromFile(name string) (*dockerCompose.Config, error) {
|
||||||
fileStat, err := os.Stat(name)
|
fileStat, err := os.Stat(name)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, os.ErrNotExist):
|
case err != nil:
|
||||||
return nil, err
|
return nil, err
|
||||||
case fileStat.IsDir():
|
case fileStat.IsDir():
|
||||||
return nil, fmt.Errorf("%w: %s", ErrorPathIsDir, name)
|
return nil, fmt.Errorf("%w: %s", ErrorPathIsDir, name)
|
||||||
|
@ -1,31 +1,10 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
"assignees": [ "volker.raschek" ],
|
"extends": [
|
||||||
"automergeStrategy": "merge-commit",
|
"local>volker.raschek/renovate-config:default#master",
|
||||||
"automergeType": "pr",
|
"local>volker.raschek/renovate-config:container#master",
|
||||||
"labels": [ "renovate" ],
|
"local>volker.raschek/renovate-config:actions#master",
|
||||||
"packageRules": [
|
"local>volker.raschek/renovate-config:golang#master",
|
||||||
{
|
"local>volker.raschek/renovate-config:regexp#master"
|
||||||
"addLabels": [ "renovate/droneci", "renovate/automerge" ],
|
]
|
||||||
"automerge": true,
|
|
||||||
"matchManagers": "droneci",
|
|
||||||
"matchUpdateTypes": [ "minor", "patch"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Automatically update patch version of used container images in docker files",
|
|
||||||
"addLabels": [ "renovate/container-image", "renovate/automerge" ],
|
|
||||||
"automerge": true,
|
|
||||||
"matchBaseBranches": [ "master" ],
|
|
||||||
"matchManagers": [ "dockerfile" ],
|
|
||||||
"matchUpdateTypes": [ "patch" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"addLabels": [ "renovate/dcmerge", "renovate/automerge" ],
|
|
||||||
"automerge": false,
|
|
||||||
"matchPackageNames": [ "dcmerge" ],
|
|
||||||
"matchManagers": [ "regex" ]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"rebaseLabel": "renovate/rebase",
|
|
||||||
"rebaseWhen": "behind-base-branch"
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
version: "3.3"
|
version: "3.3"
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
|
depends_on:
|
||||||
|
- oracle
|
||||||
environment:
|
environment:
|
||||||
- HTTP_PROXY=1.2.3.4:8080
|
- HTTP_PROXY=1.2.3.4:8080
|
||||||
image: repository:version
|
image: repository:version
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
version: "3.3"
|
version: "3.3"
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
environment:
|
environment:
|
||||||
- HTTP_PROXY=4.3.2.1:8080
|
- HTTP_PROXY=4.3.2.1:8080
|
||||||
image: repository:version
|
image: repository:version
|
||||||
|
Reference in New Issue
Block a user