Open
Description
Describe the bug
head_comment
operator does fetch the head comment for one document, but not for another document which is basically configured in the same manner.
Version of yq: 4.45.1
Operating system: mac
Installed via:
- Homebrew (mac)
Input Yamls
Document 1:
data1.yaml:
# flux-tenant-name: flux-tenant1-sync
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- app1.yaml
Document 2:
data2.yaml:
# flux-tenant-name: flux-tenant2-sync
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- app2.yaml
Command
The command you ran:
yq 'head_comment' "data1.yaml"
yq 'head_comment' "data2.yaml"
Actual behavior
flux-tenant-name: flux-tenant1-sync
Expected behavior
flux-tenant-name: flux-tenant1-sync
flux-tenant-name: flux-tenant2-sync
Additional context
I first experienced this on a Linux runner using the same version of YQ mentioned above. I found a workaround using yq '... | headComment | select(. != "")' "data2.yaml"
which provides the correct result.