Skip to content

Commit

Permalink
Fix upgrade and version check (openshift#60)
Browse files Browse the repository at this point in the history
* Upgrade fix

Fix versioning

* Fix versioning

* Fix tests
  • Loading branch information
Supreeth Basabattini authored Mar 30, 2023
1 parent ba926a0 commit d802596
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 21 deletions.
8 changes: 4 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ builds:
goarch:
- amd64
- arm64
ldflags:
# The "-X" go flag sets the Version
- -X github.com/openshift/backplane-cli/pkg/info.Version={{.Version}}
main: ./cmd/ocm-backplane/
binary: ocm-backplane

archives:
- replacements:
darwin: Darwin
linux: Linux
amd64: x86_64
- name_template: '{{ .ProjectName }}_{{- .Version }}_{{- title .Os }}_{{- if eq .Arch "amd64" }}x86_64{{- else }}{{ .Arch }}{{ end}}'

checksum:
name_template: "checksums.txt"
Expand Down
2 changes: 1 addition & 1 deletion cmd/ocm-backplane/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
var VersionCmd = &cobra.Command{
Use: "version",
Short: "Prints the version",
Long: `Prints the version number of the client.`,
Long: `Prints the version number of Backplane CLI`,
RunE: runVersion,
}

Expand Down
4 changes: 3 additions & 1 deletion internal/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (

const (
gitHubApiEndPoint = "https://api.github.com/repos/openshift/backplane-cli"
assetTemplateName = "backplane-cli_%s_%s_%s.tar.gz" // version, GOOS, GOARCH
assetTemplateName = "ocm-backplane_%s_%s_%s.tar.gz" // version, GOOS, GOARCH
)

func NewClient(opts ...ClientOption) *Client {
Expand Down Expand Up @@ -194,6 +194,8 @@ func mapArch(goarch string) string {
switch goarch {
case "amd64":
return "x86_64"
case "arm64":
return "arm64"
default:
return goarch
}
Expand Down
20 changes: 10 additions & 10 deletions internal/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ func TestFindAssetURL(t *testing.T) {
TagName: "v0.0.1",
Assets: []upgrade.ReleaseAsset{
{
Name: "backplane-cli_0.0.1_Darwin_arm64.tar.gz",
DownloadUrl: "https://github.com/openshift/backplane-cli/releases/download/v0.0.1/backplane-cli_0.0.1_Darwin_arm64.tar.gz",
Name: "ocm-backplane_0.0.1_Darwin_arm64.tar.gz",
DownloadUrl: "https://github.com/openshift/backplane-cli/releases/download/v0.0.1/ocm-backplane_0.0.1_Darwin_arm64.tar.gz",
},
},
},
Expand All @@ -97,15 +97,15 @@ func TestFindAssetURL(t *testing.T) {
OSArch: "arm64",
},
match: true,
ExpectedAsert: "https://github.com/openshift/backplane-cli/releases/download/v0.0.1/backplane-cli_0.0.1_Darwin_arm64.tar.gz",
ExpectedAsert: "https://github.com/openshift/backplane-cli/releases/download/v0.0.1/ocm-backplane_0.0.1_Darwin_arm64.tar.gz",
},
"check matching asert for Linux": {
LatestRelease: upgrade.Release{
TagName: "v0.0.1",
Assets: []upgrade.ReleaseAsset{
{
Name: "backplane-cli_0.0.1_Linux_arm64.tar.gz",
DownloadUrl: "https://github.com/openshift/backplane-cli/releases/download/v0.0.1/backplane-cli_0.0.1_Linux_arm64.tar.gz",
Name: "ocm-backplane_0.0.1_Linux_arm64.tar.gz",
DownloadUrl: "https://github.com/openshift/backplane-cli/releases/download/v0.0.1/ocm-backplane_0.0.1_Linux_arm64.tar.gz",
},
},
},
Expand All @@ -114,19 +114,19 @@ func TestFindAssetURL(t *testing.T) {
OSArch: "arm64",
},
match: true,
ExpectedAsert: "https://github.com/openshift/backplane-cli/releases/download/v0.0.1/backplane-cli_0.0.1_Linux_arm64.tar.gz",
ExpectedAsert: "https://github.com/openshift/backplane-cli/releases/download/v0.0.1/ocm-backplane_0.0.1_Linux_arm64.tar.gz",
},
"check asert for unsupported OS ": {
LatestRelease: upgrade.Release{
TagName: "v0.0.1",
Assets: []upgrade.ReleaseAsset{
{
Name: "backplane-cli_0.0.1_Linux_arm64.tar.gz",
DownloadUrl: "https://github.com/openshift/backplane-cli/releases/download/v0.0.1/backplane-cli_0.0.1_Linux_arm64.tar.gz",
Name: "ocm-backplane_0.0.1_Linux_arm64.tar.gz",
DownloadUrl: "https://github.com/openshift/backplane-cli/releases/download/v0.0.1/ocm-backplane_0.0.1_Linux_arm64.tar.gz",
},
{
Name: "backplane-cli_0.0.1_Darwin_arm64.tar.gz",
DownloadUrl: "https://github.com/openshift/backplane-cli/releases/download/v0.0.1/backplane-cli_0.0.1_Darwin_arm64.tar.gz",
Name: "ocm-backplane_0.0.1_Darwin_arm64.tar.gz",
DownloadUrl: "https://github.com/openshift/backplane-cli/releases/download/v0.0.1/ocm-backplane_0.0.1_Darwin_arm64.tar.gz",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (c *CmdConfig) Default() {
}

if c.BinaryName == "" {
c.BinaryName = "backplane-cli"
c.BinaryName = "ocm-backplane"
}

if c.Org == "" {
Expand Down
11 changes: 7 additions & 4 deletions pkg/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import (
)

const (
// Version of the backplane-cli
Version = "0.0.0"

BACKPLANE_URL_ENV_NAME = "BACKPLANE_URL"
BACKPLANE_PROXY_ENV_NAME = "HTTPS_PROXY"
BACKPLANE_CONFIG_PATH_ENV_NAME = "BACKPLANE_CONFIG"
Expand All @@ -28,4 +25,10 @@ const (
GitHubHost = "github.com"
)

var UpstreamREADMETagged = fmt.Sprintf(UpstreamREADMETemplate, Version)
var (
// Version of the backplane-cli
// This will be set via Goreleaser during the build process
Version string

UpstreamREADMETagged = fmt.Sprintf(UpstreamREADMETemplate, Version)
)

0 comments on commit d802596

Please sign in to comment.