Skip to content

Commit 9e5e92e

Browse files
authored
Merge pull request kubernetes#3007 from spiffxp/prr-implemented
pkg/kepval: enable PRR check for implemented KEPs
2 parents 45a37e6 + 4b78b37 commit 9e5e92e

File tree

78 files changed

+256
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+256
-7
lines changed

api/proposal.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ func (k *KEPHandler) Validate(p *Proposal) []error {
257257
if err := p.Stage.IsValid(); err != nil {
258258
allErrs = append(allErrs, err)
259259
}
260+
if p.Status == ImplementedStatus && p.Stage != StableStage {
261+
allErrs = append(allErrs, fmt.Errorf("status:implemented implies stage:stable but found: %v", p.Stage))
262+
}
260263
return allErrs
261264
}
262265

hack/edit-keps.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright 2021 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""Edit KEPs en-masse by round-tripping them through ruamel.yaml
18+
19+
This is not intended for general usage, because:
20+
- many keps have different formatting, and we're not at a point where
21+
we can enforce formatting standards, so this is almost guaranteed
22+
to introduce formatting change noise
23+
- the idea is to manually edit this file with the specific edit to be
24+
done, rather that developing a general purpose language to do this
25+
"""
26+
27+
import argparse
28+
import glob
29+
30+
from os import path
31+
32+
import ruamel.yaml
33+
34+
# Files that will be ignored
35+
EXCLUDED_FILES = []
36+
# A hilariously large line length to ensure we never line-wrap
37+
MAX_WIDTH = 2000000000
38+
39+
def setup_yaml():
40+
# Setup the ruamel.yaml parser
41+
yaml = ruamel.yaml.YAML(typ='rt')
42+
yaml.preserve_quotes = True
43+
# This is what's used in the template, currently ~36 KEPs have drifted
44+
yaml.indent(mapping=2, sequence=4, offset=2)
45+
yaml.width = MAX_WIDTH
46+
return yaml
47+
48+
def edit_kep(yaml, file_name, force_rewrite=False):
49+
with open(file_name, "r") as fp:
50+
kep = yaml.load(fp)
51+
52+
rewrite = force_rewrite
53+
54+
stage = kep.get("stage", "unknown")
55+
status = kep.get("status", "unknown")
56+
latest_milestone = kep.get("latest-milestone", "unknown")
57+
last_updated = kep.get("last-updated", "unknown")
58+
milestone = kep.get("milestone", {})
59+
60+
if status == "implemented":
61+
if latest_milestone == "unknown":
62+
print(f'status: {status} stage: {stage} last-updated: {last_updated} file: {file_name}')
63+
kep["latest-milestone"] = "0.0"
64+
rewrite = True
65+
if stage == "unknown":
66+
if latest_milestone == "unknown":
67+
kep["stage"] = "stable"
68+
else:
69+
kep["stage"] = [s for s,v in milestone.items() if v == latest_milestone][0]
70+
rewrite = True
71+
72+
# Dump KEP to file_name
73+
if rewrite:
74+
print(f' writing {file_name}')
75+
with open(file_name, "w") as fp:
76+
yaml.dump(kep, fp)
77+
fp.truncate()
78+
79+
def main(keps_dir, force_rewrite):
80+
yaml = setup_yaml()
81+
for f in glob.glob(f'{keps_dir}/**/kep.yaml', recursive=True):
82+
if path.basename(f) not in EXCLUDED_FILES:
83+
try:
84+
print(f'processing file: {f}')
85+
edit_kep(yaml, f, force_rewrite)
86+
except Exception as e: # pylint: disable=broad-except
87+
print(f'ERROR: could not edit {f}: {e}')
88+
89+
if __name__ == '__main__':
90+
PARSER = argparse.ArgumentParser(
91+
description='Does things to KEPs')
92+
PARSER.add_argument(
93+
'--keps-dir',
94+
default='../keps',
95+
help='Path to KEPs directoryProw Job Directory')
96+
PARSER.add_argument(
97+
'--force',
98+
default=False,
99+
help='Force rewrite of all KEPs')
100+
ARGS = PARSER.parse_args()
101+
102+
main(ARGS.keps_dir, ARGS.force)
103+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kep-number: 1143
2+
stable:
3+
approver: "@wojtek-t"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kep-number: 2907
2+
stable:
3+
approver: "@johnbelamaric"

keps/prod-readiness/sig-cli/2206.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kep-number: 2206
2+
beta:
3+
approver: "@johnbelamaric"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kep-number: 2539
2+
beta:
3+
approver: "@johnbelamaric"

keps/sig-api-machinery/1152-less-object-serializations/kep.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ replaces:
2121
- n/a
2222
superseded-by:
2323
- n/a
24+
latest-milestone: '0.0'
25+
stage: stable

keps/sig-api-machinery/1623-standardize-conditions/kep.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ approvers:
1717
- "@liggitt"
1818
see-also:
1919
replaces:
20+
latest-milestone: '0.0'
21+
stage: stable

keps/sig-api-machinery/2332-pruning-for-custom-resources/kep.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ status: implemented
2222
see-also:
2323
- "https://github.com/kubernetes/enhancements/pull/1002"
2424
- "/keps/sig-api-machinery/20180415-crds-to-ga.md"
25+
latest-milestone: '0.0'
26+
stage: stable

keps/sig-api-machinery/2335-vanilla-crd-openapi-subset-structural-schemas/kep.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ see-also:
2222
- "/keps/sig-api-machinery/20180415-crds-to-ga.md"
2323
- "https://github.com/kubernetes/enhancements/pull/926"
2424
- "https://github.com/kubernetes/enhancements/pull/709"
25+
latest-milestone: '0.0'
26+
stage: stable

0 commit comments

Comments
 (0)