rewrite
rewrite copied to clipboard
HCL base recipes and utilities
- [x]
getAttributeValue(String)
/getAttribute(String)
onBlock
- [x]
withAttributeValue(String, String)
onBlock
- [x]
JsonPathMatcher
for HCL - [x]
DeleteContent
by path (content includes blocks but could also include attributes) - [ ]
InsertContent
by path - [ ]
MergeContent
- [x] New file with
Block
from another - [x]
FindContent
(search recipe)
cc / @nmck257 JsonPathMatcher
will be a more fully featured form of getBlockPath()
.
JsonPathMatcher
introduced with df8d8dece8fe40253bc80c75821a836f082321d5
@jkschneider thoughts on JsonPathMatcher support for querying on labels? (didn't think it does currently)
I'm thinking something like $.provider[aws]
to match the first block below - or $.resource[foo.bar]
to match third block below.
provider "aws" {
}
provider "gcp" {
}
resource "foo" "bar" {
}
Edit - proper jsonpath syntax is probably something like $.provider[?(@.labels = 'aws']
or $.resource[?(@.labels = 'foo.bar']
- labels being a special property to query on