Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
token: kubeconfigToken
}
}
]
};
// Save the kubeconfig object.
const formattedConfig = JSON.stringify(kubeconfig, null, 4);
fs.writeFileSync(`${workdir}/kubeconfig`, formattedConfig);
// Download and install kubectl.
const kubectl = await tc.downloadTool("https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/linux/amd64/kubectl");
await io.mv(kubectl, `${workdir}/kubectl`);
// Cache kubectl and kubeconfig.
const cachedPath = await tc.cacheDir(workdir, 'kubectl', 'v1.16.0');
// Set KUBECONFIG environment variable.
core.exportVariable('KUBECONFIG', `${cachedPath}/kubeconfig`);
// Add kubectl to PATH.
core.addPath(`${cachedPath}/kubectl`);
}
catch (error) {
core.setFailed(error.message);
}
}
core.debug(`Found local cached tool at ${directoryToAddToPath} adding that to path`);
await core.addPath(directoryToAddToPath);
return;
}
// Download latest Nuget.exe
core.debug("Downloading Nuget tool");
const nugetPath = await tc.downloadTool("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe");
// Rename the file which is a GUID without extension
var folder = path.dirname(nugetPath);
var fullPath = path.join(folder, "nuget.exe");
fs.renameSync(nugetPath, fullPath);
//Cache the directory with Nuget in it - which returns a NEW cached location
var cachedToolDir = await tc.cacheDir(folder, "nuget", "latest");
core.debug(`Cached Tool Dir ${cachedToolDir}`);
// Add Nuget.exe CLI tool to path for other steps to be able to access it
await core.addPath(cachedToolDir);
} catch (error) {
core.setFailed(error.message);
}
}
downloadPath = await tc.downloadTool(downloadUrl);
} catch (error) {
core.debug(error);
throw `Failed to download version ${version}: ${error}`;
}
// Extract
let extPath: string | null = null;
if (osPlat == "win32") {
extPath = await tc.extractZip(downloadPath);
} else {
extPath = await tc.extractTar(downloadPath);
}
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
return await tc.cacheDir(extPath, "arduino-cli", version);
}
downloadPath = await tc.downloadTool(downloadUrl);
} catch (error) {
throw `Failed to download Pandoc ${version}: ${error}`;
}
//
// Extract
//
let extPath: string = tempDirectory;
if (!extPath) {
throw new Error("Temp directory not set");
}
extPath = await tc.extractZip(downloadPath);
const toolPath = await tc.cacheDir(extPath, "pandoc", version);
// It extracts to this folder
const toolRoot = path.join(
toolPath,
util.format("pandoc-%s-windows-x86_64", version)
);
core.addPath(toolRoot);
}
const archive = await tc.downloadTool(descr.url);
if (descr.sig)
{
console.log("Verifying the download with GPG");
await gpg.install();
await gpg.verify(archive, descr.sig);
}
const dc_path = await extract(descr.url, archive);
if (descr.download_dub) {
const dub = await legacyDub();
const archive2 = await tc.downloadTool(dub.url);
await extract(dub.url, archive2, dc_path + descr.binpath);
}
cached = await tc.cacheDir(dc_path, 'dc', cache_tag);
}
const binpath = cached + descr.binpath;
console.log("Adding '" + binpath + "' to path");
core.addPath(binpath);
core.exportVariable("DC", descr.name);
const libpath = cached + descr.libpath;
console.log("Adding '" + libpath + "' to library path");
if (process.platform == "win32") {
core.addPath(cached + descr.libpath);
}
else {
core.exportVariable("LD_LIBRARY_PATH", libpath);
}
console.log("Done");
const libPath = await tc.downloadTool(libUrl);
await io.cp(libPath, path.join(tempDir, 'node.lib'));
} catch (err) {
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
exeUrl = `https://nodejs.org/dist/v${version}/node.exe`;
libUrl = `https://nodejs.org/dist/v${version}/node.lib`;
const exePath = await tc.downloadTool(exeUrl);
await io.cp(exePath, path.join(tempDir, 'node.exe'));
const libPath = await tc.downloadTool(libUrl);
await io.cp(libPath, path.join(tempDir, 'node.lib'));
} else {
throw err;
}
}
return await tc.cacheDir(tempDir, 'node', version);
}
if (toolPath && version !== 'latest') {
core.info(`Leiningen found in cache ${toolPath}`);
} else {
let leiningenFile = await tc.downloadTool(
`https://raw.githubusercontent.com/technomancy/leiningen/${version === 'latest' ? 'stable' : version}/bin/lein${IS_WINDOWS ? '.bat' : ''}`
);
let tempDir: string = path.join(
tempDirectory,
'temp_' + Math.floor(Math.random() * 2000000000)
);
const leiningenDir = await installLeiningen(
leiningenFile,
tempDir
);
core.debug(`Leiningen installed to ${leiningenDir}`);
toolPath = await tc.cacheDir(
leiningenDir,
'Leiningen',
utils.getCacheVersionString(version)
);
}
core.exportVariable('LEIN_HOME', toolPath);
core.addPath(path.join(toolPath, 'bin'));
}
let dstdir: string;
switch (type) {
case "tarxz":
dstdir = await tc.extractTar(tmppath);
break;
case "7z":
dstdir = await tc.extract7z(tmppath);
break;
case "zip":
dstdir = await tc.extractZip(tmppath);
break;
default: throw new Error("unexpected program state");
}
if (dmdVersion !== "master")
tc.cacheDir(dstdir, "dmd", dmdVersion);
return dstdir;
}
let cleanver = `${version.replace('+', '-')}-${channel}`;
let toolPath = tc.find('flutter', cleanver);
if (toolPath) {
core.debug(`Tool found in cache ${toolPath}`);
} else {
core.debug('Downloading Flutter from Google storage');
const downloadInfo = getDownloadInfo(version, channel);
const sdkFile = await tc.downloadTool(downloadInfo.url);
let tempDir: string = generateTempDir();
const sdkDir = await extractDownload(sdkFile, tempDir);
core.debug(`Flutter sdk extracted to ${sdkDir}`);
toolPath = await tc.cacheDir(sdkDir, 'flutter', cleanver);
}
core.exportVariable('FLUTTER_HOME', toolPath);
core.addPath(path.join(toolPath, 'bin'));
}