From 2af98b510b3a8e06dc698b7cbc7718e7ca6d7ce5 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Wed, 11 Mar 2020 14:33:28 +0100 Subject: [PATCH] Add krel announce subcommand We now add a new krel subcommand which re-uses the already implemented sendgrid code from the `patch` package. This code has been moved into a new package `mail`, which will be now used by the patch announcer and `krel announce`. Signed-off-by: Sascha Grunert --- BUILD.bazel | 2 + cmd/krel/cmd/BUILD.bazel | 2 + cmd/krel/cmd/announce.go | 185 ++++++++++++++++++ pkg/mail/BUILD.bazel | 43 ++++ .../internal/mail_sender.go => mail/mail.go} | 28 ++- .../mail_sender_test.go => mail/mail_test.go} | 30 +-- pkg/mail/mailfakes/BUILD.bazel | 27 +++ .../mailfakes}/fake_sendgrid_client.go | 20 +- pkg/patch/BUILD.bazel | 3 +- pkg/patch/announce.go | 7 +- pkg/patch/announce_test.go | 2 +- pkg/patch/internal/BUILD.bazel | 9 +- pkg/patch/internal/formatter_test.go | 2 +- pkg/patch/internal/internalfakes/BUILD.bazel | 3 - pkg/patch/internal/release_notes_test.go | 2 +- pkg/patch/internal/workspace_test.go | 2 +- pkg/release/release.go | 2 +- pkg/{patch/internal => }/testing/BUILD.bazel | 4 +- pkg/{patch/internal => }/testing/testing.go | 0 19 files changed, 321 insertions(+), 52 deletions(-) create mode 100644 cmd/krel/cmd/announce.go create mode 100644 pkg/mail/BUILD.bazel rename pkg/{patch/internal/mail_sender.go => mail/mail.go} (78%) rename pkg/{patch/internal/mail_sender_test.go => mail/mail_test.go} (85%) create mode 100644 pkg/mail/mailfakes/BUILD.bazel rename pkg/{patch/internal/internalfakes => mail/mailfakes}/fake_sendgrid_client.go (85%) rename pkg/{patch/internal => }/testing/BUILD.bazel (80%) rename pkg/{patch/internal => }/testing/testing.go (100%) diff --git a/BUILD.bazel b/BUILD.bazel index e941c9456c1..316955d7a93 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -41,10 +41,12 @@ filegroup( "//pkg/http:all-srcs", "//pkg/kubepkg:all-srcs", "//pkg/log:all-srcs", + "//pkg/mail:all-srcs", "//pkg/notes:all-srcs", "//pkg/patch:all-srcs", "//pkg/release:all-srcs", "//pkg/testgrid:all-srcs", + "//pkg/testing:all-srcs", "//pkg/util:all-srcs", "//pkg/version:all-srcs", ], diff --git a/cmd/krel/cmd/BUILD.bazel b/cmd/krel/cmd/BUILD.bazel index 91d7058f8c7..81b2b4d8dc0 100644 --- a/cmd/krel/cmd/BUILD.bazel +++ b/cmd/krel/cmd/BUILD.bazel @@ -4,6 +4,7 @@ go_library( name = "go_default_library", srcs = [ "anago.go", + "announce.go", "changelog.go", "ff.go", "gcbmgr.go", @@ -24,6 +25,7 @@ go_library( "//pkg/github:go_default_library", "//pkg/http:go_default_library", "//pkg/log:go_default_library", + "//pkg/mail:go_default_library", "//pkg/notes:go_default_library", "//pkg/notes/document:go_default_library", "//pkg/notes/options:go_default_library", diff --git a/cmd/krel/cmd/announce.go b/cmd/krel/cmd/announce.go new file mode 100644 index 00000000000..928d4e85ff4 --- /dev/null +++ b/cmd/krel/cmd/announce.go @@ -0,0 +1,185 @@ +/* +Copyright 2020 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cmd + +import ( + "fmt" + + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + + "k8s.io/release/pkg/http" + "k8s.io/release/pkg/mail" + "k8s.io/release/pkg/release" + "k8s.io/release/pkg/util" +) + +const ( + sendgridAPIKeyFlag = "sendgrid-api-key" + sendgridAPIKeyEnvKey = "SENDGRID_API_KEY" + nameFlag = "name" + emailFlag = "email" + tagFlag = "tag" +) + +// announceCmd represents the subcommand for `krel announce` +var announceCmd = &cobra.Command{ + Use: "announce", + Short: "Announce Kubernetes releases", + Long: fmt.Sprintf(`krel announce + +krel announce can be used to announce already built Kubernetes releases to the +%q and %q Google Group. + +If --nomock=true (the default), then the mail will be sent only to a test +Google Group %q. + +It is necessary to either set a valid --%s,-s or export the +$%s environment variable. An API key can be created by +registering a sendgrid.com account and adding the key here: + +https://app.sendgrid.com/settings/api_keys + +Beside this, the flags for a valid sender name (--%s,-n), sender email +address (--%s,-e) and a valid Kubernetes tag (--%s,-t) have to be set +as well.`, + mail.KubernetesAnnounceGoogleGroup, + mail.KubernetesDevGoogleGroup, + mail.KubernetesAnnounceTestGoogleGroup, + sendgridAPIKeyFlag, + sendgridAPIKeyEnvKey, + nameFlag, + emailFlag, + tagFlag, + ), + SilenceUsage: true, + SilenceErrors: true, + RunE: func(cmd *cobra.Command, args []string) error { + return runAnnounce(announceOpts, rootOpts) + }, +} + +type announceOptions struct { + sendgridAPIKey string + name string + email string + tag string +} + +var announceOpts = &announceOptions{} + +func init() { + announceCmd.PersistentFlags().StringVarP( + &announceOpts.sendgridAPIKey, + sendgridAPIKeyFlag, + "s", + util.EnvDefault(sendgridAPIKeyEnvKey, ""), + fmt.Sprintf( + "API key for sendgrid, can be set via %s too", + sendgridAPIKeyEnvKey, + ), + ) + + announceCmd.PersistentFlags().StringVarP( + &announceOpts.name, + nameFlag, + "n", + "", + "mail sender name", + ) + if err := announceCmd.MarkPersistentFlagRequired(nameFlag); err != nil { + logrus.Fatal(err) + } + + announceCmd.PersistentFlags().StringVarP( + &announceOpts.email, + emailFlag, + "e", + "", + "email address", + ) + if err := announceCmd.MarkPersistentFlagRequired(emailFlag); err != nil { + logrus.Fatal(err) + } + + announceCmd.PersistentFlags().StringVarP( + &announceOpts.tag, + tagFlag, + "t", + "", + "built tag to be announced, will be used for fetching the "+ + "announcement from the google cloud bucket", + ) + if err := announceCmd.MarkPersistentFlagRequired(tagFlag); err != nil { + logrus.Fatal(err) + } + + rootCmd.AddCommand(announceCmd) +} + +func runAnnounce(opts *announceOptions, rootOpts *rootOptions) error { + if opts.sendgridAPIKey == "" { + return errors.Errorf( + "Neither --sendgrid-api-key,-s nor $%s is set", sendgridAPIKeyEnvKey, + ) + } + + logrus.Info("Retrieving release announcement from Google Cloud Bucket") + + tag := util.AddTagPrefix(opts.tag) + u := fmt.Sprintf( + "%s/archive/anago-%s/announcement.html", + release.URLPrefixForBucket(release.ProductionBucket), tag, + ) + logrus.Infof("Using announcement remote URL: %s", u) + + content, err := http.GetURLResponse(u, false) + if err != nil { + return errors.Wrapf(err, + "unable to retrieve release announcement form url: %s", u, + ) + } + + logrus.Info("Preparing mail sender") + m := mail.Sender{APIKey: opts.sendgridAPIKey} + + if err := m.SetSender(opts.name, opts.email); err != nil { + return errors.Wrap(err, "unable to set mail sender") + } + + groups := []mail.GoogleGroup{mail.KubernetesAnnounceTestGoogleGroup} + if rootOpts.nomock { + groups = []mail.GoogleGroup{ + mail.KubernetesAnnounceGoogleGroup, + mail.KubernetesDevGoogleGroup, + } + } + logrus.Infof("Using Google Groups as announcement target: %v", groups) + + if err := m.SetGoogleGroupRecipients(groups...); err != nil { + return errors.Wrap(err, "unable to set mail recipients") + } + + logrus.Info("Sending mail") + subject := fmt.Sprintf("Kubernetes %s is live!", tag) + if err := m.Send(content, subject); err != nil { + return errors.Wrap(err, "unable to send mail") + } + + return nil +} diff --git a/pkg/mail/BUILD.bazel b/pkg/mail/BUILD.bazel new file mode 100644 index 00000000000..5bdd0f85cef --- /dev/null +++ b/pkg/mail/BUILD.bazel @@ -0,0 +1,43 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["mail.go"], + importpath = "k8s.io/release/pkg/mail", + visibility = ["//visibility:public"], + deps = [ + "//pkg/log:go_default_library", + "@com_github_sendgrid_rest//:go_default_library", + "@com_github_sendgrid_sendgrid_go//:go_default_library", + "@com_github_sendgrid_sendgrid_go//helpers/mail:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["mail_test.go"], + embed = [":go_default_library"], + deps = [ + "//pkg/mail/mailfakes:go_default_library", + "//pkg/testing:go_default_library", + "@com_github_sendgrid_rest//:go_default_library", + "@com_github_stretchr_testify//require:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//pkg/mail/mailfakes:all-srcs", + ], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/patch/internal/mail_sender.go b/pkg/mail/mail.go similarity index 78% rename from pkg/patch/internal/mail_sender.go rename to pkg/mail/mail.go index 686864ba76d..ec978a66cb3 100644 --- a/pkg/patch/internal/mail_sender.go +++ b/pkg/mail/mail.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package internal +package mail import ( "fmt" @@ -25,7 +25,16 @@ import ( "k8s.io/release/pkg/log" ) -type MailSender struct { +// GoogleGroup is a simple google group representation +type GoogleGroup string + +const ( + KubernetesAnnounceGoogleGroup GoogleGroup = "kubernetes-announce" + KubernetesDevGoogleGroup GoogleGroup = "kubernetes-dev" + KubernetesAnnounceTestGoogleGroup GoogleGroup = "kubernetes-announce-test" +) + +type Sender struct { log.Mixin SendgridClientCreator SendgridClientCreator @@ -55,7 +64,7 @@ var defaultSendgridClientCreator = func(apiKey string) SendgridClient { return sendgrid.NewSendClient(apiKey) } -func (m *MailSender) Send(body, subject string) error { +func (m *Sender) Send(body, subject string) error { html := mail.NewContent("text/html", body) p := mail.NewPersonalization() @@ -95,7 +104,7 @@ func (e *SendError) Error() string { return fmt.Sprintf("got code %d while sending: Body: %q, Header: %q", e.code, e.resBody, e.resHeaders) } -func (m *MailSender) SetSender(name, email string) error { +func (m *Sender) SetSender(name, email string) error { if email == "" { return fmt.Errorf("email must not be empty") } @@ -104,7 +113,7 @@ func (m *MailSender) SetSender(name, email string) error { return nil } -func (m *MailSender) SetRecipients(recipientArgs ...string) error { +func (m *Sender) SetRecipients(recipientArgs ...string) error { l := len(recipientArgs) if l%2 != 0 { @@ -127,3 +136,12 @@ func (m *MailSender) SetRecipients(recipientArgs ...string) error { return nil } + +// SetGoogleGroupRecipient can be used to set multiple Google Groups as recipient +func (m *Sender) SetGoogleGroupRecipients(groups ...GoogleGroup) error { + args := []string{} + for _, group := range groups { + args = append(args, string(group), fmt.Sprintf("%s@googlegroups.com", group)) + } + return m.SetRecipients(args...) +} diff --git a/pkg/patch/internal/mail_sender_test.go b/pkg/mail/mail_test.go similarity index 85% rename from pkg/patch/internal/mail_sender_test.go rename to pkg/mail/mail_test.go index b631d973f81..fad3c141884 100644 --- a/pkg/patch/internal/mail_sender_test.go +++ b/pkg/mail/mail_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package internal_test +package mail_test import ( "fmt" @@ -22,9 +22,9 @@ import ( "github.com/sendgrid/rest" "github.com/stretchr/testify/require" - "k8s.io/release/pkg/patch/internal" - "k8s.io/release/pkg/patch/internal/internalfakes" - it "k8s.io/release/pkg/patch/internal/testing" + "k8s.io/release/pkg/mail" + "k8s.io/release/pkg/mail/mailfakes" + it "k8s.io/release/pkg/testing" ) func TestMailSender(t *testing.T) { @@ -35,9 +35,9 @@ func TestMailSender(t *testing.T) { it.Run(t, "Send", testSend) it.Run(t, "main", func(t *testing.T) { - m := &internal.MailSender{ - SendgridClientCreator: func(_ string) internal.SendgridClient { - c := &internalfakes.FakeSendgridClient{} + m := &mail.Sender{ + SendgridClientCreator: func(_ string) mail.SendgridClient { + c := &mailfakes.FakeSendgridClient{} c.SendReturns(&rest.Response{ Body: "some API response", StatusCode: 202, @@ -84,14 +84,14 @@ func testSend(t *testing.T) { tc := tc it.Run(t, name, func(t *testing.T) { - m := &internal.MailSender{ + m := &mail.Sender{ APIKey: tc.apiKey, } - sgClient := &internalfakes.FakeSendgridClient{} + sgClient := &mailfakes.FakeSendgridClient{} sgClient.SendReturns(tc.sendgridSendResponse, tc.sendgridSendErr) - m.SendgridClientCreator = func(apiKey string) internal.SendgridClient { + m.SendgridClientCreator = func(apiKey string) mail.SendgridClient { require.Equal(t, tc.expectedSendgridAPIKey, apiKey, "SendgridClient#creator arg") return sgClient } @@ -101,9 +101,9 @@ func testSend(t *testing.T) { require.Equal(t, 1, sgClient.SendCallCount(), "SendgridClient#Send call count") - mail := sgClient.SendArgsForCall(0) - require.Equalf(t, tc.subject, mail.Subject, "the mail's subject") - require.Equalf(t, tc.message, mail.Content[0].Value, "the mail's body") + email := sgClient.SendArgsForCall(0) + require.Equalf(t, tc.subject, email.Subject, "the mail's subject") + require.Equalf(t, tc.message, email.Content[0].Value, "the mail's body") }) } } @@ -132,7 +132,7 @@ func testSender(t *testing.T) { for name, tc := range tests { tc := tc it.Run(t, name, func(t *testing.T) { - m := &internal.MailSender{} + m := &mail.Sender{} err := m.SetSender(tc.senderName, tc.senderEmail) it.CheckErr(t, err, tc.expectedErr) }) @@ -173,7 +173,7 @@ func testRecipient(t *testing.T) { it.Run(t, name, func(t *testing.T) { for _, args := range tc.recipientArgs { it.Run(t, "", func(t *testing.T) { - m := &internal.MailSender{} + m := &mail.Sender{} err := m.SetRecipients(args...) it.CheckErr(t, err, tc.expectedErr) }) diff --git a/pkg/mail/mailfakes/BUILD.bazel b/pkg/mail/mailfakes/BUILD.bazel new file mode 100644 index 00000000000..8696cb0c202 --- /dev/null +++ b/pkg/mail/mailfakes/BUILD.bazel @@ -0,0 +1,27 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["fake_sendgrid_client.go"], + importpath = "k8s.io/release/pkg/mail/mailfakes", + visibility = ["//visibility:public"], + deps = [ + "//pkg/mail:go_default_library", + "@com_github_sendgrid_rest//:go_default_library", + "@com_github_sendgrid_sendgrid_go//helpers/mail:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/patch/internal/internalfakes/fake_sendgrid_client.go b/pkg/mail/mailfakes/fake_sendgrid_client.go similarity index 85% rename from pkg/patch/internal/internalfakes/fake_sendgrid_client.go rename to pkg/mail/mailfakes/fake_sendgrid_client.go index 4f40db599cc..c995fbb58d3 100644 --- a/pkg/patch/internal/internalfakes/fake_sendgrid_client.go +++ b/pkg/mail/mailfakes/fake_sendgrid_client.go @@ -15,21 +15,21 @@ limitations under the License. */ // Code generated by counterfeiter. DO NOT EDIT. -package internalfakes +package mailfakes import ( "sync" "github.com/sendgrid/rest" - "github.com/sendgrid/sendgrid-go/helpers/mail" - "k8s.io/release/pkg/patch/internal" + maila "github.com/sendgrid/sendgrid-go/helpers/mail" + "k8s.io/release/pkg/mail" ) type FakeSendgridClient struct { - SendStub func(*mail.SGMailV3) (*rest.Response, error) + SendStub func(*maila.SGMailV3) (*rest.Response, error) sendMutex sync.RWMutex sendArgsForCall []struct { - arg1 *mail.SGMailV3 + arg1 *maila.SGMailV3 } sendReturns struct { result1 *rest.Response @@ -43,11 +43,11 @@ type FakeSendgridClient struct { invocationsMutex sync.RWMutex } -func (fake *FakeSendgridClient) Send(arg1 *mail.SGMailV3) (*rest.Response, error) { +func (fake *FakeSendgridClient) Send(arg1 *maila.SGMailV3) (*rest.Response, error) { fake.sendMutex.Lock() ret, specificReturn := fake.sendReturnsOnCall[len(fake.sendArgsForCall)] fake.sendArgsForCall = append(fake.sendArgsForCall, struct { - arg1 *mail.SGMailV3 + arg1 *maila.SGMailV3 }{arg1}) fake.recordInvocation("Send", []interface{}{arg1}) fake.sendMutex.Unlock() @@ -67,13 +67,13 @@ func (fake *FakeSendgridClient) SendCallCount() int { return len(fake.sendArgsForCall) } -func (fake *FakeSendgridClient) SendCalls(stub func(*mail.SGMailV3) (*rest.Response, error)) { +func (fake *FakeSendgridClient) SendCalls(stub func(*maila.SGMailV3) (*rest.Response, error)) { fake.sendMutex.Lock() defer fake.sendMutex.Unlock() fake.SendStub = stub } -func (fake *FakeSendgridClient) SendArgsForCall(i int) *mail.SGMailV3 { +func (fake *FakeSendgridClient) SendArgsForCall(i int) *maila.SGMailV3 { fake.sendMutex.RLock() defer fake.sendMutex.RUnlock() argsForCall := fake.sendArgsForCall[i] @@ -130,4 +130,4 @@ func (fake *FakeSendgridClient) recordInvocation(key string, args []interface{}) fake.invocations[key] = append(fake.invocations[key], args) } -var _ internal.SendgridClient = new(FakeSendgridClient) +var _ mail.SendgridClient = new(FakeSendgridClient) diff --git a/pkg/patch/BUILD.bazel b/pkg/patch/BUILD.bazel index 8c1f5a1f1c0..887ebf3e1a6 100644 --- a/pkg/patch/BUILD.bazel +++ b/pkg/patch/BUILD.bazel @@ -10,6 +10,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/log:go_default_library", + "//pkg/mail:go_default_library", "//pkg/patch/internal:go_default_library", ], ) @@ -20,7 +21,7 @@ go_test( embed = [":go_default_library"], deps = [ "//pkg/patch/internal/internalfakes:go_default_library", - "//pkg/patch/internal/testing:go_default_library", + "//pkg/testing:go_default_library", "@com_github_stretchr_testify//require:go_default_library", ], ) diff --git a/pkg/patch/announce.go b/pkg/patch/announce.go index 5b7683877b8..225cb6377bf 100644 --- a/pkg/patch/announce.go +++ b/pkg/patch/announce.go @@ -24,6 +24,7 @@ import ( "time" "k8s.io/release/pkg/log" + "k8s.io/release/pkg/mail" "k8s.io/release/pkg/patch/internal" ) @@ -239,9 +240,9 @@ func (a *Announcer) formatAsHTML(title string, parts ...string) (string, error) return html, nil } -func (a *Announcer) sendMail(mail, subject string) error { +func (a *Announcer) sendMail(content, subject string) error { if a.MailSender == nil { - ms := &internal.MailSender{ + ms := &mail.Sender{ APIKey: a.Opts.SendgridAPIKey, } ms.SetLogger(a.Logger(), "mail-sender") @@ -263,7 +264,7 @@ func (a *Announcer) sendMail(mail, subject string) error { } a.Logger().Debug("calling the mail sender") - return a.MailSender.Send(mail, subject) + return a.MailSender.Send(content, subject) } func (a *Announcer) getReleaseNotes() (string, error) { diff --git a/pkg/patch/announce_test.go b/pkg/patch/announce_test.go index 269e7bdbff5..95f7f8c7e09 100644 --- a/pkg/patch/announce_test.go +++ b/pkg/patch/announce_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "k8s.io/release/pkg/patch" "k8s.io/release/pkg/patch/internal/internalfakes" - it "k8s.io/release/pkg/patch/internal/testing" + it "k8s.io/release/pkg/testing" ) type opts = patch.AnnounceOptions diff --git a/pkg/patch/internal/BUILD.bazel b/pkg/patch/internal/BUILD.bazel index f54086852d0..5d14d8f4940 100644 --- a/pkg/patch/internal/BUILD.bazel +++ b/pkg/patch/internal/BUILD.bazel @@ -5,7 +5,6 @@ go_library( srcs = [ "exec.go", "formatter.go", - "mail_sender.go", "release_notes.go", "workspace.go", ], @@ -13,9 +12,6 @@ go_library( visibility = ["//pkg/patch:__subpackages__"], deps = [ "//pkg/log:go_default_library", - "@com_github_sendgrid_rest//:go_default_library", - "@com_github_sendgrid_sendgrid_go//:go_default_library", - "@com_github_sendgrid_sendgrid_go//helpers/mail:go_default_library", "@io_k8s_utils//exec:go_default_library", ], ) @@ -24,7 +20,6 @@ go_test( name = "go_default_test", srcs = [ "formatter_test.go", - "mail_sender_test.go", "release_notes_test.go", "workspace_test.go", ], @@ -32,8 +27,7 @@ go_test( deps = [ "//pkg/github:go_default_library", "//pkg/patch/internal/internalfakes:go_default_library", - "//pkg/patch/internal/testing:go_default_library", - "@com_github_sendgrid_rest//:go_default_library", + "//pkg/testing:go_default_library", "@com_github_stretchr_testify//require:go_default_library", "@io_k8s_utils//exec:go_default_library", ], @@ -51,7 +45,6 @@ filegroup( srcs = [ ":package-srcs", "//pkg/patch/internal/internalfakes:all-srcs", - "//pkg/patch/internal/testing:all-srcs", ], tags = ["automanaged"], visibility = ["//visibility:public"], diff --git a/pkg/patch/internal/formatter_test.go b/pkg/patch/internal/formatter_test.go index bfc8c2f64d7..1f3d42de9b3 100644 --- a/pkg/patch/internal/formatter_test.go +++ b/pkg/patch/internal/formatter_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "k8s.io/release/pkg/patch/internal" "k8s.io/release/pkg/patch/internal/internalfakes" - it "k8s.io/release/pkg/patch/internal/testing" + it "k8s.io/release/pkg/testing" "k8s.io/utils/exec" ) diff --git a/pkg/patch/internal/internalfakes/BUILD.bazel b/pkg/patch/internal/internalfakes/BUILD.bazel index 6c53f5a0e37..d6895cb4b16 100644 --- a/pkg/patch/internal/internalfakes/BUILD.bazel +++ b/pkg/patch/internal/internalfakes/BUILD.bazel @@ -7,7 +7,6 @@ go_library( "fake_formatter.go", "fake_mail_sender.go", "fake_release_noter.go", - "fake_sendgrid_client.go", "fake_workspace.go", ], importpath = "k8s.io/release/pkg/patch/internal/internalfakes", @@ -15,8 +14,6 @@ go_library( deps = [ "//pkg/patch:go_default_library", "//pkg/patch/internal:go_default_library", - "@com_github_sendgrid_rest//:go_default_library", - "@com_github_sendgrid_sendgrid_go//helpers/mail:go_default_library", ], ) diff --git a/pkg/patch/internal/release_notes_test.go b/pkg/patch/internal/release_notes_test.go index 67e42a65afe..d6168f9ce05 100644 --- a/pkg/patch/internal/release_notes_test.go +++ b/pkg/patch/internal/release_notes_test.go @@ -26,7 +26,7 @@ import ( "k8s.io/release/pkg/github" "k8s.io/release/pkg/patch/internal" "k8s.io/release/pkg/patch/internal/internalfakes" - it "k8s.io/release/pkg/patch/internal/testing" + it "k8s.io/release/pkg/testing" "k8s.io/utils/exec" ) diff --git a/pkg/patch/internal/workspace_test.go b/pkg/patch/internal/workspace_test.go index ce8fc8ada4c..400fd92cfd3 100644 --- a/pkg/patch/internal/workspace_test.go +++ b/pkg/patch/internal/workspace_test.go @@ -23,7 +23,7 @@ import ( "github.com/stretchr/testify/require" "k8s.io/release/pkg/patch/internal" "k8s.io/release/pkg/patch/internal/internalfakes" - it "k8s.io/release/pkg/patch/internal/testing" + it "k8s.io/release/pkg/testing" "k8s.io/utils/exec" ) diff --git a/pkg/release/release.go b/pkg/release/release.go index 4f7f42549c8..2267c69d95c 100644 --- a/pkg/release/release.go +++ b/pkg/release/release.go @@ -190,7 +190,7 @@ func GetKubecrossVersion(branches ...string) (string, error) { // URLPrefixForBucket returns the URL prefix for the provided bucket string func URLPrefixForBucket(bucket string) string { - urlPrefix := fmt.Sprintf("https://storage.googleapis.com/%s/release", bucket) + urlPrefix := fmt.Sprintf("https://storage.googleapis.com/%s", bucket) if bucket == ProductionBucket { urlPrefix = ProductionBucketURL } diff --git a/pkg/patch/internal/testing/BUILD.bazel b/pkg/testing/BUILD.bazel similarity index 80% rename from pkg/patch/internal/testing/BUILD.bazel rename to pkg/testing/BUILD.bazel index 3ced3b97592..eb0050099a5 100644 --- a/pkg/patch/internal/testing/BUILD.bazel +++ b/pkg/testing/BUILD.bazel @@ -3,8 +3,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", srcs = ["testing.go"], - importpath = "k8s.io/release/pkg/patch/internal/testing", - visibility = ["//pkg/patch:__subpackages__"], + importpath = "k8s.io/release/pkg/testing", + visibility = ["//visibility:public"], deps = ["@com_github_stretchr_testify//require:go_default_library"], ) diff --git a/pkg/patch/internal/testing/testing.go b/pkg/testing/testing.go similarity index 100% rename from pkg/patch/internal/testing/testing.go rename to pkg/testing/testing.go