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

Get the values of a mapping node #409

Closed
pantelis-karamolegkos opened this issue Nov 23, 2023 · 1 comment
Closed

Get the values of a mapping node #409

pantelis-karamolegkos opened this issue Nov 23, 2023 · 1 comment

Comments

@pantelis-karamolegkos
Copy link

pantelis-karamolegkos commented Nov 23, 2023

Is your feature request related to a problem? Please describe.
I want to be able to get the values of a (say mapping) node, including comments.

Describe the solution you'd like
Let's say for example we have the following yaml

apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: myapp
  namespace: default
spec:
  chart:
    spec:
      # THIS IS A COMMENT
      chart: charts/myapp
      reconcileStrategy: Revision
      sourceRef:
        kind: GitRepository
        name: my-branch
        namespace: systems

I want to be able to do something like the following:

(assume file is an *os.File with the above contents)

path, err := yaml.PathString("$.spec.chart")
node, err := path.ReadNode(file)
contents := node.GetContents() // or node.GetChildren() or whatever
fmt.Println(contents)

result

      # THIS IS A COMMENT
      chart: charts/myapp
      reconcileStrategy: Revision
      sourceRef:
        kind: GitRepository
        name: my-branch
        namespace: systems

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@goccy
Copy link
Owner

goccy commented Dec 10, 2024

@pantelis-karamolegkos This is already possible. Please refer to this issue.

#574

@goccy goccy closed this as completed Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants