@@ -17,13 +17,13 @@ limitations under the License.
17
17
package kepval
18
18
19
19
import (
20
+ "errors"
20
21
"fmt"
21
22
"os"
22
23
"path/filepath"
23
24
"strings"
24
25
25
26
"github.com/blang/semver/v4"
26
- "github.com/pkg/errors"
27
27
"github.com/sirupsen/logrus"
28
28
29
29
"k8s.io/enhancements/api"
@@ -32,7 +32,7 @@ import (
32
32
func ValidatePRR (kep * api.Proposal , h * api.PRRHandler , prrDir string ) error {
33
33
requiredPRRApproval , err := isPRRRequired (kep )
34
34
if err != nil {
35
- return errors . Wrap ( err , "checking if PRR is required" )
35
+ return fmt . Errorf ( "checking if PRR is required: %w" , err )
36
36
}
37
37
38
38
if ! requiredPRRApproval {
@@ -55,24 +55,24 @@ func ValidatePRR(kep *api.Proposal, h *api.PRRHandler, prrDir string) error {
55
55
}
56
56
57
57
if err != nil {
58
- return errors . Wrapf ( err , "could not open file %s" , prrFilepath )
58
+ return fmt . Errorf ( "could not open file %s: %w " , prrFilepath , err )
59
59
}
60
60
61
61
// TODO: Create a context to hold the parsers
62
62
prr , prrParseErr := h .Parse (prrFile )
63
63
if prrParseErr != nil {
64
- return errors . Wrap ( prrParseErr , "parsing PRR approval file" )
64
+ return fmt . Errorf ( "parsing PRR approval file: %w" , prrParseErr )
65
65
}
66
66
67
67
// TODO: This shouldn't be required once we push the errors into the
68
68
// parser struct
69
69
if prr .Error != nil {
70
- return errors . Wrapf ( prr . Error , "%v has an error" , prrFilepath )
70
+ return fmt . Errorf ( "%v has an error: %w " , prrFilepath , prr . Error )
71
71
}
72
72
73
73
stagePRRApprover , err := prr .ApproverForStage (kep .Stage )
74
74
if err != nil {
75
- return errors . Wrapf ( err , "getting PRR approver for %s stage" , kep .Stage )
75
+ return fmt . Errorf ( "getting PRR approver for %s stage: %w " , kep .Stage , err )
76
76
}
77
77
78
78
if stagePRRApprover == "" {
@@ -85,13 +85,7 @@ func ValidatePRR(kep *api.Proposal, h *api.PRRHandler, prrDir string) error {
85
85
86
86
validApprover := api .IsOneOf (stagePRRApprover , h .PRRApprovers )
87
87
if ! validApprover {
88
- return errors .New (
89
- fmt .Sprintf (
90
- "this contributor (%s) is not a PRR approver (%v)" ,
91
- stagePRRApprover ,
92
- h .PRRApprovers ,
93
- ),
94
- )
88
+ return fmt .Errorf ("this contributor (%s) is not a PRR approver (%v)" , stagePRRApprover , h .PRRApprovers )
95
89
}
96
90
97
91
return nil
@@ -116,12 +110,12 @@ func isPRRRequired(kep *api.Proposal) (required bool, err error) {
116
110
// TODO: Consider making this a function
117
111
prrRequiredAtSemVer , err := semver .ParseTolerant ("v1.21" )
118
112
if err != nil {
119
- return required , errors . Wrap ( err , "creating a SemVer object for PRRs" )
113
+ return required , fmt . Errorf ( "creating a SemVer object for PRRs: %w" , err )
120
114
}
121
115
122
116
latestSemVer , err := semver .ParseTolerant (kep .LatestMilestone )
123
117
if err != nil {
124
- return required , errors . Wrap ( err , "creating a SemVer object for latest milestone" )
118
+ return required , fmt . Errorf ( "creating a SemVer object for latest milestone: %w" , err )
125
119
}
126
120
127
121
if latestSemVer .LT (prrRequiredAtSemVer ) {
0 commit comments