image-automation-controller icon indicating copy to clipboard operation
image-automation-controller copied to clipboard

blank lines removed from kustomization.yaml after image update

Open dan-slinky-ckpd opened this issue 3 years ago • 2 comments

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

dan-slinky-ckpd avatar Feb 26 '21 19:02 dan-slinky-ckpd

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

stefanprodan avatar Feb 26 '21 22:02 stefanprodan

@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"}

cpressland avatar Oct 18 '22 21:10 cpressland