Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into upstream-auth-token-cache-issue
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
  • Loading branch information
eapolinario committed May 21, 2024
2 parents b012847 + 1884dcf commit 4b4ff17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
| 🗑 As of May-24 we moved the development of this component to [monorepo](https://github.com/flyteorg/flyte). 🗑 |
| - |

<html>
<p align="center">
<img src="https://raw.githubusercontent.com/flyteorg/static-resources/main/common/flyte_circle_gradient_1_4x4.png" alt="Flyte Logo" width="100">
Expand Down
15 changes: 11 additions & 4 deletions pkg/github/githubutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,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 @@ -118,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 @@ -231,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

0 comments on commit 4b4ff17

Please sign in to comment.