diff --git a/flytectl/pkg/github/githubutil.go b/flytectl/pkg/github/githubutil.go index f6216245d0..e439df44f8 100644 --- a/flytectl/pkg/github/githubutil.go +++ b/flytectl/pkg/github/githubutil.go @@ -27,14 +27,13 @@ const ( flyte = "flyte" flytectl = "flytectl" sandboxSupportedVersion = "v0.10.0" - // TODO - change this to the monorepo name after we have a successful release - flytectlRepository = "github.com/flyteorg/flytectl" - commonMessage = "\n A new release of flytectl is available: %s → %s \n" - brewMessage = "To upgrade, run: brew update && brew upgrade flytectl \n" - linuxMessage = "To upgrade, run: flytectl upgrade \n" - darwinMessage = "To upgrade, run: flytectl upgrade \n" - releaseURL = "https://github.com/flyteorg/flyte/flytectl/releases/tag/%s \n" - brewInstallDirectory = "/Cellar/flytectl" + flytectlRepository = "github.com/flyteorg/flyte" + commonMessage = "\n A new release of flytectl is available: %s → %s \n" + brewMessage = "To upgrade, run: brew update && brew upgrade flytectl \n" + linuxMessage = "To upgrade, run: flytectl upgrade \n" + darwinMessage = "To upgrade, run: flytectl upgrade \n" + releaseURL = "https://github.com/flyteorg/flyte/releases/tag/%s \n" + brewInstallDirectory = "/Cellar/flytectl" ) var Client GHRepoService @@ -73,14 +72,20 @@ func GetLatestRelease(repoName string, g GHRepoService) (*github.RepositoryRelea } // ListReleases returns the list of release of provided repoName -func ListReleases(repoName string, g GHRepoService) ([]*github.RepositoryRelease, error) { +func ListReleases(repoName string, g GHRepoService, filterPrefix string) ([]*github.RepositoryRelease, error) { releases, _, err := g.ListReleases(context.Background(), owner, repoName, &github.ListOptions{ PerPage: 100, }) if err != nil { return nil, err } - return releases, err + var filteredReleases []*github.RepositoryRelease + for _, release := range releases { + if !strings.HasPrefix(release.GetTagName(), filterPrefix) { + filteredReleases = append(filteredReleases, release) + } + } + return filteredReleases, err } // GetReleaseByTag returns the provided tag release if tag exist in repository @@ -119,7 +124,8 @@ func GetAssetFromRelease(tag, assetName, repoName string, g GHRepoService) (*git func GetSandboxImageSha(tag string, pre bool, g GHRepoService) (string, string, error) { var release *github.RepositoryRelease if len(tag) == 0 { - releases, err := ListReleases(flyte, g) + // Only fetch Flyte releases + releases, err := ListReleases(flyte, g, "flytectl/") if err != nil { return "", release.GetTagName(), err } @@ -232,7 +238,7 @@ func GetGHRepoService() GHRepoService { gh = github.NewClient(oauth2.NewClient(context.Background(), oauth2.StaticTokenSource( &oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")}, ))) - if _, err := ListReleases(flyte, gh.Repositories); err != nil { + if _, err := ListReleases(flyte, gh.Repositories, ""); err != nil { logger.Warnf(context.Background(), "Found GITHUB_TOKEN but failed to fetch releases. Using empty http.Client: %s.", err) gh = nil } diff --git a/flytectl/pkg/github/githubutil_test.go b/flytectl/pkg/github/githubutil_test.go index 4f69aacfef..bd4001faa6 100644 --- a/flytectl/pkg/github/githubutil_test.go +++ b/flytectl/pkg/github/githubutil_test.go @@ -181,7 +181,7 @@ func TestGetUpgradeMessage(t *testing.T) { stdlibversion.Version = "v0.2.10" message, err := GetUpgradeMessage(version, darwin) assert.Nil(t, err) - assert.Equal(t, 163, len(message)) + assert.Equal(t, 154, len(message)) version = "v0.2.09" message, err = GetUpgradeMessage(version, darwin) @@ -196,10 +196,10 @@ func TestGetUpgradeMessage(t *testing.T) { version = "v0.2.20" message, err = GetUpgradeMessage(version, windows) assert.Nil(t, err) - assert.Equal(t, 163, len(message)) + assert.Equal(t, 154, len(message)) version = "v0.2.20" message, err = GetUpgradeMessage(version, linux) assert.Nil(t, err) - assert.Equal(t, 163, len(message)) + assert.Equal(t, 154, len(message)) }