Skip to content

Commit ecae345

Browse files
authored
Merge pull request kubernetes#1465 from dims/strict-validation-of-KEPs
Strict validation of keps
2 parents 691be53 + a56fcf2 commit ecae345

File tree

8 files changed

+36
-8
lines changed

8 files changed

+36
-8
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
[._]s[a-w][a-z]
1818
*.un~
1919
Session.vim
20-
.netrwhist
20+
.netrwhist
21+
22+
# Files generated by JetBrains IDEs, e.g. IntelliJ IDEA
23+
.idea/

cmd/kepval/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ func run() int {
4646
return 1
4747
}
4848

49-
fmt.Println("No validation errors")
49+
fmt.Printf("No validation errors : %v\n", os.Args[1:])
5050
return 0
5151
}

cmd/kepval/main_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ func ignore(name string) bool {
7373
if !strings.HasSuffix(name, "md") {
7474
return true
7575
}
76-
if name == "0023-documentation-for-images.md" {
76+
if name == "0023-documentation-for-images.md" ||
77+
name == "0004-cloud-provider-template.md" ||
78+
name == "README.md" ||
79+
name == "kep-faq.md" {
7780
return true
7881
}
7982
return false

keps/sig-cli/kustomize-extend-patch.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ reviewers:
1010
- "@mengqiy"
1111
approvers:
1212
- "@monopole"
13-
editors:
14-
- "@Liujingfang1"
13+
editor: "@Liujingfang1"
1514
creation-date: 2019-03-14
1615
last-updated: 2019-03-18
1716
status: implementable

keps/sig-instrumentation/0034-distributed-tracing-kep.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
title: Leveraging Distributed Tracing to Understand Kubernetes Object Lifecycles
33
authors:
44
- "@Monkeyanator"
5-
editors:
6-
- "@dashpole"
5+
editor: "@dashpole"
76
owning-sig: sig-instrumentation
87
participating-sigs:
98
- sig-architecture

keps/sig-network/20190920-external-dns.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
---
2+
title: Move ExternalDNS out of Kubernetes incubator
3+
authors:
4+
- "@njuettner"
5+
owning-sig: sig-network
6+
---
7+
18
# Move ExternalDNS out of Kubernetes incubator
29

310
## Table of Contents

pkg/kepval/keps/proposals.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ func (p *Parser) Parse(in io.Reader) *Proposal {
9393
return proposal
9494
}
9595

96-
proposal.Error = yaml.Unmarshal(metadata, proposal)
96+
proposal.Error = yaml.UnmarshalStrict(metadata, proposal)
9797
return proposal
9898
}

pkg/kepval/keps/validations/yaml.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ import (
2121
"strings"
2222
)
2323

24+
type KeyMustBeSpecified struct {
25+
key interface{}
26+
}
27+
28+
func (k *KeyMustBeSpecified) Error() string {
29+
return fmt.Sprintf("missing key %[1]v", k.key)
30+
}
31+
2432
type KeyMustBeString struct {
2533
key interface{}
2634
}
@@ -62,7 +70,16 @@ type MustHaveAtLeastOneValue struct {
6270
func (m *MustHaveAtLeastOneValue) Error() string {
6371
return fmt.Sprintf("%q must have at least one value", m.key)
6472
}
73+
74+
var mandatoryKeys = []string{"title", "owning-sig"}
75+
6576
func ValidateStructure(parsed map[interface{}]interface{}) error {
77+
for _, key := range mandatoryKeys {
78+
if _, found := parsed[key]; !found {
79+
return &KeyMustBeSpecified{key}
80+
}
81+
}
82+
6683
for key, value := range parsed {
6784
// First off the key has to be a string. fact.
6885
k, ok := key.(string)

0 commit comments

Comments
 (0)