-
Notifications
You must be signed in to change notification settings - Fork 682
Create limactl tmpl yq
command to query a template
#3313
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
Conversation
2d9e9e3
to
f894b78
Compare
cmd/limactl/template.go
Outdated
templateYQCommand := &cobra.Command{ | ||
Use: "yq TEMPLATE EXPR", | ||
Short: "Query template expressions", | ||
Long: "Extract template data using a yq expression", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add how this differs from the standalone yq
command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only difference is that it works even when you don't have yq
installed (e.g. on Windows GitHub runners). Not sure how you want to put this into the command help.
This is essentially the same as the gh api ... --jq
option, having the tool already built in, so you don't need to worry about having it installed.
I'm planning to eventually add --yq
options to limactl ls
and limactl info
as well, but not right now.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the PR to produce the following output:
❯ limactl tmpl yq --help
Use the builtin YQ evaluator to extract information from a template.
External references are embedded and default values are filled in
before the YQ expression is evaluated.
Example:
limactl template yq template://default '.images[].location'
The example command is equivalent to using an external yq command like this:
limactl template copy --fill template://default - | yq '.images[].location'
Usage:
limactl template yq TEMPLATE EXPR [flags]
...
664f54a
to
955d852
Compare
The following commands are equivalent: limactl tmpl yq $TEMPLATE $EXPRESSION limactl tmpl copy --fill $TEMPLATE - | yq $EXPRESSION The new `yq` variant is clearer, but more importantly does not require that `yq` is installed. Since we already include all the code in limactl anyways, we get this functionality almost for free. Signed-off-by: Jan Dubois <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
The following commands are equivalent:
The new
yq
variant is clearer, but more importantly does not require thatyq
is installed. Since we already include all the code in limactl anyways, we get this functionality almost for free1.Example:
Footnotes
10 lines for the Cobra definition and 20 lines for the implementation; the rest is just refactoring. ↩