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

update syntax for labels #18

Merged
merged 2 commits into from
Feb 7, 2025
Merged

update syntax for labels #18

merged 2 commits into from
Feb 7, 2025

Conversation

miller-time
Copy link
Owner

where before the filter syntax would've been hq read '.block["label"]' now it's hq read '.block{"label"}'

this allows us to treat .name and ["name"] equivalently, with the added bonus that quoting the value allows you to use characters that aren't valid identifier characters.

here's an example:

another_block "some_label" {
    m = {
        "map@key1": "map@value1",
        "map@key2": "map@value2",
    }
}

another_block "another_label" {
    m = {
        "map@key1": "map@value3",
        "map@key2": "map@value4",
    }
}
$ hq read -f example.hcl '.another_block{"some_label"}.m["map@key1"]'
"map@value1"

$ hq read -f example.hcl '.another_block{"some_label"}.m["map@key2"]'
"map@value2"

@miller-time miller-time merged commit e87b41e into master Feb 7, 2025
1 check passed
@miller-time miller-time deleted the curly_labels branch February 7, 2025 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant