Skip to content

Commit 015c031

Browse files
committed
kepctl query: add --participating-sig
1 parent b003f6b commit 015c031

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

pkg/kepctl/commands/query.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ func addQuery(topLevel *cobra.Command) {
8888
"Author",
8989
)
9090

91+
cmd.PersistentFlags().StringSliceVar(
92+
&qo.Participant,
93+
"participating-sig",
94+
nil,
95+
"Participating SIG",
96+
)
97+
9198
cmd.PersistentFlags().BoolVar(
9299
&qo.IncludePRs,
93100
"include-prs",

pkg/kepctl/kepctl.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ type Options struct {
2323
TokenPath string
2424

2525
// KEP options
26-
KEP string // KEP name sig-xxx/xxx-name
27-
Name string
28-
Number string
29-
SIG string
26+
KEP string // KEP name sig-xxx/xxx-name
27+
Name string
28+
Number string
29+
SIG string
30+
ParticipatingSIG string
3031
}

pkg/repo/query.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type QueryOpts struct {
3434
PRRApprover []string
3535
Author []string
3636
Approver []string
37+
Participant []string
3738
IncludePRs bool
3839
Output string
3940
}
@@ -122,6 +123,7 @@ func (r *Repo) Query(opts *QueryOpts) ([]*api.Proposal, error) {
122123
allowedPRR := sliceToMap(opts.PRRApprover)
123124
allowedAuthor := sliceToMap(opts.Author)
124125
allowedApprover := sliceToMap(opts.Approver)
126+
allowedParticipant := sliceToMap(opts.Participant)
125127

126128
results := make([]*api.Proposal, 0, 10)
127129
for _, k := range allKEPs {
@@ -146,6 +148,9 @@ func (r *Repo) Query(opts *QueryOpts) ([]*api.Proposal, error) {
146148
if len(opts.Approver) > 0 && !atLeastOne(k.Approvers, allowedApprover) {
147149
continue
148150
}
151+
if len(opts.Participant) > 0 && !atLeastOne(k.ParticipatingSIGs, allowedParticipant) {
152+
continue
153+
}
149154

150155
results = append(results, k)
151156
}

pkg/repo/query_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,31 @@ func TestQuery(t *testing.T) {
280280
skip: true,
281281
},
282282
},
283+
"participating-sig": {
284+
{
285+
name: "results",
286+
queryOpts: repo.QueryOpts{
287+
Participant: []string{"sig-participates-only"},
288+
},
289+
kepNames: []string{
290+
"42-the-answer",
291+
"404-question-not-found",
292+
},
293+
},
294+
{
295+
name: "no results",
296+
queryOpts: repo.QueryOpts{
297+
Participant: []string{"sig-owns-only"},
298+
},
299+
},
300+
{
301+
name: "invalid",
302+
queryOpts: repo.QueryOpts{
303+
Groups: []string{"sig-does-not-exist"},
304+
},
305+
err: fmt.Errorf("invalid query options: no SIGs match any of: [sig-does-not-exist]"),
306+
},
307+
},
283308
}
284309

285310
r := fixture.validRepo

0 commit comments

Comments
 (0)