Skip to content

Commit b8bdaf9

Browse files
committed
pkg/repo: Remove logic for processing legacy KEPs
Signed-off-by: Stephen Augustus <[email protected]>
1 parent ce28320 commit b8bdaf9

File tree

15 files changed

+85
-118
lines changed

15 files changed

+85
-118
lines changed

pkg/repo/repo.go

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package repo
1818

1919
import (
20-
"bytes"
2120
"context"
2221
"fmt"
2322
"io"
@@ -59,10 +58,11 @@ type Repo struct {
5958
BasePath string
6059
ProposalPath string
6160
PRRApprovalPath string
62-
TokenPath string
61+
ProposalReadme string
6362

6463
// Auth
65-
Token string
64+
TokenPath string
65+
Token string
6666

6767
// I/O
6868
In io.Reader
@@ -121,10 +121,28 @@ func New(repoPath string) (*Repo, error) {
121121
)
122122
}
123123

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+
124141
repo := &Repo{
125142
BasePath: repoPath,
126143
ProposalPath: proposalPath,
127144
PRRApprovalPath: prrApprovalPath,
145+
ProposalReadme: proposalReadme,
128146
In: os.Stdin,
129147
Out: os.Stdout,
130148
Err: os.Stderr,
@@ -203,10 +221,6 @@ func (r *Repo) findLocalKEPMeta(sig string) ([]string, error) {
203221
return err
204222
}
205223

206-
if ignore(info.Name(), "yaml", "md") {
207-
return nil
208-
}
209-
210224
// true if the file is a symlink
211225
if info.Mode()&os.ModeSymlink != 0 {
212226
// Assume symlink from old KEP location to new. The new location
@@ -225,10 +239,6 @@ func (r *Repo) findLocalKEPMeta(sig string) ([]string, error) {
225239
return filepath.SkipDir
226240
}
227241

228-
if filepath.Ext(path) != ".md" {
229-
return nil
230-
}
231-
232242
if info.Name() == ProposalFilename {
233243
return nil
234244
}
@@ -267,17 +277,6 @@ func (r *Repo) LoadLocalKEPs(sig string) ([]*api.Proposal, error) {
267277
)
268278
}
269279

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-
281280
allKEPs = append(allKEPs, kep)
282281
}
283282
}
@@ -428,18 +427,11 @@ func (r *Repo) ReadKEP(sig, name string) (*api.Proposal, error) {
428427
)
429428

430429
_, 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)
433432
}
434433

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)
443435
}
444436

445437
func (r *Repo) loadKEPFromYaml(kepPath string) (*api.Proposal, error) {
@@ -512,22 +504,3 @@ func (r *Repo) loadKEPFromYaml(kepPath string) (*api.Proposal, error) {
512504

513505
return &p, nil
514506
}
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-
}

pkg/repo/repo_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,17 @@ func TestFindLocalKEPs(t *testing.T) {
7171
}{
7272
{
7373
"sig-architecture",
74-
[]string{"123-newstyle", "20200115-kubectl-diff.md"},
74+
[]string{
75+
"123-newstyle",
76+
},
7577
},
7678
{
7779
"sig-sig",
7880
[]string{},
7981
},
8082
}
8183

82-
r, repoErr := repo.New("testdata")
84+
r, repoErr := repo.New(validRepo)
8385
require.Nil(t, repoErr)
8486

8587
for i, tc := range testcases {

pkg/repo/testdata/keps/sig-architecture/20200115-kubectl-diff.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

pkg/repo/testdata/keps/sig-architecture/20200528-newstyle.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)