Skip to content

Commit 6803980

Browse files
committed
kepval: Temporarily skip PRR approval validation if "stage" is missing
Signed-off-by: Stephen Augustus <[email protected]>
1 parent 183d079 commit 6803980

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

api/proposal.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ func (p *Proposal) IsMissingMilestone() bool {
8787
return false
8888
}
8989

90+
func (p *Proposal) IsMissingStage() bool {
91+
if p.Stage == "" {
92+
return true
93+
}
94+
95+
return false
96+
}
97+
9098
type KEPHandler Parser
9199

92100
// TODO(api): Make this a generic parser for all `Document` types

pkg/kepval/approval.go

Lines changed: 18 additions & 8 deletions
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
}
@@ -91,39 +91,49 @@ func ValidatePRR(kep *api.Proposal, h *api.PRRHandler, prrDir string) error {
9191
return nil
9292
}
9393

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

9797
required = true
9898
missingMilestone = kep.IsMissingMilestone()
99+
missingStage = kep.IsMissingStage()
99100

100101
if kep.Status != "implementable" {
101102
required = false
102-
return required, missingMilestone, nil
103+
return required, missingMilestone, missingStage, nil
103104
}
104105

105106
if missingMilestone {
106107
required = false
108+
// TODO: Make this a specialized error
107109
logrus.Warnf("KEP %s is missing the latest milestone field. This will become a validation error in future releases.", kep.Number)
108110

109-
return required, missingMilestone, nil
111+
return required, missingMilestone, missingStage, nil
112+
}
113+
114+
if missingStage {
115+
required = false
116+
// TODO: Make this a specialized error
117+
logrus.Warnf("KEP %s is missing the stage field. This will become a validation error in future releases.", kep.Number)
118+
119+
return required, missingMilestone, missingStage, nil
110120
}
111121

112122
// TODO: Consider making this a function
113123
prrRequiredAtSemVer, err := semver.ParseTolerant("v1.21")
114124
if err != nil {
115-
return required, missingMilestone, errors.Wrap(err, "creating a SemVer object for PRRs")
125+
return required, missingMilestone, missingStage, errors.Wrap(err, "creating a SemVer object for PRRs")
116126
}
117127

118128
latestSemVer, err := semver.ParseTolerant(kep.LatestMilestone)
119129
if err != nil {
120-
return required, missingMilestone, errors.Wrap(err, "creating a SemVer object for latest milestone")
130+
return required, missingMilestone, missingStage, errors.Wrap(err, "creating a SemVer object for latest milestone")
121131
}
122132

123133
if latestSemVer.LT(prrRequiredAtSemVer) {
124134
required = false
125-
return required, missingMilestone, nil
135+
return required, missingMilestone, missingStage, nil
126136
}
127137

128-
return required, missingMilestone, nil
138+
return required, missingMilestone, missingStage, nil
129139
}

0 commit comments

Comments
 (0)