Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove announcement-subject.txt from release artifacts #3731

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions cmd/krel/cmd/announce_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import (
"github.com/spf13/cobra"

"sigs.k8s.io/release-utils/command"

"k8s.io/release/pkg/announce"
)

const (
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand All @@ -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
}
Expand Down
3 changes: 0 additions & 3 deletions pkg/anago/anago.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
5 changes: 2 additions & 3 deletions pkg/anago/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 2 additions & 9 deletions pkg/announce/announce.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
<p>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 8 additions & 10 deletions pkg/announce/announcefakes/fake_impl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 2 additions & 16 deletions pkg/announce/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/announce/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down