Skip to content

Commit

Permalink
use constant instead of ldflag
Browse files Browse the repository at this point in the history
  • Loading branch information
radTuti committed Jan 13, 2025
1 parent c6b293b commit f5029d4
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 37 deletions.
6 changes: 0 additions & 6 deletions release/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ PACKAGE_NAME = github.com/projectcalico/calico/release

include ../lib.Makefile

# The name of the product.
# Either "Calico" or "Calico Enterprise"
PRODUCT_NAME=Calico

export ORGANIZATION
export GIT_REPO
export GIT_REPO_SLUG
export DEV_REGISTRIES
export OPERATOR_BRANCH

LDFLAGS= -X $(PACKAGE_NAME)/pkg/buildinfo.ProductName='$(PRODUCT_NAME)'

.PHONY: build
build: bin/release

Expand Down
3 changes: 1 addition & 2 deletions release/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

"github.com/projectcalico/calico/release/internal/command"
"github.com/projectcalico/calico/release/internal/utils"
"github.com/projectcalico/calico/release/pkg/buildinfo"
"github.com/projectcalico/calico/release/pkg/tasks"
)

Expand Down Expand Up @@ -70,7 +69,7 @@ func main() {

app := &cli.App{
Name: "release",
Usage: fmt.Sprintf("release tool for %s", buildinfo.ProductName),
Usage: fmt.Sprintf("release tool for %s", utils.ProductName),
Flags: globalFlags,
Commands: Commands(cfg),
EnableBashCompletion: true,
Expand Down
3 changes: 1 addition & 2 deletions release/internal/outputs/releasenotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (

"github.com/projectcalico/calico/release/internal/utils"
"github.com/projectcalico/calico/release/internal/version"
"github.com/projectcalico/calico/release/pkg/buildinfo"
)

const (
Expand Down Expand Up @@ -198,7 +197,7 @@ func ReleaseNotes(owner, githubToken, repoRootDir, outputDir string, ver version
outputDir = "."
}
logrus.Infof("Generating release notes for %s", ver.FormattedString())
milestone := ver.Milestone(buildinfo.ProductName)
milestone := ver.Milestone(utils.ProductName)
githubClient := github.NewTokenClient(context.Background(), githubToken)
releaseNoteDataList := []*ReleaseNoteIssueData{}
opts := &github.MilestoneListOptions{
Expand Down
10 changes: 6 additions & 4 deletions release/internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

package utils

import "github.com/projectcalico/calico/release/pkg/buildinfo"

var ProductName = buildinfo.ProductName

const (
// ProductName is used in the release process to identify the product.
ProductName = CalicoProductName

// Calico is the product name for projectcalico.
Calico = "calico"

Expand All @@ -31,6 +30,9 @@ const (
// CalicoProductCode is the code for projectcalico.
CalicoProductCode = "os"

// CalicoProductName is the name of the projectcalico product.
CalicoProductName = "Calico"

// ProjectCalicoOrg is the name of the Project Calico organization.
ProjectCalicoOrg = "projectcalico"

Expand Down
3 changes: 1 addition & 2 deletions release/internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"github.com/projectcalico/calico/release/internal/command"
"github.com/projectcalico/calico/release/internal/utils"
"github.com/projectcalico/calico/release/pkg/buildinfo"
)

// Data is the interface that provides version data for a release.
Expand Down Expand Up @@ -98,7 +97,7 @@ func (v *Version) FormattedString() string {
// Milestone returns the GitHub milestone name which corresponds with this version.
func (v *Version) Milestone(prefix string) string {
if prefix == "" {
prefix = buildinfo.ProductName
prefix = utils.ProductName
}
ver := semver.MustParse(string(*v))
return fmt.Sprintf("%s v%d.%d.%d", prefix, ver.Major(), ver.Minor(), ver.Patch())
Expand Down
19 changes: 0 additions & 19 deletions release/pkg/buildinfo/buildinfo.go

This file was deleted.

3 changes: 1 addition & 2 deletions release/pkg/tasks/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ import (
"github.com/projectcalico/calico/release/internal/slack"
"github.com/projectcalico/calico/release/internal/utils"
"github.com/projectcalico/calico/release/internal/version"
"github.com/projectcalico/calico/release/pkg/buildinfo"
errr "github.com/projectcalico/calico/release/pkg/errors"
)

var product = buildinfo.ProductName
var product = utils.ProductName

// SendErrorNotification sends a slack notification for a given error.
// The error type determines the message to send.
Expand Down

0 comments on commit f5029d4

Please sign in to comment.