@@ -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 != "" {
@@ -280,7 +281,7 @@ func (c *Client) loadKEPPullRequests(sig string) ([]*keps.Proposal, error) {
280
281
281
282
// read out each PR, and create a Proposal for each KEP that is
282
283
// touched by a PR. This may result in multiple versions of the same KEP.
283
- var allKEPs []* keps .Proposal
284
+ var allKEPs []* api .Proposal
284
285
for _ , pr := range kepPRs {
285
286
files , _ , err := gh .PullRequests .ListFiles (context .Background (), "kubernetes" , "enhancements" ,
286
287
pr .GetNumber (), & github.ListOptions {})
@@ -329,7 +330,7 @@ func (c *Client) loadKEPPullRequests(sig string) ([]*keps.Proposal, error) {
329
330
return allKEPs , nil
330
331
}
331
332
332
- func (c * Client ) readKEP (repoPath string , sig , name string ) (* keps .Proposal , error ) {
333
+ func (c * Client ) readKEP (repoPath string , sig , name string ) (* api .Proposal , error ) {
333
334
kepPath := filepath .Join (
334
335
repoPath ,
335
336
"keps" ,
@@ -352,12 +353,12 @@ func (c *Client) readKEP(repoPath string, sig, name string) (*keps.Proposal, err
352
353
return c .loadKEPFromOldStyle (kepPath )
353
354
}
354
355
355
- func (c * Client ) loadKEPFromYaml (kepPath string ) (* keps .Proposal , error ) {
356
+ func (c * Client ) loadKEPFromYaml (kepPath string ) (* api .Proposal , error ) {
356
357
b , err := ioutil .ReadFile (kepPath )
357
358
if err != nil {
358
359
return nil , fmt .Errorf ("unable to read KEP metadata: %s" , err )
359
360
}
360
- var p keps .Proposal
361
+ var p api .Proposal
361
362
err = yaml .Unmarshal (b , & p )
362
363
if err != nil {
363
364
return nil , fmt .Errorf ("unable to load KEP metadata: %s" , err )
@@ -366,7 +367,7 @@ func (c *Client) loadKEPFromYaml(kepPath string) (*keps.Proposal, error) {
366
367
return & p , nil
367
368
}
368
369
369
- func (c * Client ) loadKEPFromOldStyle (kepPath string ) (* keps .Proposal , error ) {
370
+ func (c * Client ) loadKEPFromOldStyle (kepPath string ) (* api .Proposal , error ) {
370
371
b , err := ioutil .ReadFile (kepPath )
371
372
if err != nil {
372
373
return nil , fmt .Errorf ("no kep.yaml, but failed to read as old-style KEP: %s" , err )
@@ -382,7 +383,7 @@ func (c *Client) loadKEPFromOldStyle(kepPath string) (*keps.Proposal, error) {
382
383
return kep , nil
383
384
}
384
385
385
- func (c * Client ) writeKEP (kep * keps .Proposal , opts CommonArgs ) error {
386
+ func (c * Client ) writeKEP (kep * api .Proposal , opts CommonArgs ) error {
386
387
path , err := c .findEnhancementsRepo (opts )
387
388
if err != nil {
388
389
return fmt .Errorf ("unable to write KEP: %s" , err )
@@ -408,39 +409,39 @@ func (c *Client) writeKEP(kep *keps.Proposal, opts CommonArgs) error {
408
409
409
410
type PrintConfig interface {
410
411
Title () string
411
- Value (* keps .Proposal ) string
412
+ Value (* api .Proposal ) string
412
413
}
413
414
414
415
type printConfig struct {
415
416
title string
416
- valueFunc func (* keps .Proposal ) string
417
+ valueFunc func (* api .Proposal ) string
417
418
}
418
419
419
420
func (p * printConfig ) Title () string { return p .title }
420
- func (p * printConfig ) Value (k * keps .Proposal ) string {
421
+ func (p * printConfig ) Value (k * api .Proposal ) string {
421
422
return p .valueFunc (k )
422
423
}
423
424
424
425
var defaultConfig = map [string ]printConfig {
425
- "Authors" : {"Authors" , func (k * keps .Proposal ) string { return strings .Join (k .Authors , ", " ) }},
426
- "LastUpdated" : {"Updated" , func (k * keps .Proposal ) string { return k .LastUpdated }},
427
- "SIG" : {"SIG" , func (k * keps .Proposal ) string {
426
+ "Authors" : {"Authors" , func (k * api .Proposal ) string { return strings .Join (k .Authors , ", " ) }},
427
+ "LastUpdated" : {"Updated" , func (k * api .Proposal ) string { return k .LastUpdated }},
428
+ "SIG" : {"SIG" , func (k * api .Proposal ) string {
428
429
if strings .HasPrefix (k .OwningSIG , "sig-" ) {
429
430
return k .OwningSIG [4 :]
430
431
} else {
431
432
return k .OwningSIG
432
433
}
433
434
}},
434
- "Stage" : {"Stage" , func (k * keps .Proposal ) string { return k .Stage }},
435
- "Status" : {"Status" , func (k * keps .Proposal ) string { return k .Status }},
436
- "Title" : {"Title" , func (k * keps .Proposal ) string {
435
+ "Stage" : {"Stage" , func (k * api .Proposal ) string { return k .Stage }},
436
+ "Status" : {"Status" , func (k * api .Proposal ) string { return k .Status }},
437
+ "Title" : {"Title" , func (k * api .Proposal ) string {
437
438
if k .PRNumber == "" {
438
439
return k .Title
439
440
} else {
440
441
return "PR#" + k .PRNumber + " - " + k .Title
441
442
}
442
443
}},
443
- "Link" : {"Link" , func (k * keps .Proposal ) string {
444
+ "Link" : {"Link" , func (k * api .Proposal ) string {
444
445
if k .PRNumber == "" {
445
446
return "https://git.k8s.io/enhancements/keps/" + k .OwningSIG + "/" + k .Name
446
447
} else {
@@ -459,7 +460,7 @@ func DefaultPrintConfigs(names ...string) []PrintConfig {
459
460
return configs
460
461
}
461
462
462
- func (c * Client ) PrintTable (configs []PrintConfig , proposals []* keps .Proposal ) {
463
+ func (c * Client ) PrintTable (configs []PrintConfig , proposals []* api .Proposal ) {
463
464
if len (configs ) == 0 {
464
465
return
465
466
}
@@ -484,7 +485,7 @@ func (c *Client) PrintTable(configs []PrintConfig, proposals []*keps.Proposal) {
484
485
}
485
486
486
487
// PrintYAML outputs keps array as YAML to c.Out
487
- func (c * Client ) PrintYAML (proposals []* keps .Proposal ) {
488
+ func (c * Client ) PrintYAML (proposals []* api .Proposal ) {
488
489
data , err := yaml .Marshal (proposals )
489
490
if err != nil {
490
491
fmt .Fprintf (c .Err , "error printing keps as YAML: %s" , err )
@@ -495,7 +496,7 @@ func (c *Client) PrintYAML(proposals []*keps.Proposal) {
495
496
}
496
497
497
498
// PrintJSON outputs keps array as YAML to c.Out
498
- func (c * Client ) PrintJSON (proposals []* keps .Proposal ) {
499
+ func (c * Client ) PrintJSON (proposals []* api .Proposal ) {
499
500
data , err := json .Marshal (proposals )
500
501
if err != nil {
501
502
fmt .Fprintf (c .Err , "error printing keps as JSON: %s" , err )
0 commit comments