From 54854a57ce008db5a7a1c2230b297988ef103960 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Wed, 28 Aug 2024 14:42:32 +0200 Subject: [PATCH] Remove announcement-subject.txt from release artifacts The subject is not used anywhere, means we can probably remove it. Signed-off-by: Sascha Grunert --- cmd/krel/cmd/announce_build.go | 17 +++-------------- pkg/anago/anago.go | 3 --- pkg/anago/release.go | 5 ++--- pkg/announce/announce.go | 11 ++--------- pkg/announce/announcefakes/fake_impl.go | 18 ++++++++---------- pkg/announce/impl.go | 18 ++---------------- pkg/announce/options.go | 4 ++-- 7 files changed, 19 insertions(+), 57 deletions(-) diff --git a/cmd/krel/cmd/announce_build.go b/cmd/krel/cmd/announce_build.go index 2c3f44df220..8073702eec1 100644 --- a/cmd/krel/cmd/announce_build.go +++ b/cmd/krel/cmd/announce_build.go @@ -29,8 +29,6 @@ import ( "github.com/spf13/cobra" "sigs.k8s.io/release-utils/command" - - "k8s.io/release/pkg/announce" ) const ( @@ -181,8 +179,7 @@ func runBuildBranchAnnounce(opts *buildBranchAnnounceOptions, buildOpts *buildAn return fmt.Errorf("generating the announcement html file: %w", err) } - announcementSubject := fmt.Sprintf("Kubernetes %s branch has been created", opts.branch) - return buildOpts.saveAnnouncement(announcementSubject, announcement) + return buildOpts.saveAnnouncement(announcement) } // runBuildReleaseAnnounce build the announcement file when creating a new Kubernetes release. @@ -227,12 +224,10 @@ func runBuildReleaseAnnounce(opts *buildReleaseAnnounceOptions, buildOpts *build return fmt.Errorf("generating the announcement html file: %w", err) } - announcementSubject := fmt.Sprintf("Kubernetes %s is live!", announceOpts.tag) - - return buildOpts.saveAnnouncement(announcementSubject, announcement) + return buildOpts.saveAnnouncement(announcement) } -func (opts *buildAnnounceOptions) saveAnnouncement(announcementSubject string, announcement bytes.Buffer) error { +func (opts *buildAnnounceOptions) saveAnnouncement(announcement bytes.Buffer) error { logrus.Info("Creating announcement files") absOutputPath := filepath.Join(opts.workDir, "announcement.html") @@ -242,12 +237,6 @@ func (opts *buildAnnounceOptions) saveAnnouncement(announcementSubject string, a return fmt.Errorf("saving announcement.html: %w", err) } - absOutputPath = filepath.Join(opts.workDir, announce.SubjectFile) - logrus.Infof("Writing announcement subject to %s", absOutputPath) - err = os.WriteFile(absOutputPath, []byte(announcementSubject), os.FileMode(0o644)) - if err != nil { - return fmt.Errorf("saving announcement-subject.txt: %w", err) - } logrus.Info("Kubernetes Announcement created.") return nil } diff --git a/pkg/anago/anago.go b/pkg/anago/anago.go index ec1ef05ebbc..acace0369ce 100644 --- a/pkg/anago/anago.go +++ b/pkg/anago/anago.go @@ -55,9 +55,6 @@ const ( // announcementHTMLFile is the file containing the release announcement in HTML format. announcementHTMLFile = workspaceDir + "/src/" + announce.AnnouncementFile - // announcementSubjectFile is the file containing the release announcement subject. - announcementSubjectFile = workspaceDir + "/src/" + announce.SubjectFile - // The default license for all artifacts. LicenseIdentifier = "Apache-2.0" ) diff --git a/pkg/anago/release.go b/pkg/anago/release.go index 53884a874c1..81911124f2b 100644 --- a/pkg/anago/release.go +++ b/pkg/anago/release.go @@ -432,9 +432,8 @@ func (d *DefaultRelease) PushArtifacts() error { ) for from, to := range map[string]string{ - releaseNotesJSONFile: gcsReleaseNotesPath, - announcementHTMLFile: gcsReleaseRootPath + fmt.Sprintf("/%s/%s", d.state.versions.Prime(), announce.AnnouncementFile), - announcementSubjectFile: gcsReleaseRootPath + fmt.Sprintf("/%s/%s", d.state.versions.Prime(), announce.SubjectFile), + releaseNotesJSONFile: gcsReleaseNotesPath, + announcementHTMLFile: gcsReleaseRootPath + fmt.Sprintf("/%s/%s", d.state.versions.Prime(), announce.AnnouncementFile), } { if err := d.impl.CopyToRemote( objStore, diff --git a/pkg/announce/announce.go b/pkg/announce/announce.go index f7492e33721..9a67032066d 100644 --- a/pkg/announce/announce.go +++ b/pkg/announce/announce.go @@ -24,13 +24,8 @@ import ( "github.com/sirupsen/logrus" ) -const ( - // AnnouncementFile is the default announcement HTML file. - AnnouncementFile = "announcement.html" - - // SubjectFile is the default subject file for the announcement. - SubjectFile = "announcement-subject.txt" -) +// AnnouncementFile is the default announcement HTML file. +const AnnouncementFile = "announcement.html" const branchAnnouncement = `Kubernetes Community,

@@ -92,7 +87,6 @@ func (a *Announce) CreateForBranch() error { if err := a.impl.Create( a.options.workDir, - fmt.Sprintf("Kubernetes %s branch has been created", a.options.branch), fmt.Sprintf(branchAnnouncement, a.options.branch), ); err != nil { return fmt.Errorf("creating branch announcement: %w", err) @@ -139,7 +133,6 @@ func (a *Announce) CreateForRelease() error { if err := a.impl.Create( a.options.workDir, - fmt.Sprintf("Kubernetes %s is live!", a.options.tag), fmt.Sprintf(releaseAnnouncement, a.options.tag, goVersion, a.options.changelogPath, filepath.Base(a.options.changelogPath), a.options.tag, changelog, diff --git a/pkg/announce/announcefakes/fake_impl.go b/pkg/announce/announcefakes/fake_impl.go index 3eed2b9712c..26ec52899d4 100644 --- a/pkg/announce/announcefakes/fake_impl.go +++ b/pkg/announce/announcefakes/fake_impl.go @@ -22,12 +22,11 @@ import ( ) type FakeImpl struct { - CreateStub func(string, string, string) error + CreateStub func(string, string) error createMutex sync.RWMutex createArgsForCall []struct { arg1 string arg2 string - arg3 string } createReturns struct { result1 error @@ -65,20 +64,19 @@ type FakeImpl struct { invocationsMutex sync.RWMutex } -func (fake *FakeImpl) Create(arg1 string, arg2 string, arg3 string) error { +func (fake *FakeImpl) Create(arg1 string, arg2 string) error { fake.createMutex.Lock() ret, specificReturn := fake.createReturnsOnCall[len(fake.createArgsForCall)] fake.createArgsForCall = append(fake.createArgsForCall, struct { arg1 string arg2 string - arg3 string - }{arg1, arg2, arg3}) + }{arg1, arg2}) stub := fake.CreateStub fakeReturns := fake.createReturns - fake.recordInvocation("Create", []interface{}{arg1, arg2, arg3}) + fake.recordInvocation("Create", []interface{}{arg1, arg2}) fake.createMutex.Unlock() if stub != nil { - return stub(arg1, arg2, arg3) + return stub(arg1, arg2) } if specificReturn { return ret.result1 @@ -92,17 +90,17 @@ func (fake *FakeImpl) CreateCallCount() int { return len(fake.createArgsForCall) } -func (fake *FakeImpl) CreateCalls(stub func(string, string, string) error) { +func (fake *FakeImpl) CreateCalls(stub func(string, string) error) { fake.createMutex.Lock() defer fake.createMutex.Unlock() fake.CreateStub = stub } -func (fake *FakeImpl) CreateArgsForCall(i int) (string, string, string) { +func (fake *FakeImpl) CreateArgsForCall(i int) (string, string) { fake.createMutex.RLock() defer fake.createMutex.RUnlock() argsForCall := fake.createArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 + return argsForCall.arg1, argsForCall.arg2 } func (fake *FakeImpl) CreateReturns(result1 error) { diff --git a/pkg/announce/impl.go b/pkg/announce/impl.go index fa8fecf899b..fddd19e62b3 100644 --- a/pkg/announce/impl.go +++ b/pkg/announce/impl.go @@ -38,26 +38,12 @@ type defaultImpl struct{} //go:generate /usr/bin/env bash -c "cat ../../hack/boilerplate/boilerplate.generatego.txt announcefakes/fake_impl.go > announcefakes/_fake_impl.go && mv announcefakes/_fake_impl.go announcefakes/fake_impl.go" type impl interface { - Create(workDir, subject, message string) error + Create(workDir, message string) error GetGoVersion(tag string) (string, error) ReadChangelogFile(file string) ([]byte, error) } -func (i *defaultImpl) Create(workDir, subject, message string) error { - subjectFile := filepath.Join(workDir, SubjectFile) - //nolint:gosec // TODO(gosec): G306: Expect WriteFile permissions to be - // 0600 or less - if err := os.WriteFile( - subjectFile, []byte(subject), 0o755, - ); err != nil { - return fmt.Errorf( - "writing subject to file %s: %w", - subjectFile, - err, - ) - } - logrus.Debugf("Wrote file %s", subjectFile) - +func (i *defaultImpl) Create(workDir, message string) error { announcementFile := filepath.Join(workDir, AnnouncementFile) //nolint:gosec // TODO(gosec): G306: Expect WriteFile permissions to be // 0600 or less diff --git a/pkg/announce/options.go b/pkg/announce/options.go index f03e275dabf..de887fd9a77 100644 --- a/pkg/announce/options.go +++ b/pkg/announce/options.go @@ -17,8 +17,8 @@ limitations under the License. package announce type Options struct { - // workDir is the directory where announcement.html and - // announcement-subject.txt will be written + // workDir is the directory where announcement.html + // will be written workDir string // Release tag we will build the announcement for tag string