From 943a6ee0465bcb4505dc1b18c97c8070adcb0a8c Mon Sep 17 00:00:00 2001 From: Daniel Mikusa Date: Wed, 7 Jun 2023 21:05:13 -0400 Subject: [PATCH 1/2] Switch to using Azul Metadata API This commit switches from the old Discovery API to using the Metadata API. This also resolves issue https://github.com/paketo-buildpacks/azul-zulu/issues/322. Signed-off-by: Daniel Mikusa --- actions/azul-zulu-dependency/main.go | 39 ++++++++++++++++++---------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/actions/azul-zulu-dependency/main.go b/actions/azul-zulu-dependency/main.go index 9ae5f9cd..76a601a5 100644 --- a/actions/azul-zulu-dependency/main.go +++ b/actions/azul-zulu-dependency/main.go @@ -37,15 +37,25 @@ func main() { panic(fmt.Errorf("version must be specified")) } - uri := fmt.Sprintf("https://api.azul.com/zulu/download/community/v1.0/bundles/latest/"+ - "?arch=x86"+ - "&ext=tar.gz"+ - "&features=%s"+ - "&hw_bitness=64"+ - "&jdk_version=%s"+ - "&os=linux"+ - "&javafx=false", - t, v) + // uri := fmt.Sprintf("https://api.azul.com/zulu/download/community/v1.0/bundles/latest/"+ + // "?arch=x86"+ + // "&ext=tar.gz"+ + // "&features=%s"+ + // "&hw_bitness=64"+ + // "&jdk_version=%s"+ + // "&os=linux"+ + // "&javafx=false", + // t, v) + uri := fmt.Sprintf("https://api.azul.com/metadata/v1/zulu/packages/?"+ + "os=linux-glibc&"+ + "arch=x64&"+ + "archive_type=tar.gz&"+ + "java_package_type=%s&"+ + "javafx_bundled=false&"+ + "crac_supported=false&"+ + "latest=true&"+ + "distro_version=%s&"+ + "release_status=ga", t, v) resp, err := http.Get(uri) if err != nil { @@ -57,13 +67,14 @@ func main() { panic(fmt.Errorf("unable to download %s: %d", uri, resp.StatusCode)) } - var raw Bundle + var raw []Bundle if err := json.NewDecoder(resp.Body).Decode(&raw); err != nil { panic(fmt.Errorf("unable to decode payload\n%w", err)) } - versions := actions.Versions{ - fmt.Sprintf("%d.%d.%d", raw.JDKVersion[0], raw.JDKVersion[1], raw.JDKVersion[2]): raw.URL, + versions := actions.Versions{} + for _, bundle := range raw { + versions[fmt.Sprintf("%d.%d.%d", bundle.JDKVersion[0], bundle.JDKVersion[1], bundle.JDKVersion[2])] = bundle.URL } latestVersion, err := versions.GetLatestVersion(inputs) @@ -88,6 +99,6 @@ func main() { } type Bundle struct { - JDKVersion []int `json:"jdk_version"` - URL string `json:"url"` + JDKVersion []int `json:"java_version"` + URL string `json:"download_url"` } From 20275aeb403324dc8956ee9f1fa2839f5347f393 Mon Sep 17 00:00:00 2001 From: Daniel Mikusa Date: Wed, 7 Jun 2023 21:07:11 -0400 Subject: [PATCH 2/2] Remove comment Signed-off-by: Daniel Mikusa --- actions/azul-zulu-dependency/main.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/actions/azul-zulu-dependency/main.go b/actions/azul-zulu-dependency/main.go index 76a601a5..ddc3b078 100644 --- a/actions/azul-zulu-dependency/main.go +++ b/actions/azul-zulu-dependency/main.go @@ -37,15 +37,6 @@ func main() { panic(fmt.Errorf("version must be specified")) } - // uri := fmt.Sprintf("https://api.azul.com/zulu/download/community/v1.0/bundles/latest/"+ - // "?arch=x86"+ - // "&ext=tar.gz"+ - // "&features=%s"+ - // "&hw_bitness=64"+ - // "&jdk_version=%s"+ - // "&os=linux"+ - // "&javafx=false", - // t, v) uri := fmt.Sprintf("https://api.azul.com/metadata/v1/zulu/packages/?"+ "os=linux-glibc&"+ "arch=x64&"+