estahn / k8s-image-swapper

Mirror images into your own registry and swap image references automatically.
https://estahn.github.io/k8s-image-swapper/
MIT License
540 stars 44 forks source link

Does not correctly tag digest pinned container image #836

Open jetersen opened 2 days ago

jetersen commented 2 days ago

Given image using tag with digest pinned it does not correct upload the image with tag v2.13.0 and gets deleted by untagged images policy :sweat_smile:

argo-cd:
  global:
    image:
      repository: quay.io/argoproj/argocd
      tag: v2.13.0@sha256:5806aac0c6e4d04aeeb385a218cfeaeb4daaab9bfbc2b41f908788eb5b3d2909
jetersen commented 2 days ago

This method should properly return normalizedName, tag, digest and than if tag and digest is not nil. Tag the digest after having copied it :thinking:

https://github.com/estahn/k8s-image-swapper/blob/72a2a044215ce81bba9799ae291930452589e16c/pkg/webhook/image_swapper.go#L150-L165