Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yq head_comment strange behavior #2300

Open
kristeey opened this issue Feb 25, 2025 · 0 comments
Open

yq head_comment strange behavior #2300

kristeey opened this issue Feb 25, 2025 · 0 comments
Labels

Comments

@kristeey
Copy link

kristeey commented Feb 25, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant