Problem
Consider the following template:
version: '3.3'
services:
swarm-sync:
image: nginx:{{ nginx_tag }}
deploy:
labels:
- "swarm-sync.managed=true"
- "swarm-sync.image-pattern={{ nginx_tag_pattern }}"
We want the following:
-
swarm-pack can deploy it manually, and fill the value for nginx_tag (nginx_tag_pattern could be optional) from static values
-
swarm-sync can deploy it using swarm-pack, it could get the value of nginx_tag using the pattern to get the lastest tag
-
swarm-sync should be able to keep the image up to date later using the pattern (for now, it is in the label swarm-sync.image-pattern)
Using the current strategy, we define the stack file like this:
packs:
- pack: nginx
values:
my_value: foo
nginx_tag_pattern: 1.4.*
autovalues:
nginx_tag:
type: image_tag_pattern
image: nginx
tag_pattern: 1.4.*
(n.b. autovalues represents types of values which can be created automatically based on the type and other values. In this case it is image_tag_pattern type which means it will hit docker registry for the latest value.
Problem: tag_pattern: 1.4.* & nginx_tag_pattern: 1.4.* are duplicates, and could be a problem when we change it we must remember to change it in both places.
For reference, this is an example Flux config which defines similar scenario: