fluxcd / image-automation-controller

GitOps Toolkit controller that patches container image tags in Git
https://fluxcd.io
Apache License 2.0
172 stars 71 forks source link

blank lines removed from kustomization.yaml after image update #117

Open dan-slinky-ckpd opened 3 years ago

dan-slinky-ckpd commented 3 years ago

Describe the bug

Blank lines are removed from my kustomization.yaml after an image update. In large kustomizations it useful to seperate sections for readability.

To Reproduce

Start with a kustomization.yaml like so:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: production-my-app

namePrefix: production-

commonLabels:
  overlay: production

resources:
- namespace.yaml
- ../base

images:
- name: ghcr.io/stefanprodan/podinfo
  newTag: 5.0.0 # {"$imagepolicy": "flux-system:my-app-production:tag"}

After an image update, the blank lines are removed :(

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: production-my-app
namePrefix: production-
commonLabels:
  overlay: production
resources:
- namespace.yaml
- ../base
images:
- name: ghcr.io/stefanprodan/podinfo
  newTag: 5.1.4 # {"$imagepolicy": "flux-system:my-app-production:tag"}

Expected behavior

Maintain the blank lines.

Additional context

flux version 0.9.0

stefanprodan commented 3 years ago

Please see https://github.com/kubernetes-sigs/kustomize/issues/3559

cpressland commented 1 year ago

@stefanprodan given the upstream bug on this is now resolved is any work on this planned? We're trying to enforce linters in our gitops repos and many code formatters like yamlfmt and yamlfix all prefer indenting lists with an additional two spaces. To be clear I'm happy with either convention, I just can't configure flux or the linters to a single convention - configurability is never a bad thing. Heres what happens in our repos after linting, and then a new image gets commited by flux.

before:

  images:
    - name: myrepo.azurecr.io/myproject
      newName: myrepo.azurecr.io/myproject
      newTag: prod-2.2.2 # {"$imagepolicy": "flux-system:myproject:tag"}

after:

  images:
  - name: myrepo.azurecr.io/myproject
    newName: myrepo.azurecr.io/myproject
    newTag: prod-2.2.2 # {"$imagepolicy": "flux-system:myproject:tag"}
rossigee commented 1 month ago

This is still happening and is very annoying. Any updates?

Can we at least remove the 'blocked/upstream' tag?