Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <[email protected]>
  • Loading branch information
wangxiaoxuan273 committed Jun 5, 2024
1 parent a201d6d commit 95cb4b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 10 additions & 1 deletion src/lib/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
5 changes: 0 additions & 5 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ async function setup(): Promise<void> {
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;
Expand Down

0 comments on commit 95cb4b9

Please sign in to comment.