Skip to content

Commit c18e33a

Browse files
authored
Merge pull request kubernetes#2282 from shekhar-rajak/2279_additional_query
Additional query options to kepctl query - author, approver
2 parents 9106c8f + 63beaf7 commit c18e33a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

cmd/kepctl/query.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ func buildQueryCommand(k *kepctl.Client) *cobra.Command {
4444
f.StringSliceVar(&opts.Status, "status", nil, "Status")
4545
f.StringSliceVar(&opts.Stage, "stage", nil, "Stage")
4646
f.StringSliceVar(&opts.PRRApprover, "prr", nil, "Prod Readiness Approver")
47+
f.StringSliceVar(&opts.Approver, "approver", nil, "Approver")
48+
f.StringSliceVar(&opts.Author, "author", nil, "Author")
4749
f.BoolVar(&opts.IncludePRs, "include-prs", false, "Include PRs in the results")
4850
f.StringVar(&opts.Output, "output", kepctl.DefaultOutputOpt, fmt.Sprintf("Output format. Can be %v", kepctl.SupportedOutputOpts))
4951

pkg/kepctl/query.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ type QueryOpts struct {
4949
Status []string
5050
Stage []string
5151
PRRApprover []string
52+
Author []string
53+
Approver []string
5254
IncludePRs bool
5355
Output string
5456
}
@@ -121,6 +123,8 @@ func (c *Client) Query(opts QueryOpts) error {
121123
allowedStatus := sliceToMap(opts.Status)
122124
allowedStage := sliceToMap(opts.Stage)
123125
allowedPRR := sliceToMap(opts.PRRApprover)
126+
allowedAuthor := sliceToMap(opts.Author)
127+
allowedApprover := sliceToMap(opts.Approver)
124128

125129
var keep []*keps.Proposal
126130
for _, k := range allKEPs {
@@ -133,6 +137,12 @@ func (c *Client) Query(opts QueryOpts) error {
133137
if len(opts.PRRApprover) > 0 && !atLeastOne(k.PRRApprovers, allowedPRR) {
134138
continue
135139
}
140+
if len(opts.Author) > 0 && !atLeastOne(k.Authors, allowedAuthor) {
141+
continue
142+
}
143+
if len(opts.Approver) > 0 && !atLeastOne(k.Approvers, allowedApprover) {
144+
continue
145+
}
136146
keep = append(keep, k)
137147
}
138148

0 commit comments

Comments
 (0)