Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves integration with Foojay API #446

Merged
merged 1 commit into from
Nov 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions actions/foojay-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ func main() {

func LoadPackages(d string, t string, v int) actions.Versions {
uri := fmt.Sprintf(
"https://api.foojay.io/disco/v2.0/packages?"+
"https://api.foojay.io/disco/v3.0/packages?"+
"distro=%s&"+
"architecture=x64&"+
"archive_type=tar.gz&"+
"package_type=%s&"+
"operating_system=linux",
url.PathEscape(d), t)
"operating_system=linux&"+
"javafx_bundled=false&"+
"version=%d..%%3C%d", // 11..<12
url.PathEscape(d), t, v, v+1)

resp, err := http.Get(uri)
if err != nil {
Expand All @@ -91,12 +93,10 @@ func LoadPackages(d string, t string, v int) actions.Versions {

versions := make(actions.Versions)
for _, result := range raw.Result {
if result.MajorVersion == v {
if ver := re.FindStringSubmatch(result.JavaVersion); ver != nil {
versions[ver[1]] = LoadDownloadURI(result.Links.URI)
} else {
fmt.Println(result.JavaVersion, "failed to parse")
}
if ver := re.FindStringSubmatch(result.JavaVersion); ver != nil {
versions[ver[1]] = LoadDownloadURI(result.Links.URI)
} else {
fmt.Println(result.JavaVersion, "failed to parse")
}
}

Expand Down Expand Up @@ -128,9 +128,8 @@ func LoadDownloadURI(uri string) string {

type PackagesResponse struct {
Result []struct {
MajorVersion int `json:"major_version"`
JavaVersion string `json:"java_version"`
Links struct {
JavaVersion string `json:"java_version"`
Links struct {
URI string `json:"pkg_info_uri"`
}
}
Expand All @@ -140,6 +139,7 @@ type PackagesResponse struct {
type DownloadResponse struct {
Result []struct {
DirectDownloadURI string `json:"direct_download_uri"`
SignatureURI string `json:"signature_uri"`
}
Message string
}