Skip to content

Commit 8c61c8b

Browse files
authored
Merge pull request #4338 from wojtek-t/implementable_has_milestones
Improve validation for KEP metadata
2 parents b646eea + b20a9d8 commit 8c61c8b

File tree

6 files changed

+34
-16
lines changed

6 files changed

+34
-16
lines changed

Diff for: keps/sig-auth/2907-secrets-store-csi-driver/kep.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ approvers:
1515
- "@mikedanese"
1616
status: implemented
1717
stage: stable
18+
19+
latest-milestone: "v1.19"
20+
21+
# The milestone at which this feature was, or is targeted to be, at each stage.
22+
milestone:
23+
stable: "v1.22"

Diff for: keps/sig-etcd/4326-downgrade/4326.yaml renamed to keps/sig-etcd/4326-downgrade/kep.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kep-number: 4326
33
authors:
44
- "@serathius"
55
owning-sig: sig-etcd
6-
status: implementable
6+
status: provisional
77
creation-date: yyyy-mm-dd
88
reviewers:
99
approvers:

Diff for: keps/sig-etcd/4331-livez-readyz/4331.yaml renamed to keps/sig-etcd/4331-livez-readyz/kep.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ authors:
44
- "@siyuanfoundation"
55
- "@chaochn47"
66
owning-sig: sig-etcd
7-
status: implementable
7+
status: provisional
88
creation-date: yyyy-mm-dd
99
reviewers:
1010
approvers:

Diff for: keps/sig-network/2829-gateway-api-to-k8s-io/kep.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ approvers:
1717

1818
# The target maturity stage in the current dev cycle for this KEP.
1919
stage: alpha
20+
21+
# This is out-of-tree and we provide milestone just to pass validation.
22+
latest-milestone: "v1.22"

Diff for: pkg/kepval/approval.go

+13-14
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
)
3131

3232
func ValidatePRR(kep *api.Proposal, h *api.PRRHandler, prrDir string) error {
33-
requiredPRRApproval, _, _, err := isPRRRequired(kep)
33+
requiredPRRApproval, err := isPRRRequired(kep)
3434
if err != nil {
3535
return errors.Wrap(err, "checking if PRR is required")
3636
}
@@ -97,38 +97,37 @@ func ValidatePRR(kep *api.Proposal, h *api.PRRHandler, prrDir string) error {
9797
return nil
9898
}
9999

100-
func isPRRRequired(kep *api.Proposal) (required, missingMilestone, missingStage bool, err error) {
100+
func isPRRRequired(kep *api.Proposal) (required bool, err error) {
101101
logrus.Debug("checking if PRR is required")
102102

103103
required = kep.Status == api.ImplementableStatus || kep.Status == api.ImplementedStatus
104-
missingMilestone = kep.IsMissingMilestone()
105-
missingStage = kep.IsMissingStage()
104+
if !required {
105+
return false, nil
106+
}
106107

107-
if missingMilestone {
108-
logrus.Warnf("Missing the latest milestone field: %s", kep.Filename)
109-
return required, missingMilestone, missingStage, nil
108+
if kep.IsMissingMilestone() {
109+
return required, fmt.Errorf("missing the latest milestone field: %s", kep.Filename)
110110
}
111111

112-
if missingStage {
113-
logrus.Warnf("Missing the stage field: %s", kep.Filename)
114-
return required, missingMilestone, missingStage, nil
112+
if kep.IsMissingStage() {
113+
return required, fmt.Errorf("missing the stage field: %s", kep.Filename)
115114
}
116115

117116
// TODO: Consider making this a function
118117
prrRequiredAtSemVer, err := semver.ParseTolerant("v1.21")
119118
if err != nil {
120-
return required, missingMilestone, missingStage, errors.Wrap(err, "creating a SemVer object for PRRs")
119+
return required, errors.Wrap(err, "creating a SemVer object for PRRs")
121120
}
122121

123122
latestSemVer, err := semver.ParseTolerant(kep.LatestMilestone)
124123
if err != nil {
125-
return required, missingMilestone, missingStage, errors.Wrap(err, "creating a SemVer object for latest milestone")
124+
return required, errors.Wrap(err, "creating a SemVer object for latest milestone")
126125
}
127126

128127
if latestSemVer.LT(prrRequiredAtSemVer) {
129128
required = false
130-
return required, missingMilestone, missingStage, nil
129+
return required, nil
131130
}
132131

133-
return required, missingMilestone, missingStage, nil
132+
return required, nil
134133
}

Diff for: pkg/repo/validate.go

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package repo
1818

1919
import (
20+
"fmt"
2021
"os"
2122
"path/filepath"
2223

@@ -63,6 +64,7 @@ func (r *Repo) Validate() (
6364

6465
metadataFilename := ProposalMetadataFilename
6566
metadataFilepath := filepath.Join(dir, metadataFilename)
67+
6668
if _, err := os.Stat(metadataFilepath); err == nil {
6769
// There is KEP metadata file in this directory, only that one should be processed.
6870
if info.Name() == metadataFilename {
@@ -71,6 +73,14 @@ func (r *Repo) Validate() (
7173
}
7274
}
7375

76+
if info.Name() == ProposalFilename && dir != kepDir {
77+
// There is a proposal, we require metadata file for it.
78+
if _, err := os.Stat(metadataFilepath); os.IsNotExist(err) {
79+
kepErr := fmt.Errorf("metadata file missing for KEP: %s", metadataFilepath)
80+
valErrMap[metadataFilepath] = append(valErrMap[metadataFilepath], kepErr)
81+
}
82+
}
83+
7484
return nil
7585
},
7686
)

0 commit comments

Comments
 (0)