Skip to content

Commit

Permalink
fix operator version for hashrelease (#9696)
Browse files Browse the repository at this point in the history
* fix operator version for hashrelease

* use product version instead of release name

+ rename calico version data struct to specify it is for hashrelease

* rename Data -> Versions and CalicoVersionData -> HashreleaseVersions
  • Loading branch information
radTuti authored Jan 10, 2025
1 parent c9931c1 commit ca80474
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions release/internal/pinnedversion/pinnedversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var noImageComponents = []string{
}

type PinnedVersions interface {
GenerateFile() (version.Data, error)
GenerateFile() (version.Versions, error)
ManagerOptions() ([]calico.Option, error)
}

Expand Down Expand Up @@ -125,7 +125,7 @@ type CalicoPinnedVersions struct {
}

// GenerateFile generates the pinned version file.
func (p *CalicoPinnedVersions) GenerateFile() (version.Data, error) {
func (p *CalicoPinnedVersions) GenerateFile() (version.Versions, error) {
pinnedVersionPath := pinnedVersionFilePath(p.Dir)

productBranch, err := utils.GitBranch(p.RootDir)
Expand All @@ -147,7 +147,7 @@ func (p *CalicoPinnedVersions) GenerateFile() (version.Data, error) {
if err != nil {
return nil, err
}
versionData := version.NewVersionData(version.New(productVer), operatorVer)
versionData := version.NewHashreleaseVersions(version.New(productVer), operatorVer)
tmpl, err := template.New("pinnedversion").Parse(calicoTemplate)
if err != nil {
return nil, err
Expand Down Expand Up @@ -303,11 +303,11 @@ func RetrieveImageComponents(outputDir string) (map[string]registry.Component, e
return components, nil
}

func RetrieveVersions(outputDir string) (version.Data, error) {
func RetrieveVersions(outputDir string) (version.Versions, error) {
pinnedVersion, err := retrievePinnedVersion(outputDir)
if err != nil {
return nil, err
}

return version.NewVersionData(version.New(pinnedVersion.Title), pinnedVersion.TigeraOperator.Version), nil
return version.NewHashreleaseVersions(version.New(pinnedVersion.Title), pinnedVersion.TigeraOperator.Version), nil
}
24 changes: 12 additions & 12 deletions release/internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,45 +27,45 @@ import (
"github.com/projectcalico/calico/release/internal/utils"
)

// Data is the interface that provides version data for a release.
type Data interface {
// Versions is the interface that provides version data for a hashrelease or release.
type Versions interface {
Hash() string
ProductVersion() string
OperatorVersion() string
HelmChartVersion() string
ReleaseBranch(releaseBranchPrefix string) string
}

func NewVersionData(calico Version, operator string) Data {
return &CalicoVersionData{
func NewHashreleaseVersions(calico Version, operator string) Versions {
return &HashreleaseVersions{
calico: calico,
operator: operator,
}
}

// CalicoVersionData provides version data for a Calico release.
type CalicoVersionData struct {
// HashreleaseVersions implements the Versions interface for a hashrelease.
type HashreleaseVersions struct {
calico Version
operator string
}

func (v *CalicoVersionData) ProductVersion() string {
func (v *HashreleaseVersions) ProductVersion() string {
return v.calico.FormattedString()
}

func (v *CalicoVersionData) OperatorVersion() string {
return v.operator
func (v *HashreleaseVersions) OperatorVersion() string {
return fmt.Sprintf("%s-%s", v.operator, v.ProductVersion())
}

func (v *CalicoVersionData) HelmChartVersion() string {
func (v *HashreleaseVersions) HelmChartVersion() string {
return v.calico.FormattedString()
}

func (v *CalicoVersionData) Hash() string {
func (v *HashreleaseVersions) Hash() string {
return fmt.Sprintf("%s-%s", v.calico.FormattedString(), v.operator)
}

func (v *CalicoVersionData) ReleaseBranch(releaseBranchPrefix string) string {
func (v *HashreleaseVersions) ReleaseBranch(releaseBranchPrefix string) string {
return fmt.Sprintf("%s-%s", releaseBranchPrefix, v.calico.Stream())
}

Expand Down

0 comments on commit ca80474

Please sign in to comment.