From 95cb4b934a3d7eb7629838aff081655e8a51a42b Mon Sep 17 00:00:00 2001 From: Xiaoxuan Wang Date: Wed, 5 Jun 2024 01:40:37 +0000 Subject: [PATCH] resolve comments Signed-off-by: Xiaoxuan Wang --- src/lib/release.ts | 11 ++++++++++- src/setup.ts | 5 ----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/release.ts b/src/lib/release.ts index f7a4f15..3ec406a 100644 --- a/src/lib/release.ts +++ b/src/lib/release.ts @@ -28,13 +28,22 @@ interface releases { // Get release info of a certain verion of ORAS CLI export function getReleaseInfo(version: string, url: string, checksum: string) { - // if customized ORAS CLI link is provided + // if customized ORAS CLI link and checksum are provided, version is ignored if (url && checksum) { return { checksum: checksum, url: url } } + + // sanity checks + if (url && !checksum) { + throw new Error("user provided url of customized ORAS CLI release but without SHA256 checksum"); + } + if (!url && checksum) { + throw new Error("user provided SHA256 checksum but without url"); + } + // get the official release const releases = releaseJson as releases; if (!(version in releases)) { diff --git a/src/setup.ts b/src/setup.ts index 68e2bda..cfec8a5 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -24,11 +24,6 @@ async function setup(): Promise { const url: string = core.getInput('url'); const checksum = core.getInput('checksum').toLowerCase(); - // sanity check - if (url && !checksum) { - throw new Error("user provided url of customized ORAS CLI release but without SHA256 checksum"); - } - // download ORAS CLI and validate checksum const info = getReleaseInfo(version, url, checksum); const download_url = info.url;