Skip to content

Commit 51bd5dd

Browse files
committed
update code
Signed-off-by: cpanato <[email protected]>
1 parent 1ea122e commit 51bd5dd

File tree

2 files changed

+41
-43
lines changed

2 files changed

+41
-43
lines changed

cmd/patch-release-notify/cmd/root.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package cmd
1919
import (
2020
"bytes"
2121
"embed"
22+
"errors"
2223
"fmt"
2324
"html/template"
2425
"io"
@@ -29,7 +30,6 @@ import (
2930
"strings"
3031
"time"
3132

32-
"github.com/pkg/errors"
3333
"github.com/sirupsen/logrus"
3434
"github.com/spf13/cobra"
3535

@@ -159,26 +159,26 @@ func initLogging(*cobra.Command, []string) error {
159159

160160
func run(opts *options) error {
161161
if err := opts.SetAndValidate(); err != nil {
162-
return errors.Wrap(err, "validating schedule-path options")
162+
return fmt.Errorf("validating schedule-path options: %w", err)
163163
}
164164

165165
if opts.sendgridAPIKey == "" {
166-
return errors.Errorf(
166+
return fmt.Errorf(
167167
"$%s is not set", sendgridAPIKeyEnvKey,
168168
)
169169
}
170170

171171
data, err := loadFileOrURL(opts.schedulePath)
172172
if err != nil {
173-
return errors.Wrap(err, "failed to read the file")
173+
return fmt.Errorf("failed to read the file: %w", err)
174174
}
175175

176176
patchSchedule := &model.PatchSchedule{}
177177

178178
logrus.Info("Parsing the schedule...")
179179

180180
if err := yaml.UnmarshalStrict(data, &patchSchedule); err != nil {
181-
return errors.Wrap(err, "failed to decode the file")
181+
return fmt.Errorf("failed to decode the file: %w", err)
182182
}
183183

184184
output := &Template{}
@@ -188,7 +188,7 @@ func run(opts *options) error {
188188
for _, patch := range patchSchedule.Schedules {
189189
t, err := time.Parse(layout, patch.CherryPickDeadline)
190190
if err != nil {
191-
return errors.Wrap(err, "parsing schedule time")
191+
return fmt.Errorf("parsing schedule time: %w", err)
192192
}
193193

194194
currentTime := time.Now().UTC()
@@ -205,13 +205,13 @@ func run(opts *options) error {
205205

206206
tmpl, err := template.ParseFS(tpls, "templates/email.tmpl")
207207
if err != nil {
208-
return errors.Wrap(err, "parsing template")
208+
return fmt.Errorf("parsing template: %w", err)
209209
}
210210

211211
var tmplBytes bytes.Buffer
212212
err = tmpl.Execute(&tmplBytes, output)
213213
if err != nil {
214-
return errors.Wrap(err, "parsing values to the template")
214+
return fmt.Errorf("parsing values to the template: %w", err)
215215
}
216216

217217
if shouldSendEmail {
@@ -225,12 +225,12 @@ func run(opts *options) error {
225225

226226
if opts.name != "" && opts.email != "" {
227227
if err := m.SetSender(opts.name, opts.email); err != nil {
228-
return errors.Wrap(err, "unable to set mail sender")
228+
return fmt.Errorf("unable to set mail sender: %w", err)
229229
}
230230
} else {
231231
logrus.Info("Retrieving default sender from sendgrid API")
232232
if err := m.SetDefaultSender(); err != nil {
233-
return errors.Wrap(err, "setting default sender")
233+
return fmt.Errorf("setting default sender: %w", err)
234234
}
235235
}
236236

@@ -243,14 +243,14 @@ func run(opts *options) error {
243243
logrus.Infof("Using Google Groups as announcement target: %v", groups)
244244

245245
if err := m.SetGoogleGroupRecipients(groups...); err != nil {
246-
return errors.Wrap(err, "unable to set mail recipients")
246+
return fmt.Errorf("unable to set mail recipients: %w", err)
247247
}
248248

249249
logrus.Info("Sending mail")
250250
subject := "[Please Read] Patch Releases cherry-pick deadline"
251251

252252
if err := m.Send(tmplBytes.String(), subject); err != nil {
253-
return errors.Wrap(err, "unable to send mail")
253+
return fmt.Errorf("unable to send mail: %w", err)
254254
}
255255
} else {
256256
logrus.Info("No email is needed to send")
@@ -264,7 +264,7 @@ func (o *options) SetAndValidate() error {
264264
logrus.Info("Validating schedule-path options...")
265265

266266
if o.schedulePath == "" {
267-
return errors.Errorf("need to set the schedule-path")
267+
return errors.New("need to set the schedule-path")
268268
}
269269

270270
return nil
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
1-
Hello Kubernetes Community!
2-
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<p>Hello Kubernetes Community!</p>
35
{{range .Releases}}
4-
The cherry-pick deadline for the {{ .Release }} branches is {{ .CherryPickDeadline }} EOD PT.
6+
<p>The cherry-pick deadline for the <b>{{ .Release }}</b> branches is <b>{{ .CherryPickDeadline }} EOD PT.</b></p>
57
{{end}}
6-
7-
Here are some quick links to search for cherry-pick PRs:
8-
8+
<br><p>Here are some quick links to search for cherry-pick PRs:</p>
99
{{range .Releases}}
10-
- release-{{ .Release }}: https://github.com/kubernetes/kubernetes/pulls?q=is%3Apr+is%3Aopen+base%3Arelease-{{ .Release }}+label%3Ado-not-merge%2Fcherry-pick-not-approved
10+
<p> - release-{{ .Release }}: https://github.com/kubernetes/kubernetes/pulls?q=is%3Apr+is%3Aopen+base%3Arelease-{{ .Release }}+label%3Ado-not-merge%2Fcherry-pick-not-approved</p>
1111
{{end}}
12-
13-
14-
For PRs that you intend to land for the upcoming patch sets, please
15-
ensure they have:
16-
- a release note in the PR description
17-
- /sig
18-
- /kind
19-
- /priority
20-
- /lgtm
21-
- /approve
22-
- passing tests
23-
24-
Details on the cherry-pick process can be found here:
25-
https://git.k8s.io/community/contributors/devel/sig-release/cherry-picks.md
26-
27-
We keep general info and up-to-date timelines for patch releases here:
28-
https://kubernetes.io/releases/patch-releases/#upcoming-monthly-releases
29-
30-
If you have any questions for the Release Managers, please feel free to
31-
reach out to us at #release-management (Kubernetes Slack) or [email protected]
32-
33-
We wish everyone a happy and safe week!
34-
SIG-Release Team
12+
<br>
13+
<p>For PRs that you intend to land for the upcoming patch sets, please
14+
ensure they have:</p>
15+
<p> - a release note in the PR description</p>
16+
<p> - /sig</p>
17+
<p> - /kind</p>
18+
<p> - /priority</p>
19+
<p> - /lgtm</p>
20+
<p> - /approve</p>
21+
<p> - passing tests</p>
22+
<br>
23+
<p>Details on the cherry-pick process can be found here:</p>
24+
<p>https://git.k8s.io/community/contributors/devel/sig-release/cherry-picks.md</p>
25+
<p>We keep general info and up-to-date timelines for patch releases here:</p>
26+
<p>https://kubernetes.io/releases/patch-releases/#upcoming-monthly-releases</p>
27+
<p>If you have any questions for the Release Managers, please feel free to
28+
reach out to us at #release-management (Kubernetes Slack) or [email protected]</p><br>
29+
<p>We wish everyone a happy and safe week!</p>
30+
<p>SIG-Release Team</p>
31+
</body>
32+
</html>

0 commit comments

Comments
 (0)