Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Merge array doens' work well. Replace always first position #796

Closed
richard24se opened this issue Apr 28, 2021 · 1 comment
Closed

Merge array doens' work well. Replace always first position #796

richard24se opened this issue Apr 28, 2021 · 1 comment
Labels

Comments

@richard24se
Copy link

Describe the bug
A clear and concise description of what the bug is.

Note that any how to questions should be posted in the discussion board and not raised as an issue.

Version of yq: 4.7.1
Operating system: linux
Installed via: binary

Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
s1.yml:

rules:
  - host: hooks.pe
    http:
      paths:
      - backend:
          serviceName: tes1
          servicePort: 5005
        pathType: ImplementationSpecific
  - host: hooks.pe2
    http:
      paths:
      - backend:
          serviceName: test2
          servicePort: 50052
        pathType: ImplementationSpecific
rules2:
  - host: hooks.pe2
    http:
      paths:
      - backend:
          serviceName: tes1
          servicePort: 5010
        pathType: ImplementationSpecific

Command
The command you ran:

yq eval '.rules *d .rules2' s1.yml

Actual behavior

- host: hooks.pe2
  http:
    paths:
      - backend:
          serviceName: tes1
          servicePort: 5010
        pathType: ImplementationSpecific
- host: hooks.pe2
  http:
    paths:
      - backend:
          serviceName: test2
          servicePort: 50052
        pathType: ImplementationSpecific

Expected behavior

- host: hooks.pe
  http:
    paths:
      - backend:
          serviceName: test1
          servicePort: 5005
        pathType: ImplementationSpecific
- host: hooks.pe2
  http:
    paths:
      - backend:
          serviceName: test1
          servicePort: 5010
        pathType: ImplementationSpecific

Additional context

@mikefarah
Copy link
Owner

That's how merge with the deep flag is supposed to work. You have two arrays, each containing objects - it merges the objects deeply in the matching indices.

Note: there is no way for yq to know the schema of the objects being merged, and further that the 'host' key on the objects are keys that should be matched.

Repository owner locked and limited conversation to collaborators Apr 28, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

2 participants