Can I use secretJSON with `pass`
Closed this issue · 2 comments
I had been using pass's passFields which is okay for simple key = value
sets. I didn't find there to be any way to use an "array" of values eg:
{
"animals": [
"cat",
"dog",
"mouse"
]
}
I thought if I put this json structure into a pass reference though I should be able to use custom secretJSON right? (I made sure to set secret.command = pass
in my chezmoi config).
{{ secret "show" "secretAnimals" }}
works, but it puts:
"animals": [
"cat",
"dog",
"mouse"
]
Into my file instead of just cat dog mouse
which is what I want. Can I use secretJSON
or JSON data in a "pass" record?
You don’t need to use secretJSON
. If you have JSON data in a pass
entry called secretAnimals
, you can do pass "secretAnimals"
to return the whole entry (IIRC; I do not use pass
on a regular basis).
That will still return a string, so you would then pass that through the fromJson
filter: pass "secretAnimals" | fromJson
.
If your data is nested as you’ve shown, you will need to then select the appropriate key: (pass "secretAnimals" | fromJson).animals
Oh yes, that works wondefully. Just make sure the json is on one line.