@@ -17,7 +17,6 @@ limitations under the License.
17
17
package repo
18
18
19
19
import (
20
- "bytes"
21
20
"context"
22
21
"fmt"
23
22
"io"
@@ -59,10 +58,11 @@ type Repo struct {
59
58
BasePath string
60
59
ProposalPath string
61
60
PRRApprovalPath string
62
- TokenPath string
61
+ ProposalReadme string
63
62
64
63
// Auth
65
- Token string
64
+ TokenPath string
65
+ Token string
66
66
67
67
// I/O
68
68
In io.Reader
@@ -121,10 +121,28 @@ func New(repoPath string) (*Repo, error) {
121
121
)
122
122
}
123
123
124
+ proposalReadme := filepath .Join (proposalPath , "README.md" )
125
+ fi , err = os .Stat (proposalReadme )
126
+ if err != nil {
127
+ return nil , errors .Wrapf (
128
+ err ,
129
+ "getting file info for proposal README path %s" ,
130
+ proposalPath ,
131
+ )
132
+ }
133
+
134
+ if ! fi .Mode ().IsRegular () {
135
+ return nil , errors .Wrap (
136
+ err ,
137
+ "checking if proposal README is a file" ,
138
+ )
139
+ }
140
+
124
141
repo := & Repo {
125
142
BasePath : repoPath ,
126
143
ProposalPath : proposalPath ,
127
144
PRRApprovalPath : prrApprovalPath ,
145
+ ProposalReadme : proposalReadme ,
128
146
In : os .Stdin ,
129
147
Out : os .Stdout ,
130
148
Err : os .Stderr ,
@@ -203,10 +221,6 @@ func (r *Repo) findLocalKEPMeta(sig string) ([]string, error) {
203
221
return err
204
222
}
205
223
206
- if ignore (info .Name (), "yaml" , "md" ) {
207
- return nil
208
- }
209
-
210
224
// true if the file is a symlink
211
225
if info .Mode ()& os .ModeSymlink != 0 {
212
226
// Assume symlink from old KEP location to new. The new location
@@ -225,10 +239,6 @@ func (r *Repo) findLocalKEPMeta(sig string) ([]string, error) {
225
239
return filepath .SkipDir
226
240
}
227
241
228
- if filepath .Ext (path ) != ".md" {
229
- return nil
230
- }
231
-
232
242
if info .Name () == ProposalFilename {
233
243
return nil
234
244
}
@@ -267,17 +277,6 @@ func (r *Repo) LoadLocalKEPs(sig string) ([]*api.Proposal, error) {
267
277
)
268
278
}
269
279
270
- allKEPs = append (allKEPs , kep )
271
- } else {
272
- kep , err := r .loadKEPFromOldStyle (k )
273
- if err != nil {
274
- return nil , errors .Wrapf (
275
- err ,
276
- "reading KEP %s from markdown" ,
277
- k ,
278
- )
279
- }
280
-
281
280
allKEPs = append (allKEPs , kep )
282
281
}
283
282
}
@@ -428,18 +427,11 @@ func (r *Repo) ReadKEP(sig, name string) (*api.Proposal, error) {
428
427
)
429
428
430
429
_ , err := os .Stat (kepPath )
431
- if err = = nil {
432
- return r . loadKEPFromYaml ( kepPath )
430
+ if err ! = nil {
431
+ return nil , errors . Wrapf ( err , "getting file info for %s" , kepPath )
433
432
}
434
433
435
- // No kep.yaml, treat as old-style KEP
436
- kepPath = filepath .Join (
437
- r .ProposalPath ,
438
- sig ,
439
- name ,
440
- ) + ".md"
441
-
442
- return r .loadKEPFromOldStyle (kepPath )
434
+ return r .loadKEPFromYaml (kepPath )
443
435
}
444
436
445
437
func (r * Repo ) loadKEPFromYaml (kepPath string ) (* api.Proposal , error ) {
@@ -512,22 +504,3 @@ func (r *Repo) loadKEPFromYaml(kepPath string) (*api.Proposal, error) {
512
504
513
505
return & p , nil
514
506
}
515
-
516
- func (r * Repo ) loadKEPFromOldStyle (kepPath string ) (* api.Proposal , error ) {
517
- b , err := ioutil .ReadFile (kepPath )
518
- if err != nil {
519
- return nil , fmt .Errorf ("no kep.yaml, but failed to read as old-style KEP: %s" , err )
520
- }
521
-
522
- reader := bytes .NewReader (b )
523
-
524
- handler := r .KEPHandler
525
-
526
- kep , err := handler .Parse (reader )
527
- if err != nil {
528
- return nil , fmt .Errorf ("kep is invalid: %s" , kep .Error )
529
- }
530
-
531
- kep .Name = filepath .Base (kepPath )
532
- return kep , nil
533
- }
0 commit comments