From d61c4b2bf2015a1080c94f48f8ce245911a4e101 Mon Sep 17 00:00:00 2001 From: Monis Khan Date: Tue, 21 Apr 2020 12:32:03 -0400 Subject: [PATCH 1/4] Fail more gracefully when GitHub is down Signed-off-by: Monis Khan --- pkg/kepval/keps/validations/yaml.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/kepval/keps/validations/yaml.go b/pkg/kepval/keps/validations/yaml.go index 8171eeb5374..eac80f43847 100644 --- a/pkg/kepval/keps/validations/yaml.go +++ b/pkg/kepval/keps/validations/yaml.go @@ -91,21 +91,25 @@ var listGroups []string func init() { resp, err := http.Get("https://raw.githubusercontent.com/kubernetes/community/master/sigs.yaml") if err != nil { - fmt.Fprintf(os.Stderr, "unable to fetch list of sigs: %v", err) + fmt.Fprintf(os.Stderr, "unable to fetch list of sigs: %v\n", err) os.Exit(1) } defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + fmt.Fprintf(os.Stderr, "invalid status code when fetching list of sigs: %d\n", resp.StatusCode) + os.Exit(1) + } re := regexp.MustCompile(`- dir: (.*)$`) scanner := bufio.NewScanner(resp.Body) for scanner.Scan() { match := re.FindStringSubmatch(scanner.Text()) - if len(match)>0 { + if len(match) > 0 { listGroups = append(listGroups, match[1]) } } if err := scanner.Err(); err != nil { - fmt.Fprintf(os.Stderr, "unable to scan list of sigs: %v", err) + fmt.Fprintf(os.Stderr, "unable to scan list of sigs: %v\n", err) os.Exit(1) } sort.Strings(listGroups) From 7978f41f71a24a595598daf73d2380c5db301dd3 Mon Sep 17 00:00:00 2001 From: Monis Khan Date: Tue, 21 Apr 2020 14:20:38 -0400 Subject: [PATCH 2/4] Add support for symlinks and KEP metadata files Signed-off-by: Monis Khan --- cmd/kepval/main.go | 4 ++-- cmd/kepval/main_test.go | 29 ++++++++++++++++++++++++++--- pkg/kepval/keps/proposals.go | 7 +++++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/cmd/kepval/main.go b/cmd/kepval/main.go index 0341b506d04..8c2ca3a2f64 100644 --- a/cmd/kepval/main.go +++ b/cmd/kepval/main.go @@ -32,7 +32,7 @@ func run() int { for _, filename := range os.Args[1:] { file, err := os.Open(filename) if err != nil { - fmt.Printf("could not open file: %v", err) + fmt.Printf("could not open file %s: %v\n", filename, err) return 1 } defer file.Close() @@ -46,6 +46,6 @@ func run() int { return 1 } - fmt.Printf("No validation errors : %v\n", os.Args[1:]) + fmt.Printf("No validation errors: %v\n", os.Args[1:]) return 0 } diff --git a/cmd/kepval/main_test.go b/cmd/kepval/main_test.go index 3998011110c..ce3f61673c5 100644 --- a/cmd/kepval/main_test.go +++ b/cmd/kepval/main_test.go @@ -24,7 +24,8 @@ import ( ) const ( - kepsDir = "keps" + kepsDir = "keps" + kepMetadata = "kep.yaml" ) // This is the actual validation check of all keps in this repo @@ -40,7 +41,19 @@ func TestValidation(t *testing.T) { if info.IsDir() { return nil } - if ignore(info.Name()) { + + dir := filepath.Dir(path) + // true if the file is a symlink + if info.Mode()&os.ModeSymlink != 0 { + // assume symlink from old KEP location to new + newLocation, err := os.Readlink(path) + if err != nil { + return err + } + files = append(files, filepath.Join(dir, filepath.Dir(newLocation), kepMetadata)) + return nil + } + if ignore(dir, info.Name()) { return nil } files = append(files, path) @@ -69,10 +82,19 @@ func TestValidation(t *testing.T) { } // ignore certain files in the keps/ subdirectory -func ignore(name string) bool { +func ignore(dir, name string) bool { + if dir == "../../keps/NNNN-kep-template" { + return true // ignore the template directory because its metadata file does not use a valid sig name + } + + if name == kepMetadata { + return false // always check metadata files + } + if !strings.HasSuffix(name, "md") { return true } + if name == "0023-documentation-for-images.md" || name == "0004-cloud-provider-template.md" || name == "YYYYMMDD-kep-template.md" || @@ -80,5 +102,6 @@ func ignore(name string) bool { name == "kep-faq.md" { return true } + return false } diff --git a/pkg/kepval/keps/proposals.go b/pkg/kepval/keps/proposals.go index 2244af0fd6c..db530323a58 100644 --- a/pkg/kepval/keps/proposals.go +++ b/pkg/kepval/keps/proposals.go @@ -38,6 +38,7 @@ func (p *Proposals) AddProposal(proposal *Proposal) { type Proposal struct { ID string `json:"id"` Title string `json:"title" yaml:"title"` + Number string `json:"kep-number" yaml:"kep-number"` Authors []string `json:"authors" yaml:",flow"` OwningSIG string `json:"owningSig" yaml:"owning-sig"` ParticipatingSIGs []string `json:"participatingSigs" yaml:"participating-sigs,flow,omitempty"` @@ -83,6 +84,12 @@ func (p *Parser) Parse(in io.Reader) *Proposal { return proposal } + // this file is just the KEP metadata + if count == 0 { + metadata = body.Bytes() + proposal.Contents = "" + } + // First do structural checks test := map[interface{}]interface{}{} if err := yaml.Unmarshal(metadata, test); err != nil { From eb67042ab6b8c6c0bc5d15d06a383402b257192d Mon Sep 17 00:00:00 2001 From: Monis Khan Date: Tue, 21 Apr 2020 14:22:05 -0400 Subject: [PATCH 3/4] 617-improve-kep-implementation: fix see-also Signed-off-by: Monis Khan --- keps/sig-architecture/617-improve-kep-implementation/kep.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keps/sig-architecture/617-improve-kep-implementation/kep.yaml b/keps/sig-architecture/617-improve-kep-implementation/kep.yaml index ed1dfd526bb..a02f47b4a5e 100644 --- a/keps/sig-architecture/617-improve-kep-implementation/kep.yaml +++ b/keps/sig-architecture/617-improve-kep-implementation/kep.yaml @@ -21,5 +21,5 @@ approvers: - "@bgrant0607" - "@jbeda" see-also: - - [/keps/0001-kubernetes-enhancement-proposal-process.md] + - /keps/0001-kubernetes-enhancement-proposal-process.md replaces: [] From 07c2b0a0395d09fa8316f7f1b43f0cb8915143cc Mon Sep 17 00:00:00 2001 From: Monis Khan Date: Tue, 21 Apr 2020 14:22:31 -0400 Subject: [PATCH 4/4] Add symlink for old location of external credential providers KEP Signed-off-by: Monis Khan --- keps/sig-auth/20190711-external-credential-providers.md | 1 + 1 file changed, 1 insertion(+) create mode 120000 keps/sig-auth/20190711-external-credential-providers.md diff --git a/keps/sig-auth/20190711-external-credential-providers.md b/keps/sig-auth/20190711-external-credential-providers.md new file mode 120000 index 00000000000..27cff5648c8 --- /dev/null +++ b/keps/sig-auth/20190711-external-credential-providers.md @@ -0,0 +1 @@ +541-external-credential-providers/README.md \ No newline at end of file