@@ -41,9 +41,8 @@ export async function downloadGraalVMViaGDS(
4141 graalVMVersion : string ,
4242 jdkVersion : string
4343) : Promise < string > {
44- const userAgent = `GraalVMGitHubAction/${ c . ACTION_VERSION } (arch:${ c . GRAALVM_ARCH } ; os:${ c . GRAALVM_PLATFORM } ; jdk:${ jdkVersion } )`
45- const baseArtifact = await fetchArtifact ( userAgent , graalVMVersion , jdkVersion )
46- return downloadArtifact ( gdsToken , userAgent , baseArtifact )
44+ const baseArtifact = await fetchArtifact ( c . GDS_USER_AGENT , graalVMVersion , jdkVersion )
45+ return downloadArtifact ( gdsToken , baseArtifact )
4746}
4847
4948export async function fetchArtifact (
@@ -60,8 +59,7 @@ export async function fetchArtifact(
6059 majorJavaVersion = jdkVersion
6160 }
6261
63- const catalogOS = c . IS_MACOS ? 'macos' : c . GRAALVM_PLATFORM
64- const requestUrl = `${ c . GDS_BASE } /artifacts?productId=${ c . GDS_GRAALVM_PRODUCT_ID } &displayName=Oracle%20GraalVM&metadata=java:jdk${ majorJavaVersion } &metadata=os:${ catalogOS } &metadata=arch:${ c . GRAALVM_ARCH } &metadata=isBase:True&status=PUBLISHED&responseFields=id&responseFields=checksum&responseFields=metadata&sortBy=m:version&sortOrder=DESC`
62+ const requestUrl = c . gdsArtifactQueryUrl ( majorJavaVersion , `${ c . GDS_LATEST_FILTER } &responseFields=metadata` )
6563 core . debug ( `Requesting ${ requestUrl } ` )
6664 const response = await http . get ( requestUrl , { accept : 'application/json' } )
6765 if ( response . message . statusCode !== 200 ) {
@@ -91,79 +89,64 @@ export async function fetchArtifact(
9189// Support for GraalVM EE
9290
9391export async function downloadGraalVMViaGDSByJavaVersion ( gdsToken : string , javaVersion : string ) : Promise < string > {
94- const userAgent = `GraalVMGitHubAction/${ c . ACTION_VERSION } (arch:${ c . GRAALVM_ARCH } ; os:${ c . GRAALVM_PLATFORM } ; java:${ javaVersion } )`
95- const baseArtifact = await fetchArtifactByJavaVersion ( userAgent , 'isBase:True' , javaVersion )
96- return downloadArtifact ( gdsToken , userAgent , baseArtifact )
92+ const baseArtifact = await fetchArtifactByJavaVersion ( c . GDS_USER_AGENT , javaVersion )
93+ return downloadArtifact ( gdsToken , baseArtifact )
9794}
9895
9996export async function downloadGraalVMViaGDSByJavaVersionEELegacy (
10097 gdsToken : string ,
10198 version : string ,
10299 javaVersion : string
103100) : Promise < string > {
104- const userAgent = `GraalVMGitHubAction/${ c . ACTION_VERSION } (arch:${ c . GRAALVM_ARCH } ; os:${ c . GRAALVM_PLATFORM } ; java:${ javaVersion } )`
105- const baseArtifact = await fetchArtifactEE ( userAgent , 'isBase:True' , version , javaVersion )
106- return downloadArtifact ( gdsToken , userAgent , baseArtifact )
101+ const baseArtifact = await fetchArtifactEE ( c . GDS_USER_AGENT , version , javaVersion )
102+ return downloadArtifact ( gdsToken , baseArtifact )
107103}
108104
109- export async function fetchArtifactByJavaVersion (
110- userAgent : string ,
111- metadata : string ,
112- javaVersion : string
113- ) : Promise < GDSArtifact > {
105+ export async function fetchArtifactByJavaVersion ( userAgent : string , javaVersion : string ) : Promise < GDSArtifact > {
114106 const http = new httpClient . HttpClient ( userAgent )
115107
116- let filter
117- if ( javaVersion . includes ( '.' ) ) {
118- filter = `metadata=version:${ javaVersion } `
119- } else {
120- filter = `sortBy=m:java&sortOrder=DESC&limit=1` // latest and only one item
121- }
122-
123108 let majorJavaVersion
124109 if ( semver . valid ( javaVersion ) ) {
125110 majorJavaVersion = semver . major ( javaVersion )
126111 } else {
127112 majorJavaVersion = javaVersion
128113 }
129114
130- const catalogOS = c . IS_MACOS ? 'macos' : c . GRAALVM_PLATFORM
131- const requestUrl = `${ c . GDS_BASE } /artifacts?productId=${ c . GDS_GRAALVM_PRODUCT_ID } &displayName=Oracle%20GraalVM&${ filter } &metadata=java:jdk${ majorJavaVersion } &metadata=os:${ catalogOS } &metadata=arch:${ c . GRAALVM_ARCH } &metadata=${ metadata } &status=PUBLISHED&responseFields=id&responseFields=checksum`
115+ let filter
116+ if ( javaVersion . includes ( '.' ) ) {
117+ filter = `&metadata=version:${ javaVersion } `
118+ } else {
119+ filter = c . GDS_LATEST_FILTER
120+ }
121+
122+ const requestUrl = c . gdsArtifactQueryUrl ( majorJavaVersion , filter )
132123 core . debug ( `Requesting ${ requestUrl } ` )
133124 const response = await http . get ( requestUrl , { accept : 'application/json' } )
134125 if ( response . message . statusCode !== 200 ) {
135- throw new Error (
136- `Unable to find GraalVM for JDK ${ javaVersion } . Are you sure java-version: '${ javaVersion } ' is correct?`
137- )
126+ throw new Error ( `Unable to find GDS artifact. Are you sure java-version: '${ javaVersion } ' is correct?` )
138127 }
139128 const artifactResponse = JSON . parse ( await response . readBody ( ) ) as GDSArtifactsResponse
140129 if ( artifactResponse . items . length !== 1 ) {
141- throw new Error (
142- artifactResponse . items . length > 1
143- ? `Found more than one GDS artifact. ${ c . ERROR_HINT } `
144- : `Unable to find GDS artifact. Are you sure java-version: '${ javaVersion } ' is correct?`
145- )
130+ if ( artifactResponse . items . length > 1 ) {
131+ core . warning ( `Found more than one GDS artifact. ${ c . ERROR_HINT } ` )
132+ } else {
133+ throw new Error ( `Unable to find GDS artifact. Are you sure java-version: '${ javaVersion } ' is correct?` )
134+ }
146135 }
147136 return artifactResponse . items [ 0 ]
148137}
149138
150- export async function fetchArtifactEE (
151- userAgent : string ,
152- metadata : string ,
153- version : string ,
154- javaVersion : string
155- ) : Promise < GDSArtifact > {
139+ export async function fetchArtifactEE ( userAgent : string , version : string , javaVersion : string ) : Promise < GDSArtifact > {
156140 const http = new httpClient . HttpClient ( userAgent )
157141
158142 let filter
159143 if ( version === c . VERSION_LATEST ) {
160- filter = `sortBy=displayName&sortOrder=DESC&limit=1` // latest and only one item
144+ filter = c . GDS_LATEST_FILTER
161145 } else {
162- filter = `metadata=version:${ version } `
146+ filter = `& metadata=version:${ version } `
163147 }
164148
165- const catalogOS = c . IS_MACOS ? 'macos' : c . GRAALVM_PLATFORM
166- const requestUrl = `${ c . GDS_BASE } /artifacts?productId=${ c . GDS_GRAALVM_PRODUCT_ID } &${ filter } &metadata=edition:ee&metadata=java:jdk${ javaVersion } &metadata=os:${ catalogOS } &metadata=arch:${ c . GRAALVM_ARCH } &metadata=${ metadata } &status=PUBLISHED&responseFields=id&responseFields=checksum`
149+ const requestUrl = c . gdsArtifactQueryUrl ( javaVersion , filter )
167150 core . debug ( `Requesting ${ requestUrl } ` )
168151 const response = await http . get ( requestUrl , { accept : 'application/json' } )
169152 if ( response . message . statusCode !== 200 ) {
@@ -180,10 +163,10 @@ export async function fetchArtifactEE(
180163 return artifactResponse . items [ 0 ]
181164}
182165
183- async function downloadArtifact ( gdsToken : string , userAgent : string , artifact : GDSArtifact ) : Promise < string > {
166+ async function downloadArtifact ( gdsToken : string , artifact : GDSArtifact ) : Promise < string > {
184167 let downloadPath
185168 try {
186- downloadPath = await downloadTool ( ` ${ c . GDS_BASE } /artifacts/ ${ artifact . id } /content` , userAgent , {
169+ downloadPath = await downloadTool ( c . gdsArtifactDownloadUrl ( artifact . id ) , c . GDS_USER_AGENT , {
187170 accept : 'application/x-yaml' ,
188171 'x-download-token' : gdsToken
189172 } )
0 commit comments