Skip to content

Commit

Permalink
Use GetLatestRelease to list latest non-pre-release flytesnacks versi…
Browse files Browse the repository at this point in the history
…on #minor (flyteorg#279)

* Use GetLatestRelease to list latest non-pre-release flytesnacks version

Signed-off-by: Eduardo Apolinario <[email protected]>

* Use GetLatestVersion

Signed-off-by: Eduardo Apolinario <[email protected]>

* Move GetLatestVersion to its original place

Signed-off-by: Eduardo Apolinario <[email protected]>

Co-authored-by: Eduardo Apolinario <[email protected]>
  • Loading branch information
eapolinario and eapolinario authored Feb 16, 2022
1 parent 9f39816 commit fc7e267
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
13 changes: 2 additions & 11 deletions cmd/register/register_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,20 +561,11 @@ func getAllExample(repository, version string) ([]*github.ReleaseAsset, *github.
}
return filterExampleFromRelease(release), release, nil
}
releases, err := githubutil.GetListRelease(repository)
release, err := githubutil.GetLatestVersion(repository)
if err != nil {
return nil, nil, err
}
if len(releases) == 0 {
return nil, nil, fmt.Errorf("repository doesn't have any release")
}
for _, v := range releases {
if !*v.Prerelease {
return filterExampleFromRelease(v), v, nil
}
}
return nil, nil, nil

return filterExampleFromRelease(release), release, nil
}

func getRemoteStoragePath(ctx context.Context, s *storage.DataStore, remoteLocation, file, identifier string) (storage.DataReference, error) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/util/githubutil/githubutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func GetGHClient() *github.Client {
return github.NewClient(&http.Client{})
}

// GetLatestVersion returns the latest version of provided repository
// GetLatestVersion returns the latest non-prerelease version of provided repository, as
// described in https://docs.github.com/en/rest/reference/releases#get-the-latest-release
func GetLatestVersion(repository string) (*github.RepositoryRelease, error) {
client := GetGHClient()
release, _, err := client.Repositories.GetLatestRelease(context.Background(), owner, repository)
Expand Down

0 comments on commit fc7e267

Please sign in to comment.