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

Nested anchors of mappings do not retain order #2189

Open
fresh2dev opened this issue Nov 8, 2024 · 0 comments
Open

Nested anchors of mappings do not retain order #2189

fresh2dev opened this issue Nov 8, 2024 · 0 comments
Labels

Comments

@fresh2dev
Copy link

Describe the bug

Nested anchors of mappings do not retain order.

Version of yq: 4.44.3
Operating system: mac
Installed via: binary release

Input Yaml
data1.yml:

.global-config: &global-config
  first: foo
  second: bar
  third: baz

.local-config: &local-config
  <<: *global-config
  first: FOO

final-config:
  <<: *local-config

Command
The command you ran:

yq 'explode(.)' data1.yml

Actual behavior

---
.global-config:
  first: foo
  second: bar
  third: baz
.local-config:
  second: bar
  third: baz
  first: FOO
final-config:
  second: bar
  third: baz
  first: FOO

Expected behavior

---
.global-config:
  first: foo
  second: bar
  third: baz
.local-config:
  first: FOO
  second: bar
  third: baz
final-config:
  first: FOO
  second: bar
  third: baz

Additional context
I tested with Helm using a values.yaml, Python's pyyaml, the Python yq, and each of them do retain order of nested anchors. E.g.,

spec:
  template:
    metadata:
      labels:
        app.kubernetes.io/managed-by: Helm
        first: FOO
        second: bar
        third: baz
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