Skip to content

Follow alias nodes #52

@sergeyrud-stripe

Description

@sergeyrud-stripe

Is your feature request related to a problem? Please describe.

Is it possible to opt in to following aliases when looking for nodes? For instance, if I have the following path $.production.foo and YAML structure

default: &default
  foo: bar

production:
  <<: *default

I’d like to get the bar node without changing the path from $.production.foo to $.default.foo.

Describe the solution you'd like

API could possibly be as follows:

const data = `
default: &default
  foo: bar

production:
  <<: *default
`
var node yaml.Node
yaml.Unmarshal([]byte(data), &node)
p, _ := yamlpath.NewPath("$.production.foo")
p.FollowAliases(true) // new func that toggles this behaviour.
nodes, _ := p.Find(&node)

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions