mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2026-11-28 11:14:21 +01:00
chore: refactors downloadCLI
see: -https://github.com/opentofu/setup-opentofu/pull/2#discussion_r1356503597 - https://github.com/opentofu/setup-opentofu/pull/2#discussion_r1356504741 Signed-off-by: Dmitry Kisler <admin@dkisler.com>
This commit is contained in:
2 files changed
+18
-10
No files matched your search
Vendored
+9
-5
@@ -145,11 +145,15 @@ function mapOS (os) {
|
||||
return os;
|
||||
}
|
||||
|
||||
async function downloadCLI (url) {
|
||||
async function downloadAndExtractCLI (url) {
|
||||
core.debug(`Downloading OpenTofu CLI from ${url}`);
|
||||
const pathToCLIZip = await tc.downloadTool(url);
|
||||
|
||||
let pathToCLI = '';
|
||||
if (!pathToCLIZip) {
|
||||
throw new Error(`Unable to download OpenTofu from ${url}`);
|
||||
}
|
||||
|
||||
let pathToCLI;
|
||||
|
||||
core.debug('Extracting OpenTofu CLI zip file');
|
||||
if (os.platform().startsWith('win')) {
|
||||
@@ -164,8 +168,8 @@ async function downloadCLI (url) {
|
||||
|
||||
core.debug(`OpenTofu CLI path is ${pathToCLI}.`);
|
||||
|
||||
if (!pathToCLIZip || !pathToCLI) {
|
||||
throw new Error(`Unable to download OpenTofu from ${url}`);
|
||||
if (!pathToCLI) {
|
||||
throw new Error('Unable to unzip OpenTofu');
|
||||
}
|
||||
|
||||
return pathToCLI;
|
||||
@@ -254,7 +258,7 @@ async function run () {
|
||||
}
|
||||
|
||||
// Download requested version
|
||||
const pathToCLI = await downloadCLI(build.url);
|
||||
const pathToCLI = await downloadAndExtractCLI(build.url);
|
||||
|
||||
// Install our wrapper
|
||||
if (wrapper) {
|
||||
|
||||
+9
-5
@@ -34,11 +34,15 @@ function mapOS (os) {
|
||||
return os;
|
||||
}
|
||||
|
||||
async function downloadCLI (url) {
|
||||
async function downloadAndExtractCLI (url) {
|
||||
core.debug(`Downloading OpenTofu CLI from ${url}`);
|
||||
const pathToCLIZip = await tc.downloadTool(url);
|
||||
|
||||
let pathToCLI = '';
|
||||
if (!pathToCLIZip) {
|
||||
throw new Error(`Unable to download OpenTofu from ${url}`);
|
||||
}
|
||||
|
||||
let pathToCLI;
|
||||
|
||||
core.debug('Extracting OpenTofu CLI zip file');
|
||||
if (os.platform().startsWith('win')) {
|
||||
@@ -53,8 +57,8 @@ async function downloadCLI (url) {
|
||||
|
||||
core.debug(`OpenTofu CLI path is ${pathToCLI}.`);
|
||||
|
||||
if (!pathToCLIZip || !pathToCLI) {
|
||||
throw new Error(`Unable to download OpenTofu from ${url}`);
|
||||
if (!pathToCLI) {
|
||||
throw new Error('Unable to unzip OpenTofu');
|
||||
}
|
||||
|
||||
return pathToCLI;
|
||||
@@ -143,7 +147,7 @@ async function run () {
|
||||
}
|
||||
|
||||
// Download requested version
|
||||
const pathToCLI = await downloadCLI(build.url);
|
||||
const pathToCLI = await downloadAndExtractCLI(build.url);
|
||||
|
||||
// Install our wrapper
|
||||
if (wrapper) {
|
||||
|
||||
Reference in new issue
Block a user