-
Notifications
You must be signed in to change notification settings - Fork 709
add filter option to list command #4187
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
base: master
Are you sure you want to change the base?
add filter option to list command #4187
Conversation
4601c97
to
c7631d4
Compare
cmd/limactl/list.go
Outdated
} | ||
if len(filter) != 0 { | ||
for _, f := range filter { | ||
yq = append(yq, "select("+f+")") |
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.
Needs escaping
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 tested numerous escaping approaches as asked, but it breaks the yq expressions. What string escape approach would you recommend? Thanks @AkihiroSuda
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.
@AkihiroSuda I don't see why this needs escaping. The filter expression should be inserted literally inside the select()
.
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.
Without escaping the code looks vulnerable to "Bobby Tables".
Unlikely to result in breaking data in our case though
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.
How is this different from any code you specify via --yq
? The only difference is that the --filter
argument is wrapped inside a select()
call.
The user can literally send the same command via --yq "$(printf "select(%s)" "$FILTER")"
.
Any escaping would simply break the filter 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.
Needs changes (allow --filter
with --yq
) and simplifications.
if len(yq) != 0 { | ||
return errors.New("option --filter conflicts with option --yq") | ||
} |
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 think you should be able to combine --filter
and --yq
as long as the output format is json
or yaml
.
So you could just drop the check here because yq
is already incompatible with the other output formats.
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.
This isn't too clear to me but is there anything wrong with the way it currently is?
cmd/limactl/list.go
Outdated
} | ||
if len(filter) != 0 { | ||
for _, f := range filter { | ||
yq = append(yq, "select("+f+")") |
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.
@AkihiroSuda I don't see why this needs escaping. The filter expression should be inserted literally inside the select()
.
1c7ed74
to
404b08c
Compare
Signed-off-by: olalekan odukoya <odukoyaonline@gmail.com>
404b08c
to
a5ba9ad
Compare
Fixes