argoproj-labs / argocd-image-updater

Automatic container image update for Argo CD
https://argocd-image-updater.readthedocs.io/en/stable/
Apache License 2.0
1.21k stars 253 forks source link

Parsing semantic versions from tags with prefixes #381

Open 0m1xa opened 2 years ago

0m1xa commented 2 years ago

Is your feature request related to a problem? Please describe. It would be great to have a possibility to parse prefixes from tags with semantic versioning. There was a similar issue with semantic versioning with suffixes. But in my case the solution doesn't work. In my repo there are several tags with names like someenv-<semver>

m1xa/nginx:someenv-1.15
m1xa/nginx:someenv-1.15.2
m1xa/nginx:someenv-1.16

I run argocd-image-updater and it can't detect tag with semver. argocd-image-updater test --update-strategy semver --kubeconfig ~/.kube/config --registries-conf ~/argocd-image-updater.conf --semver-constraint 0-1.x.x --allow-tags 'regexp:^someenv-.*$' m1xa/nginx

DEBU[0000] Creating Kubernetes client from /home/m1xa/.kube/config 
INFO[0000] getting image                                 image_name=m1xa/nginx registry=
DEBU[0000] rate limiting is disabled                     prefix= registry="https://registry-1.docker.io"
DEBU[0000] rate limiting is disabled                     prefix=nexus-docker.local registry="https://nexus-docker.local"
INFO[0000] Loaded 2 registry configurations from /home/m1xa/argocd-image-updater.conf 
INFO[0000] Fetching available tags and metadata from registry  image_name=m1xa/nginx
INFO[0001] Found 3 tags in registry                      image_name=m1xa/nginx
DEBU[0001] could not parse input tag someenv-1.15 as semver: Invalid Semantic Version 
DEBU[0001] could not parse input tag someenv-1.15.2 as semver: Invalid Semantic Version 
DEBU[0001] could not parse input tag someenv-1.16 as semver: Invalid Semantic Version 
INFO[0001] no newer version of image found  

Describe the solution you'd like A way to configure image updater parser with prefixes in semantic versioning

Describe alternatives you've considered I can use the latest mechanism at that moment.

Additional context

argocd-image-updater: v0.11.3+f62b7d7
  BuildDate: 2022-02-15T10:33:30Z
  GitCommit: f62b7d7841a42030fe4c75de1951c46b0e7fca2e
  GoVersion: go1.16.13
  GoCompiler: gc
  Platform: linux/amd64
jannfis commented 2 years ago

The case with semantic versioning with certain suffixes is a different one: these strings are a valid semantic version. With prefixes, that's not the case, since the semver spec does not allow prefixes.

0m1xa commented 2 years ago

Ok. Maybe it is possible to use substitution or substitution with regex in that case? And after substitution check the semver version.

curtiscook commented 2 years ago

I came here to ask the same question.

I'm planning on namespacing my semver tags to make monorepo management easier. Prefixes are much more clear than postfixes for sorting releases

With prefixes, that's not the case, since the semver spec does not allow prefixes.

I hear you, but would argue that a prefix is effectively a namespace and not part of the semver, which is still valid

jannfis commented 2 years ago

There is a draft PR which supposedly will implement this: #413