@@ -35,6 +35,7 @@ import (
35
35
"golang.org/x/oauth2"
36
36
"gopkg.in/yaml.v2"
37
37
38
+ "k8s.io/enhancements/api"
38
39
"k8s.io/enhancements/pkg/kepval/keps"
39
40
"k8s.io/test-infra/prow/git"
40
41
)
@@ -127,8 +128,8 @@ func (c *Client) SetGitHubToken(opts CommonArgs) error {
127
128
// getKepTemplate reads the kep.yaml template from the local
128
129
// (per c.RepoPath) k/enhancements, but this could be replaced with a
129
130
// template via packr or fetched from Github?
130
- func (c * Client ) getKepTemplate (repoPath string ) (* keps .Proposal , error ) {
131
- var p keps .Proposal
131
+ func (c * Client ) getKepTemplate (repoPath string ) (* api .Proposal , error ) {
132
+ var p api .Proposal
132
133
path := filepath .Join (repoPath , "keps" , "NNNN-kep-template" , "kep.yaml" )
133
134
b , err := ioutil .ReadFile (path )
134
135
if err != nil {
@@ -148,7 +149,7 @@ func (c *Client) getReadmeTemplate(repoPath string) ([]byte, error) {
148
149
return ioutil .ReadFile (path )
149
150
}
150
151
151
- func validateKEP (p * keps .Proposal ) error {
152
+ func validateKEP (p * api .Proposal ) error {
152
153
b , err := yaml .Marshal (p )
153
154
if err != nil {
154
155
return err
@@ -200,14 +201,14 @@ func findLocalKEPMeta(repoPath, sig string) ([]string, error) {
200
201
return keps , err
201
202
}
202
203
203
- func (c * Client ) loadLocalKEPs (repoPath , sig string ) ( []* keps .Proposal ) {
204
+ func (c * Client ) loadLocalKEPs (repoPath , sig string ) []* api .Proposal {
204
205
// KEPs in the local filesystem
205
206
files , err := findLocalKEPMeta (repoPath , sig )
206
207
if err != nil {
207
208
fmt .Fprintf (c .Err , "error searching for local KEPs from %s: %s\n " , sig , err )
208
209
}
209
210
210
- var allKEPs []* keps .Proposal
211
+ var allKEPs []* api .Proposal
211
212
for _ , k := range files {
212
213
if filepath .Ext (k ) == ".yaml" {
213
214
kep , err := c .loadKEPFromYaml (k )
@@ -228,7 +229,7 @@ func (c *Client) loadLocalKEPs(repoPath, sig string) ([]*keps.Proposal) {
228
229
return allKEPs
229
230
}
230
231
231
- func (c * Client ) loadKEPPullRequests (sig string ) ([]* keps .Proposal , error ) {
232
+ func (c * Client ) loadKEPPullRequests (sig string ) ([]* api .Proposal , error ) {
232
233
var auth * http.Client
233
234
ctx := context .Background ()
234
235
if c .Token != "" {
@@ -289,7 +290,7 @@ func (c *Client) loadKEPPullRequests(sig string) ([]*keps.Proposal, error) {
289
290
290
291
// read out each PR, and create a Proposal for each KEP that is
291
292
// touched by a PR. This may result in multiple versions of the same KEP.
292
- var allKEPs []* keps .Proposal
293
+ var allKEPs []* api .Proposal
293
294
for _ , pr := range kepPRs {
294
295
files , _ , err := gh .PullRequests .ListFiles (context .Background (), "kubernetes" , "enhancements" ,
295
296
pr .GetNumber (), & github.ListOptions {})
@@ -338,7 +339,7 @@ func (c *Client) loadKEPPullRequests(sig string) ([]*keps.Proposal, error) {
338
339
return allKEPs , nil
339
340
}
340
341
341
- func (c * Client ) readKEP (repoPath string , sig , name string ) (* keps .Proposal , error ) {
342
+ func (c * Client ) readKEP (repoPath string , sig , name string ) (* api .Proposal , error ) {
342
343
kepPath := filepath .Join (
343
344
repoPath ,
344
345
"keps" ,
@@ -361,12 +362,12 @@ func (c *Client) readKEP(repoPath string, sig, name string) (*keps.Proposal, err
361
362
return c .loadKEPFromOldStyle (kepPath )
362
363
}
363
364
364
- func (c * Client ) loadKEPFromYaml (kepPath string ) (* keps .Proposal , error ) {
365
+ func (c * Client ) loadKEPFromYaml (kepPath string ) (* api .Proposal , error ) {
365
366
b , err := ioutil .ReadFile (kepPath )
366
367
if err != nil {
367
368
return nil , fmt .Errorf ("unable to read KEP metadata: %s" , err )
368
369
}
369
- var p keps .Proposal
370
+ var p api .Proposal
370
371
err = yaml .Unmarshal (b , & p )
371
372
if err != nil {
372
373
return nil , fmt .Errorf ("unable to load KEP metadata: %s" , err )
@@ -375,7 +376,7 @@ func (c *Client) loadKEPFromYaml(kepPath string) (*keps.Proposal, error) {
375
376
return & p , nil
376
377
}
377
378
378
- func (c * Client ) loadKEPFromOldStyle (kepPath string ) (* keps .Proposal , error ) {
379
+ func (c * Client ) loadKEPFromOldStyle (kepPath string ) (* api .Proposal , error ) {
379
380
b , err := ioutil .ReadFile (kepPath )
380
381
if err != nil {
381
382
return nil , fmt .Errorf ("no kep.yaml, but failed to read as old-style KEP: %s" , err )
@@ -391,7 +392,7 @@ func (c *Client) loadKEPFromOldStyle(kepPath string) (*keps.Proposal, error) {
391
392
return kep , nil
392
393
}
393
394
394
- func (c * Client ) writeKEP (kep * keps .Proposal , opts CommonArgs ) error {
395
+ func (c * Client ) writeKEP (kep * api .Proposal , opts CommonArgs ) error {
395
396
path , err := c .findEnhancementsRepo (opts )
396
397
if err != nil {
397
398
return fmt .Errorf ("unable to write KEP: %s" , err )
@@ -417,39 +418,39 @@ func (c *Client) writeKEP(kep *keps.Proposal, opts CommonArgs) error {
417
418
418
419
type PrintConfig interface {
419
420
Title () string
420
- Value (* keps .Proposal ) string
421
+ Value (* api .Proposal ) string
421
422
}
422
423
423
424
type printConfig struct {
424
425
title string
425
- valueFunc func (* keps .Proposal ) string
426
+ valueFunc func (* api .Proposal ) string
426
427
}
427
428
428
429
func (p * printConfig ) Title () string { return p .title }
429
- func (p * printConfig ) Value (k * keps .Proposal ) string {
430
+ func (p * printConfig ) Value (k * api .Proposal ) string {
430
431
return p .valueFunc (k )
431
432
}
432
433
433
434
var defaultConfig = map [string ]printConfig {
434
- "Authors" : {"Authors" , func (k * keps .Proposal ) string { return strings .Join (k .Authors , ", " ) }},
435
- "LastUpdated" : {"Updated" , func (k * keps .Proposal ) string { return k .LastUpdated }},
436
- "SIG" : {"SIG" , func (k * keps .Proposal ) string {
435
+ "Authors" : {"Authors" , func (k * api .Proposal ) string { return strings .Join (k .Authors , ", " ) }},
436
+ "LastUpdated" : {"Updated" , func (k * api .Proposal ) string { return k .LastUpdated }},
437
+ "SIG" : {"SIG" , func (k * api .Proposal ) string {
437
438
if strings .HasPrefix (k .OwningSIG , "sig-" ) {
438
439
return k .OwningSIG [4 :]
439
440
} else {
440
441
return k .OwningSIG
441
442
}
442
443
}},
443
- "Stage" : {"Stage" , func (k * keps .Proposal ) string { return k .Stage }},
444
- "Status" : {"Status" , func (k * keps .Proposal ) string { return k .Status }},
445
- "Title" : {"Title" , func (k * keps .Proposal ) string {
444
+ "Stage" : {"Stage" , func (k * api .Proposal ) string { return k .Stage }},
445
+ "Status" : {"Status" , func (k * api .Proposal ) string { return k .Status }},
446
+ "Title" : {"Title" , func (k * api .Proposal ) string {
446
447
if k .PRNumber == "" {
447
448
return k .Title
448
449
} else {
449
450
return "PR#" + k .PRNumber + " - " + k .Title
450
451
}
451
452
}},
452
- "Link" : {"Link" , func (k * keps .Proposal ) string {
453
+ "Link" : {"Link" , func (k * api .Proposal ) string {
453
454
if k .PRNumber == "" {
454
455
return "https://git.k8s.io/enhancements/keps/" + k .OwningSIG + "/" + k .Name
455
456
} else {
@@ -468,7 +469,7 @@ func DefaultPrintConfigs(names ...string) []PrintConfig {
468
469
return configs
469
470
}
470
471
471
- func (c * Client ) PrintTable (configs []PrintConfig , proposals []* keps .Proposal ) {
472
+ func (c * Client ) PrintTable (configs []PrintConfig , proposals []* api .Proposal ) {
472
473
if len (configs ) == 0 {
473
474
return
474
475
}
@@ -493,7 +494,7 @@ func (c *Client) PrintTable(configs []PrintConfig, proposals []*keps.Proposal) {
493
494
}
494
495
495
496
// PrintYAML outputs keps array as YAML to c.Out
496
- func (c * Client ) PrintYAML (proposals []* keps .Proposal ) {
497
+ func (c * Client ) PrintYAML (proposals []* api .Proposal ) {
497
498
data , err := yaml .Marshal (proposals )
498
499
if err != nil {
499
500
fmt .Fprintf (c .Err , "error printing keps as YAML: %s" , err )
@@ -504,7 +505,7 @@ func (c *Client) PrintYAML(proposals []*keps.Proposal) {
504
505
}
505
506
506
507
// PrintJSON outputs keps array as YAML to c.Out
507
- func (c * Client ) PrintJSON (proposals []* keps .Proposal ) {
508
+ func (c * Client ) PrintJSON (proposals []* api .Proposal ) {
508
509
data , err := json .Marshal (proposals )
509
510
if err != nil {
510
511
fmt .Fprintf (c .Err , "error printing keps as JSON: %s" , err )
0 commit comments