Skip to content

formating variables with dots and slash in name #228

Answered by TomWright
prune998 asked this question in Q&A
Discussion options

You must be logged in to vote

You've got the right idea, but with the golang templating you need to use the index function to access map keys: https://pkg.go.dev/text/template#hdr-Functions

index
Returns the result of indexing its first argument by the
following arguments. Thus "index x 1 2 3" is, in Go syntax,
x[1][2][3]. Each indexed item must be a map, slice, or array.

For context, the format string is a plain golang text/template and is processed outside of the normal dasel selector syntax. You could probably use the select func in the condition to use dasel syntax but in the meantime here's what I came up with:

$ echo '{
    "apiVersion": "v1",
    "items": [
        {
            "apiVersion": "networking.k8s.…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TomWright
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants