Skip to content

Commit

Permalink
Allow installing nightly builds of odo
Browse files Browse the repository at this point in the history
  • Loading branch information
rm3l committed Dec 20, 2023
1 parent ad4784a commit 44f4d11
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/scaffolder-odo-actions-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ This behavior can be customized by adding a new `"odo"` field in your `packages/

{
"odo": {
// specifying the version is optional. You can also specify "latest" to use the latest version of odo
// specifying the version is optional.
// You can also specify "latest" to use the latest version of odo, or "nightly" to use the latest nightly build of odo.
"version": "3.15.0",
"skipDownload": false
}
Expand Down
18 changes: 13 additions & 5 deletions packages/scaffolder-odo-actions-backend/scripts/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const hasha = require("hasha");
const ODO_VERSION = "3.15.0";
const ODO_DIST_URL =
"https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/odo";
const ODO_DIST_URL_NIGHTLY = "https://s3.eu-de.cloud-object-storage.appdomain.cloud/odo-nightly-builds";

// Map of all architectures that can be donwloaded on the odo distribution URL.
const SUPPORTED_ARCHITECTURES_BY_PLATFORM = new Map(
Expand Down Expand Up @@ -53,7 +54,7 @@ async function cachingFetchAndVerify(url, platform, arch, version) {
fs.mkdirSync(cacheDir, { recursive: true });
}

if (version === "latest" || !fs.existsSync(cachedFilePath)) {
if (version === "latest" || version === "nightly" || !fs.existsSync(cachedFilePath)) {
console.info(`Downloading ${url} to ${cacheDir}`);
// download file
fs.writeFileSync(cachedFilePath, await got(url).buffer(), {
Expand Down Expand Up @@ -107,6 +108,11 @@ async function cachingFetchAndVerify(url, platform, arch, version) {
case "darwin":
fs.renameSync(path.join(parentCacheDir, `odo-${platform}-${arch}`), path.join(parentCacheDir, resultingFileName));
break;
case "linux":
if (fs.existsSync(path.join(parentCacheDir, `odo-${platform}-${arch}`))) {
fs.renameSync(path.join(parentCacheDir, `odo-${platform}-${arch}`), path.join(parentCacheDir, resultingFileName));
}
break;
default:
break;
}
Expand Down Expand Up @@ -148,12 +154,14 @@ function unpack(url, installPath, stream) {
*/
async function download({ version, platform, arch }) {
let versionToDl = version;
if (versionToDl !== "latest" && !versionToDl.startsWith("v")) {
if (versionToDl !== "latest" && versionToDl !== "nightly" && !versionToDl.startsWith("v")) {
versionToDl = `v${version}`;
}
const url = `${ODO_DIST_URL}/${versionToDl}/odo-${platform}-${arch}.${
platform === "windows" ? "exe.zip" : "tar.gz"
}`;
let url = `${ODO_DIST_URL}/${versionToDl}`;
if (versionToDl === "nightly") {
url = ODO_DIST_URL_NIGHTLY;
}
url += `/odo-${platform}-${arch}.${platform === "windows" ? "exe.zip" : "tar.gz"}`;
return await cachingFetchAndVerify(url, platform, arch, version);
}

Expand Down

0 comments on commit 44f4d11

Please sign in to comment.