Skip to content

Commit

Permalink
fix endpoint for tagged releases
Browse files Browse the repository at this point in the history
Signed-off-by: kranurag7 <[email protected]>
  • Loading branch information
kranurag7 committed Jun 8, 2024
1 parent 9d3af45 commit 23b835e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,21 @@ func getReleaseInfo(repoName, tagName string) Release {
}

response := Release{}
err = client.Get(fmt.Sprintf("repos/%s/releases/%s", repoName, tagName), &response)
var url string
if tagName == "latest" {
url = fmt.Sprintf("repos/%s/releases/latest", repoName)
} else {
url = fmt.Sprintf("repos/%s/releases/tags/%s", repoName, tagName)
}

err = client.Get(url, &response)
if err != nil {
fmt.Println(err)
}
return response
}

func renderTable() table.Model {

release := getReleaseInfo(repoName, tagName)

columns := []table.Column{
Expand Down Expand Up @@ -174,7 +180,9 @@ func createTableStyles() table.Styles {

func main() {
flag.StringVar(&repoName, "repo", "kubernetes-sigs/cluster-api", "GitHub repository name")
flag.StringVar(&repoName, "R", "kubernetes-sigs/cluster-api", "GitHub repository name")
flag.StringVar(&tagName, "tag", "latest", "GitHub release tag")
flag.StringVar(&tagName, "t", "latest", "GitHub release tag")
flag.Parse()

m := model{renderTable(), getReleaseInfo(repoName, tagName)}
Expand Down

0 comments on commit 23b835e

Please sign in to comment.