@@ -18,7 +18,6 @@ package repo
18
18
19
19
import (
20
20
"fmt"
21
- "os"
22
21
"regexp"
23
22
24
23
"github.com/pkg/errors"
@@ -29,13 +28,6 @@ import (
29
28
)
30
29
31
30
type QueryOpts struct {
32
- // Proposal options
33
- KEP string // KEP name sig-xxx/xxx-name
34
- Name string
35
- Number string
36
- SIG string
37
-
38
- // Queries
39
31
Groups []string
40
32
Status []string
41
33
Stage []string
@@ -84,18 +76,18 @@ func (r *Repo) PrepareQueryOpts(opts *QueryOpts) error {
84
76
85
77
// Query searches the local repo and possibly GitHub for KEPs
86
78
// that match the search criteria.
87
- func (r * Repo ) Query (opts * QueryOpts ) error {
79
+ func (r * Repo ) Query (opts * QueryOpts ) ([] * api. Proposal , error ) {
88
80
logrus .Info ("Searching for KEPs..." )
89
81
90
82
err := r .PrepareQueryOpts (opts )
91
83
if err != nil {
92
- return fmt .Errorf ("unable to prepare query opts: %w" , err )
84
+ return nil , fmt .Errorf ("unable to prepare query opts: %w" , err )
93
85
}
94
86
95
87
if r .TokenPath != "" {
96
88
logrus .Infof ("Setting GitHub token: %v" , r .TokenPath )
97
89
if tokenErr := r .SetGitHubToken (r .TokenPath ); tokenErr != nil {
98
- return errors .Wrapf (tokenErr , "setting GitHub token" )
90
+ return nil , errors .Wrapf (tokenErr , "setting GitHub token" )
99
91
}
100
92
}
101
93
@@ -105,7 +97,7 @@ func (r *Repo) Query(opts *QueryOpts) error {
105
97
// KEPs in the local filesystem
106
98
localKEPs , err := r .LoadLocalKEPs (sig )
107
99
if err != nil {
108
- return errors .Wrap (err , "loading local KEPs" )
100
+ return nil , errors .Wrap (err , "loading local KEPs" )
109
101
}
110
102
111
103
allKEPs = append (allKEPs , localKEPs ... )
@@ -134,7 +126,7 @@ func (r *Repo) Query(opts *QueryOpts) error {
134
126
results := make ([]* api.Proposal , 0 , 10 )
135
127
for _ , k := range allKEPs {
136
128
if k == nil {
137
- return errors .New ("one of the KEPs in query was nil" )
129
+ return nil , errors .New ("one of the KEPs in query was nil" )
138
130
}
139
131
140
132
logrus .Debugf ("current KEP: %v" , k )
@@ -158,13 +150,7 @@ func (r *Repo) Query(opts *QueryOpts) error {
158
150
results = append (results , k )
159
151
}
160
152
161
- o , err := output .NewOutput (opts .Output , os .Stdout , os .Stderr )
162
- if err != nil {
163
- return err
164
- }
165
- o .PrintProposals (results )
166
-
167
- return nil
153
+ return results , nil
168
154
}
169
155
170
156
func sliceToMap (s []string ) map [string ]bool {
0 commit comments