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
2 people authored and robert-ulbrich-mercedes-benz committed Jul 2, 2024
1 parent 4caeab6 commit 5245e92
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
13 changes: 2 additions & 11 deletions flytectl/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 flytectl/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 5245e92

Please sign in to comment.