argocd-image-updater icon indicating copy to clipboard operation
argocd-image-updater copied to clipboard

Feature request: Avoid full file reformatting during updates

Open willbush opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

When using:

metadata:
  annotations:
    argocd-image-updater.argoproj.io/image-list: xyz=<image-tag>
    argocd-image-updater.argoproj.io/xyz.update-strategy: digest
    argocd-image-updater.argoproj.io/write-back-method: git
    argocd-image-updater.argoproj.io/write-back-target: kustomization:<path>

An update triggers argocd-image-updater to update a kustomize file with a new digest, it also reformats the entire file. The format style it uses is different from that of yamlfmt and prettier, which causes unnecessary changes in git.

I'm guessing the reformat is done to avoid having to infer how many spaces are needed for indentation.

Describe the solution you'd like

Infer how many spaces are needed for indentation so reformatting the whole file is not needed.

Or only reformat when digest does not exists, and then when it already exists, update it in place without reformating:

# ...
images:
  - name: <image-name>
    digest: sha256:<hash>

Describe alternatives you've considered

We are using treefmt to run a bunch of formatters on code and check style in CI. I might have to manually have it ignore certain kustomize files that have digests that are updated by argocd-image-updater to avoid CI warnings, and let the style be inconsistent.

willbush avatar Jul 30 '24 03:07 willbush