Skip to content

Commit

Permalink
Fix flytectl demo start (#5370)
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Apolinario <[email protected]>
Co-authored-by: Eduardo Apolinario <[email protected]>
  • Loading branch information
eapolinario and eapolinario authored May 15, 2024
1 parent 4dd5f3c commit 11fbeca
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
30 changes: 18 additions & 12 deletions flytectl/pkg/github/githubutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions flytectl/pkg/github/githubutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
}

0 comments on commit 11fbeca

Please sign in to comment.