You've already forked dcmerge
							
							Compare commits
	
		
			40 Commits
		
	
	
		
			v0.1.1
			...
			669ebd0f25
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 669ebd0f25 | |||
| 8f794494a2 | |||
| 
						
						
							
						
						8e411cc486
	
				 | 
					
					
						|||
| d7e8970860 | |||
| 8603eca0b5 | |||
| 
						
						
							
						
						d8ada5578b
	
				 | 
					
					
						|||
| 4f5d115926 | |||
| dac3be4e2d | |||
| 173637693f | |||
| 3ba641aa12 | |||
| 768a49319d | |||
| 66f5fff92a | |||
| b6b2e069cd | |||
| 2c738d0417 | |||
| 
						
						
							
						
						46dd067b48
	
				 | 
					
					
						|||
| 9669685997 | |||
| 9a76f3432a | |||
| 
						
						
							
						
						751bb810d2
	
				 | 
					
					
						|||
| 
						
						
							
						
						9b469bd8c6
	
				 | 
					
					
						|||
| 
						
						
							
						
						4ad9da6d63
	
				 | 
					
					
						|||
| 
						
						
							
						
						2ea83b7591
	
				 | 
					
					
						|||
| 
						
						
							
						
						6f673e4a72
	
				 | 
					
					
						|||
| 
						
						
							
						
						d9ecf068c9
	
				 | 
					
					
						|||
| 
						
						
							
						
						4c3c6cd5d2
	
				 | 
					
					
						|||
| 
						
						
							
						
						23290fbd5d
	
				 | 
					
					
						|||
| 
						
						
							
						
						07673bfd53
	
				 | 
					
					
						|||
| 
						
						
							
						
						405a0258f1
	
				 | 
					
					
						|||
| 
						
						
							
						
						462299d5cd
	
				 | 
					
					
						|||
| 
						
						
							
						
						6524785871
	
				 | 
					
					
						|||
| 
						
						
							
						
						1207bcfcab
	
				 | 
					
					
						|||
| 
						
						
							
						
						a656dc2db1
	
				 | 
					
					
						|||
| 
						
						
							
						
						14c645dd96
	
				 | 
					
					
						|||
| 7b0109caf4 | |||
| 6bfd49947e | |||
| 04e0d98dde | |||
| 
						
						
							
						
						87ec3349ea
	
				 | 
					
					
						|||
| 
						
						
							
						
						ad1cf8cbef
	
				 | 
					
					
						|||
| 
						
						
							
						
						16f1f5e9da
	
				 | 
					
					
						|||
| 35d35f0b20 | |||
| 0375ccbf69 | 
							
								
								
									
										311
									
								
								.drone.yml
									
									
									
									
									
								
							
							
						
						
									
										311
									
								
								.drone.yml
									
									
									
									
									
								
							@@ -11,12 +11,12 @@ platform:
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.2.1
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: markdown lint
 | 
			
		||||
  commands:
 | 
			
		||||
  - markdownlint *.md
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/markdownlint:0.35.0
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/markdownlint:0.37.0
 | 
			
		||||
  resources:
 | 
			
		||||
    limits:
 | 
			
		||||
      cpu: 150
 | 
			
		||||
@@ -34,7 +34,7 @@ steps:
 | 
			
		||||
      from_secret: smtp_username
 | 
			
		||||
    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:
 | 
			
		||||
    limits:
 | 
			
		||||
      cpu: 150
 | 
			
		||||
@@ -49,6 +49,59 @@ trigger:
 | 
			
		||||
    exclude:
 | 
			
		||||
    - tag
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
kind: pipeline
 | 
			
		||||
type: docker
 | 
			
		||||
name: unit-test-amd64
 | 
			
		||||
 | 
			
		||||
clone:
 | 
			
		||||
  disable: true
 | 
			
		||||
 | 
			
		||||
platform:
 | 
			
		||||
  arch: amd64
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: unit-test
 | 
			
		||||
  commands:
 | 
			
		||||
  - go test -v ./...
 | 
			
		||||
  image: docker.io/library/golang:1.21.4
 | 
			
		||||
 | 
			
		||||
trigger:
 | 
			
		||||
  event:
 | 
			
		||||
    exclude:
 | 
			
		||||
    - tag
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
kind: pipeline
 | 
			
		||||
type: docker
 | 
			
		||||
name: unit-test-arm64
 | 
			
		||||
 | 
			
		||||
clone:
 | 
			
		||||
  disable: true
 | 
			
		||||
 | 
			
		||||
platform:
 | 
			
		||||
  arch: arm64
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: unit-test
 | 
			
		||||
  commands:
 | 
			
		||||
  - go test -v ./...
 | 
			
		||||
  image: docker.io/library/golang:1.21.4
 | 
			
		||||
 | 
			
		||||
trigger:
 | 
			
		||||
  event:
 | 
			
		||||
    include:
 | 
			
		||||
    - pull_request
 | 
			
		||||
    - push
 | 
			
		||||
    exclude:
 | 
			
		||||
    - tag
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
kind: pipeline
 | 
			
		||||
type: docker
 | 
			
		||||
@@ -59,6 +112,7 @@ clone:
 | 
			
		||||
 | 
			
		||||
depends_on:
 | 
			
		||||
- linter
 | 
			
		||||
- unit-test-amd64
 | 
			
		||||
 | 
			
		||||
platform:
 | 
			
		||||
  os: linux
 | 
			
		||||
@@ -66,10 +120,10 @@ platform:
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.2.1
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: build
 | 
			
		||||
  image: docker.io/plugins/docker:20.10.9
 | 
			
		||||
  image: docker.io/plugins/docker:20.17.1
 | 
			
		||||
  settings:
 | 
			
		||||
    auto_tag: false
 | 
			
		||||
    dockerfile: Dockerfile
 | 
			
		||||
@@ -99,73 +153,7 @@ steps:
 | 
			
		||||
      from_secret: smtp_username
 | 
			
		||||
    SMTP_PASSWORD:
 | 
			
		||||
      from_secret: smtp_password
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
 | 
			
		||||
  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
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
 | 
			
		||||
  when:
 | 
			
		||||
    status:
 | 
			
		||||
    - changed
 | 
			
		||||
@@ -191,6 +179,7 @@ clone:
 | 
			
		||||
 | 
			
		||||
depends_on:
 | 
			
		||||
- linter
 | 
			
		||||
- unit-test-arm64
 | 
			
		||||
 | 
			
		||||
platform:
 | 
			
		||||
  os: linux
 | 
			
		||||
@@ -198,10 +187,10 @@ platform:
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.2.1
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: build
 | 
			
		||||
  image: docker.io/plugins/docker:20.10.9
 | 
			
		||||
  image: docker.io/plugins/docker:20.17.1
 | 
			
		||||
  settings:
 | 
			
		||||
    auto_tag: false
 | 
			
		||||
    dockerfile: Dockerfile
 | 
			
		||||
@@ -231,7 +220,7 @@ steps:
 | 
			
		||||
      from_secret: smtp_username
 | 
			
		||||
    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
 | 
			
		||||
@@ -257,6 +246,7 @@ clone:
 | 
			
		||||
 | 
			
		||||
depends_on:
 | 
			
		||||
- linter
 | 
			
		||||
- unit-test-amd64
 | 
			
		||||
 | 
			
		||||
platform:
 | 
			
		||||
  os: linux
 | 
			
		||||
@@ -264,10 +254,10 @@ platform:
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.2.1
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: build
 | 
			
		||||
  image: docker.io/plugins/docker:20.10.9
 | 
			
		||||
  image: docker.io/plugins/docker:20.17.1
 | 
			
		||||
  settings:
 | 
			
		||||
    auto_tag: false
 | 
			
		||||
    dockerfile: Dockerfile
 | 
			
		||||
@@ -296,71 +286,7 @@ steps:
 | 
			
		||||
      from_secret: smtp_username
 | 
			
		||||
    SMTP_PASSWORD:
 | 
			
		||||
      from_secret: smtp_password
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
 | 
			
		||||
  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
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
 | 
			
		||||
  when:
 | 
			
		||||
    status:
 | 
			
		||||
    - changed
 | 
			
		||||
@@ -385,6 +311,7 @@ clone:
 | 
			
		||||
 | 
			
		||||
depends_on:
 | 
			
		||||
- linter
 | 
			
		||||
- unit-test-arm64
 | 
			
		||||
 | 
			
		||||
platform:
 | 
			
		||||
  os: linux
 | 
			
		||||
@@ -392,10 +319,10 @@ platform:
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.2.1
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: build
 | 
			
		||||
  image: docker.io/plugins/docker:20.10.9
 | 
			
		||||
  image: docker.io/plugins/docker:20.17.1
 | 
			
		||||
  settings:
 | 
			
		||||
    auto_tag: false
 | 
			
		||||
    dockerfile: Dockerfile
 | 
			
		||||
@@ -424,7 +351,7 @@ steps:
 | 
			
		||||
      from_secret: smtp_username
 | 
			
		||||
    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
 | 
			
		||||
@@ -449,7 +376,6 @@ clone:
 | 
			
		||||
 | 
			
		||||
depends_on:
 | 
			
		||||
- latest-amd64
 | 
			
		||||
- latest-arm-v7
 | 
			
		||||
- latest-arm64-v8
 | 
			
		||||
 | 
			
		||||
# docker.io/plugins/manifest only for amd64 architectures available
 | 
			
		||||
@@ -459,7 +385,7 @@ node_selector:
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.2.1
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: build-manifest
 | 
			
		||||
  image: docker.io/plugins/manifest:1.4.0
 | 
			
		||||
@@ -484,7 +410,7 @@ steps:
 | 
			
		||||
      from_secret: smtp_username
 | 
			
		||||
    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:
 | 
			
		||||
    limits:
 | 
			
		||||
      cpu: 150
 | 
			
		||||
@@ -516,7 +442,7 @@ depends_on:
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.2.1
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: latest-sync
 | 
			
		||||
  commands:
 | 
			
		||||
@@ -530,7 +456,7 @@ steps:
 | 
			
		||||
      from_secret: container_image_registry_user
 | 
			
		||||
    DEST_CRED_PASSWORD:
 | 
			
		||||
      from_secret: container_image_registry_password
 | 
			
		||||
  image: quay.io/skopeo/stable:v1.13.0
 | 
			
		||||
  image: quay.io/skopeo/stable:v1.13.3
 | 
			
		||||
 | 
			
		||||
- name: email-notification
 | 
			
		||||
  environment:
 | 
			
		||||
@@ -544,7 +470,7 @@ steps:
 | 
			
		||||
      from_secret: smtp_username
 | 
			
		||||
    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:
 | 
			
		||||
    limits:
 | 
			
		||||
      cpu: 150
 | 
			
		||||
@@ -577,10 +503,10 @@ platform:
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.2.1
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: build
 | 
			
		||||
  image: docker.io/plugins/docker:20.10.9
 | 
			
		||||
  image: docker.io/plugins/docker:20.17.1
 | 
			
		||||
  settings:
 | 
			
		||||
    auto_tag: true
 | 
			
		||||
    auto_tag_suffix: amd64
 | 
			
		||||
@@ -611,67 +537,7 @@ steps:
 | 
			
		||||
      from_secret: smtp_username
 | 
			
		||||
    SMTP_PASSWORD:
 | 
			
		||||
      from_secret: smtp_password
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/drone-email:0.1.2
 | 
			
		||||
  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
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/drone-email:0.1.5
 | 
			
		||||
  when:
 | 
			
		||||
    status:
 | 
			
		||||
    - changed
 | 
			
		||||
@@ -697,10 +563,10 @@ platform:
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.2.1
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: build
 | 
			
		||||
  image: docker.io/plugins/docker:20.10.9
 | 
			
		||||
  image: docker.io/plugins/docker:20.17.1
 | 
			
		||||
  settings:
 | 
			
		||||
    auto_tag: true
 | 
			
		||||
    auto_tag_suffix: arm64-v8
 | 
			
		||||
@@ -731,7 +597,7 @@ steps:
 | 
			
		||||
      from_secret: smtp_username
 | 
			
		||||
    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
 | 
			
		||||
@@ -753,7 +619,6 @@ clone:
 | 
			
		||||
 | 
			
		||||
depends_on:
 | 
			
		||||
- tagged-amd64
 | 
			
		||||
- tagged-arm-v7
 | 
			
		||||
- tagged-arm64-v8
 | 
			
		||||
 | 
			
		||||
# docker.io/plugins/manifest only for amd64 architectures available
 | 
			
		||||
@@ -763,7 +628,7 @@ node_selector:
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.2.1
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: build-manifest
 | 
			
		||||
  image: docker.io/plugins/manifest:1.4.0
 | 
			
		||||
@@ -788,7 +653,7 @@ steps:
 | 
			
		||||
      from_secret: smtp_username
 | 
			
		||||
    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:
 | 
			
		||||
    limits:
 | 
			
		||||
      cpu: 150
 | 
			
		||||
@@ -817,7 +682,7 @@ depends_on:
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
- name: clone
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.2.1
 | 
			
		||||
  image: git.cryptic.systems/volker.raschek/git:1.3.1
 | 
			
		||||
 | 
			
		||||
- name: tagged-sync
 | 
			
		||||
  commands:
 | 
			
		||||
@@ -831,7 +696,7 @@ steps:
 | 
			
		||||
      from_secret: container_image_registry_user
 | 
			
		||||
    DEST_CRED_PASSWORD:
 | 
			
		||||
      from_secret: container_image_registry_password
 | 
			
		||||
  image: quay.io/skopeo/stable:v1.13.0
 | 
			
		||||
  image: quay.io/skopeo/stable:v1.13.3
 | 
			
		||||
 | 
			
		||||
- name: email-notification
 | 
			
		||||
  environment:
 | 
			
		||||
@@ -845,7 +710,7 @@ steps:
 | 
			
		||||
      from_secret: smtp_username
 | 
			
		||||
    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:
 | 
			
		||||
    limits:
 | 
			
		||||
      cpu: 150
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
FROM docker.io/library/golang:1.20.6-alpine3.18 AS build
 | 
			
		||||
FROM docker.io/library/golang:1.21.4-alpine3.18 AS build
 | 
			
		||||
 | 
			
		||||
RUN apk add git make
 | 
			
		||||
 | 
			
		||||
@@ -10,7 +10,7 @@ RUN make install \
 | 
			
		||||
      PREFIX=/usr \
 | 
			
		||||
      VERSION=${VERSION}
 | 
			
		||||
 | 
			
		||||
FROM docker.io/library/alpine:3.18.2
 | 
			
		||||
FROM docker.io/library/alpine:3.18.4
 | 
			
		||||
 | 
			
		||||
COPY --from=build /cache /
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										13
									
								
								cmd/root.go
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								cmd/root.go
									
									
									
									
									
								
							@@ -42,6 +42,7 @@ dcmerge docker-compose.yml https://git.example.local/user/repo/docker-compose.ym
 | 
			
		||||
		RunE:    run,
 | 
			
		||||
		Version: version,
 | 
			
		||||
	}
 | 
			
		||||
	rootCmd.Flags().BoolP("existing-win", "f", false, "Protect existing attributes")
 | 
			
		||||
	rootCmd.Flags().BoolP("last-win", "l", false, "Overwrite existing attributes")
 | 
			
		||||
	rootCmd.Flags().StringP("output-file", "o", "", "Write instead on stdout into a file")
 | 
			
		||||
	rootCmd.AddCommand(completionCmd)
 | 
			
		||||
@@ -50,6 +51,11 @@ dcmerge docker-compose.yml https://git.example.local/user/repo/docker-compose.ym
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func run(cmd *cobra.Command, args []string) error {
 | 
			
		||||
	mergeExisting, err := cmd.Flags().GetBool("existing-win")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to parse flag last-win: %s", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	mergeLastWin, err := cmd.Flags().GetBool("last-win")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("Failed to parse flag last-win: %s", err)
 | 
			
		||||
@@ -69,12 +75,15 @@ func run(cmd *cobra.Command, args []string) error {
 | 
			
		||||
 | 
			
		||||
	for _, config := range dockerComposeConfigs {
 | 
			
		||||
		switch {
 | 
			
		||||
		case mergeLastWin:
 | 
			
		||||
		case mergeExisting && mergeLastWin:
 | 
			
		||||
			return fmt.Errorf("Neither --first-win or --last-win can be specified - not booth.")
 | 
			
		||||
		case mergeExisting && !mergeLastWin:
 | 
			
		||||
			dockerComposeConfig.MergeExistingWin(config)
 | 
			
		||||
		case !mergeExisting && mergeLastWin:
 | 
			
		||||
			dockerComposeConfig.MergeLastWin(config)
 | 
			
		||||
		default:
 | 
			
		||||
			dockerComposeConfig.Merge(config)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	switch {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							@@ -3,7 +3,7 @@ module git.cryptic.systems/volker.raschek/dcmerge
 | 
			
		||||
go 1.20
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	github.com/spf13/cobra v1.7.0
 | 
			
		||||
	github.com/spf13/cobra v1.8.0
 | 
			
		||||
	github.com/stretchr/testify v1.8.4
 | 
			
		||||
	gopkg.in/yaml.v2 v2.4.0
 | 
			
		||||
)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								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.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
 | 
			
		||||
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/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
 | 
			
		||||
@@ -6,8 +6,8 @@ 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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 | 
			
		||||
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.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
 | 
			
		||||
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
 | 
			
		||||
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
 | 
			
		||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
 | 
			
		||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
 | 
			
		||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
 | 
			
		||||
 
 | 
			
		||||
@@ -12,12 +12,6 @@ manifests:
 | 
			
		||||
    platform:
 | 
			
		||||
      architecture: amd64
 | 
			
		||||
      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
 | 
			
		||||
    platform:
 | 
			
		||||
 
 | 
			
		||||
@@ -91,6 +91,31 @@ func (c *Config) Merge(config *Config) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeLastWin merges a config and overwrite already existing properties
 | 
			
		||||
func (c *Config) MergeExistingWin(config *Config) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case c == nil && config == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case c != nil && config == nil:
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	// WARN: It's not possible to change the memory pointer c *Config
 | 
			
		||||
	// to a new initialized config without returning the Config
 | 
			
		||||
	// it self.
 | 
			
		||||
	//
 | 
			
		||||
	// case c == nil && config != nil:
 | 
			
		||||
	// 	c = NewConfig()
 | 
			
		||||
	// 	fallthrough
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		c.mergeExistingWinNetworks(config.Networks)
 | 
			
		||||
		c.mergeExistingWinSecrets(config.Secrets)
 | 
			
		||||
		c.mergeExistingWinServices(config.Services)
 | 
			
		||||
		c.mergeExistingWinVersion(config.Version)
 | 
			
		||||
		c.mergeExistingWinVolumes(config.Volumes)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeLastWin merges a config and overwrite already existing properties
 | 
			
		||||
func (c *Config) MergeLastWin(config *Config) {
 | 
			
		||||
	switch {
 | 
			
		||||
@@ -116,6 +141,68 @@ func (c *Config) MergeLastWin(config *Config) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Config) mergeExistingWinVersion(version string) {
 | 
			
		||||
	if len(c.Version) <= 0 {
 | 
			
		||||
		c.Version = version
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Config) mergeExistingWinNetworks(networks map[string]*Network) {
 | 
			
		||||
	for networkName, network := range networks {
 | 
			
		||||
		if network == nil {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if c.ExistsNetwork(networkName) {
 | 
			
		||||
			c.Networks[networkName].MergeExistingWin(network)
 | 
			
		||||
		} else {
 | 
			
		||||
			c.Networks[networkName] = network
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Config) mergeExistingWinSecrets(secrets map[string]*Secret) {
 | 
			
		||||
	for secretName, secret := range secrets {
 | 
			
		||||
		if secret == nil {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if c.ExistsNetwork(secretName) {
 | 
			
		||||
			c.Secrets[secretName].MergeExistingWin(secret)
 | 
			
		||||
		} else {
 | 
			
		||||
			c.Secrets[secretName] = secret
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Config) mergeExistingWinServices(services map[string]*Service) {
 | 
			
		||||
	for serviceName, service := range services {
 | 
			
		||||
		if service == nil {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if c.ExistsService(serviceName) {
 | 
			
		||||
			c.Services[serviceName].MergeExistingWin(service)
 | 
			
		||||
		} else {
 | 
			
		||||
			c.Services[serviceName] = service
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Config) mergeExistingWinVolumes(volumes map[string]*Volume) {
 | 
			
		||||
	for volumeName, volume := range volumes {
 | 
			
		||||
		if volume == nil {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if c.ExistsNetwork(volumeName) {
 | 
			
		||||
			c.Volumes[volumeName].MergeExistingWin(volume)
 | 
			
		||||
		} else {
 | 
			
		||||
			c.Volumes[volumeName] = volume
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Config) mergeLastWinVersion(version string) {
 | 
			
		||||
	if c.Version != version {
 | 
			
		||||
		c.Version = version
 | 
			
		||||
@@ -214,6 +301,26 @@ func (n *Network) Equal(equalable Equalable) bool {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (n *Network) MergeExistingWin(network *Network) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case n == nil && network == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case n != nil && network == nil:
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	// WARN: It's not possible to change the memory pointer n *Network
 | 
			
		||||
	// to a new initialized network without returning the Network
 | 
			
		||||
	// it self.
 | 
			
		||||
	//
 | 
			
		||||
	// case n == nil && network != nil:
 | 
			
		||||
	// 	c = NewCNetwork()
 | 
			
		||||
	// 	fallthrough
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		n.mergeExistingWinIPAM(network.IPAM)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (n *Network) MergeLastWin(network *Network) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case n == nil && network == nil:
 | 
			
		||||
@@ -234,6 +341,12 @@ func (n *Network) MergeLastWin(network *Network) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (n *Network) mergeExistingWinIPAM(networkIPAM *NetworkIPAM) {
 | 
			
		||||
	if !n.IPAM.Equal(networkIPAM) {
 | 
			
		||||
		n.IPAM.MergeExistingWin(networkIPAM)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (n *Network) mergeLastWinIPAM(networkIPAM *NetworkIPAM) {
 | 
			
		||||
	if !n.IPAM.Equal(networkIPAM) {
 | 
			
		||||
		n.IPAM.MergeLastWin(networkIPAM)
 | 
			
		||||
@@ -270,6 +383,26 @@ func (nIPAM *NetworkIPAM) Equal(equalable Equalable) bool {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (nIPAM *NetworkIPAM) MergeExistingWin(networkIPAM *NetworkIPAM) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case nIPAM == nil && networkIPAM == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case nIPAM != nil && networkIPAM == nil:
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	// WARN: It's not possible to change the memory pointer n *NetworkIPAM
 | 
			
		||||
	// to a new initialized networkIPAM without returning the NetworkIPAM
 | 
			
		||||
	// it self.
 | 
			
		||||
	//
 | 
			
		||||
	// case nIPAM == nil && networkIPAM != nil:
 | 
			
		||||
	// 	c = NewNetworkIPAM()
 | 
			
		||||
	// 	fallthrough
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		nIPAM.mergeExistingWinConfig(networkIPAM.Configs)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (nIPAM *NetworkIPAM) MergeLastWin(networkIPAM *NetworkIPAM) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case nIPAM == nil && networkIPAM == nil:
 | 
			
		||||
@@ -290,6 +423,14 @@ func (nIPAM *NetworkIPAM) MergeLastWin(networkIPAM *NetworkIPAM) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (nIPAM *NetworkIPAM) mergeExistingWinConfig(networkIPAMConfigs []*NetworkIPAMConfig) {
 | 
			
		||||
	for _, networkIPAMConfig := range networkIPAMConfigs {
 | 
			
		||||
		if !existsInSlice(nIPAM.Configs, networkIPAMConfig) {
 | 
			
		||||
			nIPAM.Configs = append(nIPAM.Configs, networkIPAMConfig)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (nIPAM *NetworkIPAM) mergeLastWinConfig(networkIPAMConfigs []*NetworkIPAMConfig) {
 | 
			
		||||
	for _, networkIPAMConfig := range networkIPAMConfigs {
 | 
			
		||||
		if !existsInSlice(nIPAM.Configs, networkIPAMConfig) {
 | 
			
		||||
@@ -354,6 +495,14 @@ func (s *Secret) Equal(equalable Equalable) bool {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeExistingWin merges adds or overwrite the attributes of the passed secret
 | 
			
		||||
// with the existing one.
 | 
			
		||||
func (s *Secret) MergeExistingWin(secret *Secret) {
 | 
			
		||||
	if len(s.File) <= 0 {
 | 
			
		||||
		s.File = secret.File
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeLastWin merges adds or overwrite the attributes of the passed secret
 | 
			
		||||
// with the existing one.
 | 
			
		||||
func (s *Secret) MergeLastWin(secret *Secret) {
 | 
			
		||||
@@ -381,6 +530,103 @@ type Service struct {
 | 
			
		||||
	Volumes          []string                   `json:"volumes,omitempty" yaml:"volumes,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ExistsEnvironment returns true if the passed name of environment variable is
 | 
			
		||||
// already present.
 | 
			
		||||
func (s *Service) ExistsEnvironment(name string) bool {
 | 
			
		||||
	for _, environment := range s.Environments {
 | 
			
		||||
		key, _ := splitStringInKeyValue(environment, environmentDelimiter)
 | 
			
		||||
		if key == name {
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ExistsLabel returns true if the passed label name is already present.
 | 
			
		||||
func (s *Service) ExistsLabel(name string) bool {
 | 
			
		||||
	for _, label := range s.Labels {
 | 
			
		||||
		key, _ := splitStringInKeyValue(label, labelDelimiter)
 | 
			
		||||
		if key == name {
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ExistsPort returns true if the port definition is already present.
 | 
			
		||||
func (s *Service) ExistsPort(src string, dest string, protocol string) bool {
 | 
			
		||||
	for _, port := range s.Ports {
 | 
			
		||||
		s, d, p := splitStringInPort(port)
 | 
			
		||||
		if s == src && d == dest && p == protocol {
 | 
			
		||||
			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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ExistsVolume returns true if the volume definition is already present.
 | 
			
		||||
func (s *Service) ExistsVolume(src string, dest string, perm string) bool {
 | 
			
		||||
	for _, volume := range s.Volumes {
 | 
			
		||||
		s, d, p := splitStringInVolume(volume)
 | 
			
		||||
		if s == src && d == dest && p == perm {
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ExistsDestinationVolume returns true if the volume definition is already present.
 | 
			
		||||
func (s *Service) ExistsDestinationVolume(dest string) bool {
 | 
			
		||||
	for _, volume := range s.Volumes {
 | 
			
		||||
		_, d, _ := splitStringInVolume(volume)
 | 
			
		||||
		if d == dest {
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ExistsSourceVolume returns true if the volume definition is already present.
 | 
			
		||||
func (s *Service) ExistsSourceVolume(src string) bool {
 | 
			
		||||
	for _, volume := range s.Volumes {
 | 
			
		||||
		s, _, _ := splitStringInVolume(volume)
 | 
			
		||||
		if s == src {
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Equal returns true if the passed equalable is equal
 | 
			
		||||
func (s *Service) Equal(equalable Equalable) bool {
 | 
			
		||||
	service, ok := equalable.(*Service)
 | 
			
		||||
@@ -411,6 +657,37 @@ func (s *Service) Equal(equalable Equalable) bool {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) MergeExistingWin(service *Service) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case s == nil && service == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case s != nil && service == nil:
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	// WARN: It's not possible to change the memory pointer s *Service
 | 
			
		||||
	// to a new initialized service without returning the Service
 | 
			
		||||
	// it self.
 | 
			
		||||
	//
 | 
			
		||||
	// case s == nil && service != nil:
 | 
			
		||||
	// 	s = NewService()
 | 
			
		||||
	// 	fallthrough
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		s.mergeExistingWinCapabilitiesAdd(service.CapabilitiesAdd)
 | 
			
		||||
		s.mergeExistingWinCapabilitiesDrop(service.CapabilitiesDrop)
 | 
			
		||||
		s.mergeExistingWinDeploy(service.Deploy)
 | 
			
		||||
		s.mergeExistingWinEnvironments(service.Environments)
 | 
			
		||||
		s.mergeExistingWinExtraHosts(service.ExtraHosts)
 | 
			
		||||
		s.mergeExistingWinImage(service.Image)
 | 
			
		||||
		s.mergeExistingWinLabels(service.Labels)
 | 
			
		||||
		s.mergeExistingWinNetworks(service.Networks)
 | 
			
		||||
		s.mergeExistingWinPorts(service.Ports)
 | 
			
		||||
		s.mergeExistingWinSecrets(service.Secrets)
 | 
			
		||||
		s.mergeExistingWinULimits(service.ULimits)
 | 
			
		||||
		s.mergeExistingWinVolumes(service.Volumes)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeLastWin merges adds or overwrite the attributes of the passed secret
 | 
			
		||||
// with the existing one.
 | 
			
		||||
func (s *Service) MergeLastWin(service *Service) {
 | 
			
		||||
@@ -444,8 +721,186 @@ func (s *Service) MergeLastWin(service *Service) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeExistingWinCapabilitiesAdd(capabilitiesAdd []string) {
 | 
			
		||||
	for _, capabilityAdd := range capabilitiesAdd {
 | 
			
		||||
		if !existsInSlice(s.CapabilitiesAdd, capabilityAdd) && len(capabilityAdd) > 0 {
 | 
			
		||||
			s.CapabilitiesAdd = append(s.CapabilitiesAdd, capabilityAdd)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeExistingWinCapabilitiesDrop(capabilitiesDrop []string) {
 | 
			
		||||
	for _, capabilityDrop := range capabilitiesDrop {
 | 
			
		||||
		if !existsInSlice(s.CapabilitiesAdd, capabilityDrop) && len(capabilityDrop) > 0 {
 | 
			
		||||
			s.CapabilitiesDrop = append(s.CapabilitiesDrop, capabilityDrop)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeExistingWinDeploy(deploy *ServiceDeploy) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case s.Deploy == nil && deploy != nil:
 | 
			
		||||
		s.Deploy = deploy
 | 
			
		||||
	case s.Deploy != nil && deploy == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case s.Deploy == nil && deploy == nil:
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		s.Deploy.MergeExistingWin(deploy)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeExistingWinEnvironments(environments []string) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case s.Environments == nil && environments != nil:
 | 
			
		||||
		s.Environments = environments
 | 
			
		||||
	case s.Environments != nil && environments == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case s.Environments == nil && environments == nil:
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		for _, environment := range environments {
 | 
			
		||||
			if len(environment) <= 0 {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			key, value := splitStringInKeyValue(environment, environmentDelimiter)
 | 
			
		||||
			if !s.ExistsEnvironment(key) {
 | 
			
		||||
				s.SetEnvironment(key, value)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeExistingWinImage(image string) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case len(s.Image) == 0 && len(image) != 0:
 | 
			
		||||
		s.Image = image
 | 
			
		||||
	case len(s.Image) != 0 && len(image) == 0:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case len(s.Image) == 0 && len(image) == 0:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	default:
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeExistingWinExtraHosts(extraHosts []string) {
 | 
			
		||||
	for _, extraHost := range extraHosts {
 | 
			
		||||
		if !existsInSlice(s.ExtraHosts, extraHost) && len(extraHost) > 0 {
 | 
			
		||||
			s.ExtraHosts = append(s.ExtraHosts, extraHost)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeExistingWinLabels(labels []string) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case s.Labels == nil && labels != nil:
 | 
			
		||||
		s.Labels = labels
 | 
			
		||||
	case s.Labels != nil && labels == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case s.Labels == nil && labels == nil:
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		for _, label := range labels {
 | 
			
		||||
			if len(label) <= 0 {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			key, value := splitStringInKeyValue(label, labelDelimiter)
 | 
			
		||||
			if !s.ExistsLabel(key) {
 | 
			
		||||
				s.SetLabel(key, value)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeExistingWinNetworks(networks map[string]*ServiceNetwork) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case s.Networks == nil && networks != nil:
 | 
			
		||||
		s.Networks = networks
 | 
			
		||||
	case s.Networks != nil && networks == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case s.Networks == nil && networks == nil:
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		for name, network := range networks {
 | 
			
		||||
			if _, exists := s.Networks[name]; exists {
 | 
			
		||||
				s.Networks[name].MergeExistingWin(network)
 | 
			
		||||
			} else {
 | 
			
		||||
				s.Networks[name] = network
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeExistingWinPorts(ports []string) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case s.Ports == nil && ports != nil:
 | 
			
		||||
		s.Ports = ports
 | 
			
		||||
	case s.Ports != nil && ports == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case s.Ports == nil && ports == nil:
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		for _, port := range ports {
 | 
			
		||||
			if len(port) <= 0 {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			src, dest, protocol := splitStringInPort(port)
 | 
			
		||||
			if !s.ExistsDestinationPort(dest) {
 | 
			
		||||
				s.SetPort(src, dest, protocol)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeExistingWinSecrets(secrets []string) {
 | 
			
		||||
	for _, secret := range secrets {
 | 
			
		||||
		if !existsInSlice(s.Secrets, secret) && len(secret) > 0 {
 | 
			
		||||
			s.Secrets = append(s.Secrets, secret)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeExistingWinULimits(uLimits *ServiceULimits) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case s.ULimits == nil && uLimits != nil:
 | 
			
		||||
		s.ULimits = uLimits
 | 
			
		||||
	case s.ULimits != nil && uLimits == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case s.ULimits == nil && uLimits == nil:
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		s.ULimits.MergeExistingWin(uLimits)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeExistingWinVolumes(volumes []string) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case s.Volumes == nil && volumes != nil:
 | 
			
		||||
		s.Volumes = volumes
 | 
			
		||||
	case s.Volumes != nil && volumes == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case s.Volumes == nil && volumes == nil:
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		for _, volume := range volumes {
 | 
			
		||||
			src, dest, perm := splitStringInVolume(volume)
 | 
			
		||||
			if !s.ExistsDestinationVolume(dest) {
 | 
			
		||||
				s.SetVolume(src, dest, perm)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeLastWinCapabilitiesAdd(capabilitiesAdd []string) {
 | 
			
		||||
	for _, capabilityAdd := range capabilitiesAdd {
 | 
			
		||||
		if len(capabilityAdd) <= 0 {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !existsInSlice(s.CapabilitiesAdd, capabilityAdd) {
 | 
			
		||||
			s.CapabilitiesAdd = append(s.CapabilitiesAdd, capabilityAdd)
 | 
			
		||||
		}
 | 
			
		||||
@@ -454,6 +909,10 @@ func (s *Service) mergeLastWinCapabilitiesAdd(capabilitiesAdd []string) {
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeLastWinCapabilitiesDrop(capabilitiesDrop []string) {
 | 
			
		||||
	for _, capabilityDrop := range capabilitiesDrop {
 | 
			
		||||
		if len(capabilityDrop) <= 0 {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !existsInSlice(s.CapabilitiesAdd, capabilityDrop) {
 | 
			
		||||
			s.CapabilitiesDrop = append(s.CapabilitiesDrop, capabilityDrop)
 | 
			
		||||
		}
 | 
			
		||||
@@ -483,6 +942,10 @@ func (s *Service) mergeLastWinEnvironments(environments []string) {
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		for _, environment := range environments {
 | 
			
		||||
			if len(environment) <= 0 {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			key, value := splitStringInKeyValue(environment, environmentDelimiter)
 | 
			
		||||
			s.SetEnvironment(key, value)
 | 
			
		||||
		}
 | 
			
		||||
@@ -506,6 +969,10 @@ func (s *Service) mergeLastWinImage(image string) {
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeLastWinExtraHosts(extraHosts []string) {
 | 
			
		||||
	for _, extraHost := range extraHosts {
 | 
			
		||||
		if len(extraHost) <= 0 {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !existsInSlice(s.ExtraHosts, extraHost) {
 | 
			
		||||
			s.ExtraHosts = append(s.ExtraHosts, extraHost)
 | 
			
		||||
		}
 | 
			
		||||
@@ -522,6 +989,10 @@ func (s *Service) mergeLastWinLabels(labels []string) {
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		for _, label := range labels {
 | 
			
		||||
			if len(label) <= 0 {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			key, value := splitStringInKeyValue(label, labelDelimiter)
 | 
			
		||||
			s.SetLabel(key, value)
 | 
			
		||||
		}
 | 
			
		||||
@@ -557,6 +1028,10 @@ func (s *Service) mergeLastWinPorts(ports []string) {
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		for _, port := range ports {
 | 
			
		||||
			if len(port) <= 0 {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			src, dest, protocol := splitStringInPort(port)
 | 
			
		||||
			s.SetPort(src, dest, protocol)
 | 
			
		||||
		}
 | 
			
		||||
@@ -565,6 +1040,10 @@ func (s *Service) mergeLastWinPorts(ports []string) {
 | 
			
		||||
 | 
			
		||||
func (s *Service) mergeLastWinSecrets(secrets []string) {
 | 
			
		||||
	for _, secret := range secrets {
 | 
			
		||||
		if len(secret) <= 0 {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if !existsInSlice(s.Secrets, secret) {
 | 
			
		||||
			s.Secrets = append(s.Secrets, secret)
 | 
			
		||||
		}
 | 
			
		||||
@@ -594,6 +1073,10 @@ func (s *Service) mergeLastWinVolumes(volumes []string) {
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		for _, volume := range volumes {
 | 
			
		||||
			if len(volume) <= 0 {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			src, dest, perm := splitStringInVolume(volume)
 | 
			
		||||
			s.SetVolume(src, dest, perm)
 | 
			
		||||
		}
 | 
			
		||||
@@ -732,6 +1215,28 @@ func (sd *ServiceDeploy) Equal(equalable Equalable) bool {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeExistingWin merges adds or overwrite the attributes of the passed
 | 
			
		||||
// serviceDeploy with the existing one.
 | 
			
		||||
func (sd *ServiceDeploy) MergeExistingWin(serviceDeploy *ServiceDeploy) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case sd == nil && serviceDeploy == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case sd != nil && serviceDeploy == nil:
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	// WARN: It's not possible to change the memory pointer sd *ServiceDeploy
 | 
			
		||||
	// to a new initialized serviceDeploy without returning the ServiceDeploy
 | 
			
		||||
	// it self.
 | 
			
		||||
	//
 | 
			
		||||
	// case sd == nil && serviceDeploy != nil:
 | 
			
		||||
	// 	sd = NewServiceDeploy()
 | 
			
		||||
	// 	fallthrough
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		sd.mergeExistingWinDeployResources(serviceDeploy.Resources)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeLastWin merges adds or overwrite the attributes of the passed
 | 
			
		||||
// serviceDeploy with the existing one.
 | 
			
		||||
func (sd *ServiceDeploy) MergeLastWin(serviceDeploy *ServiceDeploy) {
 | 
			
		||||
@@ -754,6 +1259,19 @@ func (sd *ServiceDeploy) MergeLastWin(serviceDeploy *ServiceDeploy) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sd *ServiceDeploy) mergeExistingWinDeployResources(resources *ServiceDeployResources) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case sd.Resources == nil && resources != nil:
 | 
			
		||||
		sd.Resources = resources
 | 
			
		||||
	case sd.Resources != nil && resources == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case sd.Resources == nil && resources == nil:
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		sd.Resources.MergeExistingWin(resources)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sd *ServiceDeploy) mergeLastWinDeployResources(resources *ServiceDeployResources) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case sd.Resources == nil && resources != nil:
 | 
			
		||||
@@ -798,6 +1316,27 @@ func (sdr *ServiceDeployResources) Equal(equalable Equalable) bool {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeExistingWin adds only attributes of the passed serviceDeployResources if
 | 
			
		||||
// they are not already exists.
 | 
			
		||||
func (sdr *ServiceDeployResources) MergeExistingWin(serviceDeployResources *ServiceDeployResources) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case sdr == nil && serviceDeployResources == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case sdr != nil && serviceDeployResources == nil:
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	// WARN: It's not possible to change the memory pointer sdr *ServiceDeployResources
 | 
			
		||||
	// to a new initialized serviceDeployResources without returning the
 | 
			
		||||
	// serviceDeployResources it self.
 | 
			
		||||
	case sdr == nil && serviceDeployResources != nil:
 | 
			
		||||
		sdr = NewServiceDeployResources()
 | 
			
		||||
		fallthrough
 | 
			
		||||
	default:
 | 
			
		||||
		sdr.mergeExistingWinLimits(serviceDeployResources.Limits)
 | 
			
		||||
		sdr.mergeExistingWinReservations(serviceDeployResources.Reservations)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeLastWin merges adds or overwrite the attributes of the passed
 | 
			
		||||
// serviceDeployResources with the existing one.
 | 
			
		||||
func (sdr *ServiceDeployResources) MergeLastWin(serviceDeployResources *ServiceDeployResources) {
 | 
			
		||||
@@ -819,6 +1358,32 @@ func (sdr *ServiceDeployResources) MergeLastWin(serviceDeployResources *ServiceD
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sdr *ServiceDeployResources) mergeExistingWinLimits(limits *ServiceDeployResourcesLimits) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case sdr.Limits == nil && limits != nil:
 | 
			
		||||
		sdr.Limits = limits
 | 
			
		||||
	case sdr.Limits != nil && limits == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case sdr.Limits == nil && limits == nil:
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		sdr.Limits.MergeExistingWin(limits)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sdr *ServiceDeployResources) mergeExistingWinReservations(reservations *ServiceDeployResourcesLimits) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case sdr.Reservations == nil && reservations != nil:
 | 
			
		||||
		sdr.Reservations = reservations
 | 
			
		||||
	case sdr.Reservations != nil && reservations == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case sdr.Reservations == nil && reservations == nil:
 | 
			
		||||
		return
 | 
			
		||||
	default:
 | 
			
		||||
		sdr.Reservations.MergeExistingWin(reservations)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sdr *ServiceDeployResources) mergeLastWinLimits(limits *ServiceDeployResourcesLimits) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case sdr.Limits == nil && limits != nil:
 | 
			
		||||
@@ -877,6 +1442,29 @@ func (sdrl *ServiceDeployResourcesLimits) Equal(equalable Equalable) bool {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeExistingWin adds only attributes of the passed serviceDeployResourcesLimits
 | 
			
		||||
// if they are not already exists.
 | 
			
		||||
func (sdrl *ServiceDeployResourcesLimits) MergeExistingWin(serviceDeployResourcesLimits *ServiceDeployResourcesLimits) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case sdrl == nil && serviceDeployResourcesLimits == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case sdrl != nil && serviceDeployResourcesLimits == nil:
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	// WARN: It's not possible to change the memory pointer sdrl *ServiceDeployResourcesLimits
 | 
			
		||||
	// to a new initialized serviceDeployResourcesLimits without returning the
 | 
			
		||||
	// serviceDeployResourcesLimits it self.
 | 
			
		||||
	//
 | 
			
		||||
	// case sdrl == nil && serviceDeployResourcesLimits != nil:
 | 
			
		||||
	// 	sdrl = NewServiceDeployResourcesLimits()
 | 
			
		||||
	// 	fallthrough
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		sdrl.mergeExistingWinCPUs(serviceDeployResourcesLimits.CPUs)
 | 
			
		||||
		sdrl.mergeExistingWinMemory(serviceDeployResourcesLimits.Memory)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeLastWin merges adds or overwrite the attributes of the passed
 | 
			
		||||
// serviceDeployResourcesLimits with the existing one.
 | 
			
		||||
func (sdrl *ServiceDeployResourcesLimits) MergeLastWin(serviceDeployResourcesLimits *ServiceDeployResourcesLimits) {
 | 
			
		||||
@@ -900,6 +1488,18 @@ func (sdrl *ServiceDeployResourcesLimits) MergeLastWin(serviceDeployResourcesLim
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sdrl *ServiceDeployResourcesLimits) mergeExistingWinCPUs(cpus string) {
 | 
			
		||||
	if len(sdrl.CPUs) <= 0 {
 | 
			
		||||
		sdrl.CPUs = cpus
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sdrl *ServiceDeployResourcesLimits) mergeExistingWinMemory(memory string) {
 | 
			
		||||
	if len(sdrl.Memory) <= 0 {
 | 
			
		||||
		sdrl.Memory = memory
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sdrl *ServiceDeployResourcesLimits) mergeLastWinCPUs(cpus string) {
 | 
			
		||||
	if sdrl.CPUs != cpus {
 | 
			
		||||
		sdrl.CPUs = cpus
 | 
			
		||||
@@ -939,6 +1539,30 @@ func (sn *ServiceNetwork) Equal(equalable Equalable) bool {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeExistingWin adds only attributes of the passed
 | 
			
		||||
// serviceNetwork if they are undefined.
 | 
			
		||||
func (sn *ServiceNetwork) MergeExistingWin(serviceNetwork *ServiceNetwork) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case sn == nil && serviceNetwork == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case sn != nil && serviceNetwork == nil:
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	// WARN: It's not possible to change the memory pointer sn *ServiceNetwork to a new
 | 
			
		||||
	// initialized ServiceNetwork without returning the serviceNetwork it self.
 | 
			
		||||
	//
 | 
			
		||||
	// case l == nil && serviceULimits != nil:
 | 
			
		||||
	// 	l = NewServiceULimits()
 | 
			
		||||
	// 	fallthrough
 | 
			
		||||
 | 
			
		||||
	case sn == nil && serviceNetwork != nil:
 | 
			
		||||
		sn = NewServiceNetwork()
 | 
			
		||||
		fallthrough
 | 
			
		||||
	default:
 | 
			
		||||
		sn.mergeExistingWinAliases(serviceNetwork.Aliases)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeLastWin merges adds or overwrite the attributes of the passed
 | 
			
		||||
// serviceNetwork with the existing one.
 | 
			
		||||
func (sn *ServiceNetwork) MergeLastWin(serviceNetwork *ServiceNetwork) {
 | 
			
		||||
@@ -963,9 +1587,17 @@ func (sn *ServiceNetwork) MergeLastWin(serviceNetwork *ServiceNetwork) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sn *ServiceNetwork) mergeExistingWinAliases(aliases []string) {
 | 
			
		||||
	for _, alias := range aliases {
 | 
			
		||||
		if !existsInSlice(sn.Aliases, alias) && len(alias) > 0 {
 | 
			
		||||
			sn.Aliases = append(sn.Aliases, alias)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (sn *ServiceNetwork) mergeLastWinAliases(aliases []string) {
 | 
			
		||||
	for _, alias := range aliases {
 | 
			
		||||
		if !existsInSlice(sn.Aliases, alias) {
 | 
			
		||||
		if !existsInSlice(sn.Aliases, alias) && len(alias) > 0 {
 | 
			
		||||
			sn.Aliases = append(sn.Aliases, alias)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -1002,6 +1634,28 @@ func (l *ServiceULimits) Equal(equalable Equalable) bool {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeExistingWin adds only the attributes of the passed ServiceULimits they are
 | 
			
		||||
// undefined.
 | 
			
		||||
func (l *ServiceULimits) MergeExistingWin(serviceULimits *ServiceULimits) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case l == nil && serviceULimits == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case l != nil && serviceULimits == nil:
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	// WARN: It's not possible to change the memory pointer l *ServiceULimits to a new
 | 
			
		||||
	// initialized ServiceULimits without returning the serviceULimits it self.
 | 
			
		||||
	//
 | 
			
		||||
	// case l == nil && serviceULimits != nil:
 | 
			
		||||
	// 	l = NewServiceULimits()
 | 
			
		||||
	// 	fallthrough
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		l.mergeExistingWinNProc(serviceULimits.NProc)
 | 
			
		||||
		l.mergeExistingWinNoFile(serviceULimits.NoFile)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeLastWin merges adds or overwrite the attributes of the passed
 | 
			
		||||
// ServiceULimits with the existing one.
 | 
			
		||||
func (l *ServiceULimits) MergeLastWin(serviceULimits *ServiceULimits) {
 | 
			
		||||
@@ -1024,6 +1678,19 @@ func (l *ServiceULimits) MergeLastWin(serviceULimits *ServiceULimits) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (l *ServiceULimits) mergeExistingWinNProc(nproc uint) {
 | 
			
		||||
	if l.NProc != nproc {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	l.NProc = nproc
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (l *ServiceULimits) mergeExistingWinNoFile(noFile *ServiceULimitsNoFile) {
 | 
			
		||||
	if !l.NoFile.Equal(noFile) {
 | 
			
		||||
		l.NoFile.MergeExistingWin(noFile)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (l *ServiceULimits) mergeLastWinNProc(nproc uint) {
 | 
			
		||||
	if l.NProc != nproc {
 | 
			
		||||
		l.NProc = nproc
 | 
			
		||||
@@ -1067,8 +1734,31 @@ func (nf *ServiceULimitsNoFile) Equal(equalable Equalable) bool {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeExistingWin adds only the attributes of the passed ServiceULimits they are
 | 
			
		||||
// undefined.
 | 
			
		||||
func (nf *ServiceULimitsNoFile) MergeExistingWin(serviceULimitsNoFile *ServiceULimitsNoFile) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case nf == nil && serviceULimitsNoFile == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case nf != nil && serviceULimitsNoFile == nil:
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	// WARN: It's not possible to change the memory pointer nf *ServiceULimitsNoFile
 | 
			
		||||
	// to a new initialized ServiceULimitsNoFile without returning the serviceULimitsNoFile
 | 
			
		||||
	// it self.
 | 
			
		||||
	//
 | 
			
		||||
	// case nf == nil && serviceULimitsNoFile != nil:
 | 
			
		||||
	// 	nf = NewServiceULimitsNoFile()
 | 
			
		||||
	// 	fallthrough
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		nf.mergeExistingWinHard(serviceULimitsNoFile.Hard)
 | 
			
		||||
		nf.mergeExistingWinSoft(serviceULimitsNoFile.Soft)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeLastWin merges adds or overwrite the attributes of the passed
 | 
			
		||||
// ServiceULimits with the existing one.
 | 
			
		||||
// ServiceULimitsNoFile with the existing one.
 | 
			
		||||
func (nf *ServiceULimitsNoFile) MergeLastWin(serviceULimitsNoFile *ServiceULimitsNoFile) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case nf == nil && serviceULimitsNoFile == nil:
 | 
			
		||||
@@ -1090,6 +1780,20 @@ func (nf *ServiceULimitsNoFile) MergeLastWin(serviceULimitsNoFile *ServiceULimit
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (nf *ServiceULimitsNoFile) mergeExistingWinHard(hard uint) {
 | 
			
		||||
	if nf.Hard != hard {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	nf.Hard = hard
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (nf *ServiceULimitsNoFile) mergeExistingWinSoft(soft uint) {
 | 
			
		||||
	if nf.Soft != soft {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	nf.Soft = soft
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (nf *ServiceULimitsNoFile) mergeLastWinHard(hard uint) {
 | 
			
		||||
	if nf.Hard != hard {
 | 
			
		||||
		nf.Hard = hard
 | 
			
		||||
@@ -1129,6 +1833,27 @@ func (v *Volume) Equal(equalable Equalable) bool {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MergeExistingWin adds only the attributes of the passed Volume they are
 | 
			
		||||
// undefined.
 | 
			
		||||
func (v *Volume) MergeExistingWin(volume *Volume) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case v == nil && volume == nil:
 | 
			
		||||
		fallthrough
 | 
			
		||||
	case v != nil && volume == nil:
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	// WARN: It's not possible to change the memory pointer v *Volume to a new
 | 
			
		||||
	// initialized Volume without returning the volume it self.
 | 
			
		||||
	//
 | 
			
		||||
	// case v == nil && volume != nil:
 | 
			
		||||
	// 	v = NewVolume()
 | 
			
		||||
	// 	fallthrough
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		v.mergeExistingWinExternal(volume.External)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v *Volume) MergeLastWin(volume *Volume) {
 | 
			
		||||
	switch {
 | 
			
		||||
	case v == nil && volume == nil:
 | 
			
		||||
@@ -1148,6 +1873,13 @@ func (v *Volume) MergeLastWin(volume *Volume) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v *Volume) mergeExistingWinExternal(external bool) {
 | 
			
		||||
	if v.External {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	v.External = true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v *Volume) mergeLastWinExternal(external bool) {
 | 
			
		||||
	if v.External != external {
 | 
			
		||||
		v.External = external
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										10
									
								
								test/assets/docker-compose-a.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								test/assets/docker-compose-a.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
version: "3.3"
 | 
			
		||||
services:
 | 
			
		||||
  app:
 | 
			
		||||
    environment:
 | 
			
		||||
    - HTTP_PROXY=1.2.3.4:8080
 | 
			
		||||
    image: repository:version
 | 
			
		||||
    ports:
 | 
			
		||||
    - 8080:80
 | 
			
		||||
    volumes:
 | 
			
		||||
    - /etc/localtime:/etc/localtime
 | 
			
		||||
							
								
								
									
										10
									
								
								test/assets/docker-compose-b.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								test/assets/docker-compose-b.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
version: "3.3"
 | 
			
		||||
services:
 | 
			
		||||
  app:
 | 
			
		||||
    environment:
 | 
			
		||||
    - HTTP_PROXY=4.3.2.1:8080
 | 
			
		||||
    image: repository:version
 | 
			
		||||
    ports:
 | 
			
		||||
    - 10080:80
 | 
			
		||||
    volumes:
 | 
			
		||||
    - /usr/share/zoneinfo/UTC:/etc/localtime
 | 
			
		||||
		Reference in New Issue
	
	Block a user