diff --git a/README.md b/README.md index 05cf1a7..aa823be 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ Simple tool to create a list of docker tags from a given version string. DOCKER_AUTOTAG_OUTPUT_FILE= # adds a given suffix to every determined tag DOCKER_AUTOTAG_SUFFIX= +# returns only tags with the applied suffix +DOCKER_AUTOTAG_SUFFIX_STRICT=False # version string to use; returns 'latest' if nothing is specified DOCKER_AUTOTAG_VERSION= # comma-seprated list of static tags to add to the result set @@ -59,6 +61,9 @@ DOCKER_AUTOTAG_IGNORE_PRERELEASE=True DOCKER_AUTOTAG_VERSION=1.0.0-beta docker-a DOCKER_AUTOTAG_SUFFIX=amd64 DOCKER_AUTOTAG_VERSION=1.0.0 docker-autotag # 1.0.0,1.0,1,1.0.0-amd64,1.0-amd64,1-amd64 +DOCKER_AUTOTAG_SUFFIX=amd64 DOCKER_AUTOTAG_SUFFIX_STRICT=True DOCKER_AUTOTAG_VERSION=1.0.0 docker-autotag +# 1.0.0-amd64,1.0-amd64,1-amd64 + DOCKER_AUTOTAG_EXTRA_TAGS=extra1,extra2 DOCKER_AUTOTAG_VERSION=1.0.0 docker-autotag # 1.0.0,1.0,1,extra1,extra2 ``` diff --git a/dockerautotag/cli.py b/dockerautotag/cli.py index 1b59d45..36d39c7 100644 --- a/dockerautotag/cli.py +++ b/dockerautotag/cli.py @@ -42,6 +42,7 @@ class Autotag: config["file"] = normalize_path(output_raw) config["suffix"] = os.environ.get("DOCKER_AUTOTAG_SUFFIX", None) + config["suffix_strict"] = to_bool(os.environ.get("DOCKER_AUTOTAG_SUFFIX_STRICT", False)) config["version"] = os.environ.get("DOCKER_AUTOTAG_VERSION", None) config["extra"] = os.environ.get("DOCKER_AUTOTAG_EXTRA_TAGS", None) config["force_latest"] = to_bool(os.environ.get("DOCKER_AUTOTAG_FORCE_LATEST", False)) @@ -58,11 +59,14 @@ class Autotag: return tags + e @staticmethod - def _tag_suffix(tags, suffix): + def _tag_suffix(tags, suffix, suffix_strict): if not suffix: return tags - res = copy.deepcopy(tags) + res = [] + if not suffix_strict: + res = copy.deepcopy(tags) + for t in tags: if t == "latest": res.append(suffix) @@ -116,7 +120,7 @@ class Autotag: config = self.config v = self._default_tags(config["version"], config["ignore_pre"], config["force_latest"]) - v = self._tag_suffix(v, config["suffix"]) + v = self._tag_suffix(v, config["suffix"], config["suffix_strict"]) v = self._tag_extra(v, config["extra"]) if config["file"]: