mirror of
https://github.com/imranismail/setup-kustomize.git
synced 2026-05-17 18:25:27 +00:00
Fix linting
This commit is contained in:
9
.github/workflows/checkin.yml
vendored
9
.github/workflows/checkin.yml
vendored
@@ -12,12 +12,5 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- run: |
|
||||
npm install
|
||||
npm ci
|
||||
npm run all
|
||||
test: # make sure the action works on a clean machine without building
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: ./
|
||||
with:
|
||||
milliseconds: 1000
|
||||
@@ -1,103 +1,119 @@
|
||||
import io = require('@actions/io');
|
||||
import fs = require('fs');
|
||||
import os = require('os');
|
||||
import path = require('path');
|
||||
import io = require('@actions/io')
|
||||
import fs = require('fs')
|
||||
import os = require('os')
|
||||
import path = require('path')
|
||||
|
||||
const toolDir = path.join(__dirname, 'runner', 'tools');
|
||||
const tempDir = path.join(__dirname, 'runner', 'temp');
|
||||
const toolDir = path.join(__dirname, 'runner', 'tools')
|
||||
const tempDir = path.join(__dirname, 'runner', 'temp')
|
||||
|
||||
process.env['RUNNER_TOOL_CACHE'] = toolDir;
|
||||
process.env['RUNNER_TEMP'] = tempDir;
|
||||
process.env['RUNNER_TOOL_CACHE'] = toolDir
|
||||
process.env['RUNNER_TEMP'] = tempDir
|
||||
|
||||
import * as installer from '../src/installer';
|
||||
import * as installer from '../src/installer'
|
||||
|
||||
const IS_WINDOWS = os.platform() === 'win32';
|
||||
const IS_WINDOWS = os.platform() === 'win32'
|
||||
|
||||
describe('installer tests', () => {
|
||||
beforeAll(async () => {
|
||||
await io.rmRF(toolDir);
|
||||
await io.rmRF(tempDir);
|
||||
}, 100000);
|
||||
await io.rmRF(toolDir)
|
||||
await io.rmRF(tempDir)
|
||||
}, 100000)
|
||||
|
||||
afterAll(async () => {
|
||||
await io.rmRF(toolDir);
|
||||
await io.rmRF(tempDir);
|
||||
}, 100000);
|
||||
await io.rmRF(toolDir)
|
||||
await io.rmRF(tempDir)
|
||||
}, 100000)
|
||||
|
||||
it('Acquires kustomize version 3.2.0 successfully', async () => {
|
||||
await installer.getKustomize('3.2.0');
|
||||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.0', os.arch());
|
||||
await installer.getKustomize('3.2.0')
|
||||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.0', os.arch())
|
||||
|
||||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true);
|
||||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true)
|
||||
|
||||
if (IS_WINDOWS) {
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true);
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true)
|
||||
} else {
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true);
|
||||
expect(() => fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)).not.toThrow()
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true)
|
||||
expect(() =>
|
||||
fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)
|
||||
).not.toThrow()
|
||||
}
|
||||
}, 100000);
|
||||
}, 100000)
|
||||
|
||||
it('Acquires kustomize version 3.2.1 successfully', async () => {
|
||||
await installer.getKustomize('3.2.1');
|
||||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.1', os.arch());
|
||||
await installer.getKustomize('3.2.1')
|
||||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.1', os.arch())
|
||||
|
||||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true);
|
||||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true)
|
||||
|
||||
if (IS_WINDOWS) {
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true);
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true)
|
||||
} else {
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true);
|
||||
expect(() => fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)).not.toThrow()
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true)
|
||||
expect(() =>
|
||||
fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)
|
||||
).not.toThrow()
|
||||
}
|
||||
}, 100000)
|
||||
|
||||
it('Acquires kustomize version 3.3.0 successfully', async () => {
|
||||
await installer.getKustomize('3.3.0');
|
||||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.3.0', os.arch());
|
||||
await installer.getKustomize('3.3.0')
|
||||
const kustomizeDir = path.join(toolDir, 'kustomize', '3.3.0', os.arch())
|
||||
|
||||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true);
|
||||
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true)
|
||||
|
||||
if (IS_WINDOWS) {
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true);
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true)
|
||||
} else {
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true);
|
||||
expect(() => fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)).not.toThrow()
|
||||
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true)
|
||||
expect(() =>
|
||||
fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)
|
||||
).not.toThrow()
|
||||
}
|
||||
}, 100000)
|
||||
|
||||
it('Throws if no location contains correct kustomize version', async () => {
|
||||
let thrown = false;
|
||||
let thrown = false
|
||||
|
||||
try {
|
||||
await installer.getKustomize('1000');
|
||||
await installer.getKustomize('1000')
|
||||
} catch {
|
||||
thrown = true;
|
||||
thrown = true
|
||||
}
|
||||
|
||||
expect(thrown).toBe(true);
|
||||
});
|
||||
expect(thrown).toBe(true)
|
||||
})
|
||||
|
||||
it('Uses version of kustomize installed in cache', async () => {
|
||||
const kustomizeDir: string = path.join(toolDir, 'kustomize', '3.2.0', os.arch());
|
||||
const kustomizeDir: string = path.join(
|
||||
toolDir,
|
||||
'kustomize',
|
||||
'3.2.0',
|
||||
os.arch()
|
||||
)
|
||||
|
||||
await io.mkdirP(kustomizeDir);
|
||||
await io.mkdirP(kustomizeDir)
|
||||
|
||||
fs.writeFileSync(`${kustomizeDir}.complete`, 'hello');
|
||||
fs.writeFileSync(`${kustomizeDir}.complete`, 'hello')
|
||||
|
||||
await installer.getKustomize('3.2.0');
|
||||
await installer.getKustomize('3.2.0')
|
||||
|
||||
return;
|
||||
});
|
||||
return
|
||||
})
|
||||
|
||||
it('Resolves semantic versions of kustomize installed in cache', async () => {
|
||||
const kustomizeDir: string = path.join(toolDir, 'kustomize', '3.0.0', os.arch());
|
||||
const kustomizeDir: string = path.join(
|
||||
toolDir,
|
||||
'kustomize',
|
||||
'3.0.0',
|
||||
os.arch()
|
||||
)
|
||||
|
||||
await io.mkdirP(kustomizeDir);
|
||||
await io.mkdirP(kustomizeDir)
|
||||
|
||||
fs.writeFileSync(`${kustomizeDir}.complete`, 'hello');
|
||||
fs.writeFileSync(`${kustomizeDir}.complete`, 'hello')
|
||||
|
||||
await installer.getKustomize('3.0.0');
|
||||
await installer.getKustomize('3.0');
|
||||
});
|
||||
});
|
||||
await installer.getKustomize('3.0.0')
|
||||
await installer.getKustomize('3.0')
|
||||
})
|
||||
})
|
||||
|
||||
38
dist/index.js
vendored
38
dist/index.js
vendored
@@ -2516,7 +2516,7 @@ function run() {
|
||||
// Version is optional. If supplied, install / use from the tool cache
|
||||
// If not supplied then task is still used to setup proxy, auth, etc...
|
||||
//
|
||||
let version = core.getInput('kustomize-version');
|
||||
const version = core.getInput('kustomize-version');
|
||||
if (version) {
|
||||
yield installer.getKustomize(version);
|
||||
}
|
||||
@@ -6814,7 +6814,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// Load tempDirectory before it gets wiped by tool-cache
|
||||
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
const tc = __importStar(__webpack_require__(533));
|
||||
const restm = __importStar(__webpack_require__(105));
|
||||
@@ -6822,8 +6821,9 @@ const os = __importStar(__webpack_require__(87));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const semver = __importStar(__webpack_require__(876));
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
let osPlat = os.platform();
|
||||
let osArch = os.arch();
|
||||
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
||||
const osPlat = os.platform();
|
||||
const osArch = os.arch();
|
||||
if (!tempDirectory) {
|
||||
let baseLocation;
|
||||
if (process.platform === 'win32') {
|
||||
@@ -6891,18 +6891,18 @@ function queryLatestMatch(versionSpec) {
|
||||
default:
|
||||
dataFileName = `${dataFileName}_${osArch}`;
|
||||
}
|
||||
let versions = [];
|
||||
let dataUrl = 'https://api.github.com/repos/kubernetes-sigs/kustomize/releases';
|
||||
let rest = new restm.RestClient('setup-kustomize');
|
||||
let kustomizeVersions = (yield rest.get(dataUrl)).result || [];
|
||||
kustomizeVersions.forEach((kustomizeVersion) => {
|
||||
const versions = [];
|
||||
const dataUrl = 'https://api.github.com/repos/kubernetes-sigs/kustomize/releases';
|
||||
const rest = new restm.RestClient('setup-kustomize');
|
||||
const kustomizeVersions = (yield rest.get(dataUrl)).result || [];
|
||||
for (const kustomizeVersion of kustomizeVersions) {
|
||||
if (kustomizeVersion.assets.some(asset => asset.name.includes(dataFileName))) {
|
||||
let version = semver.clean(kustomizeVersion.name);
|
||||
const version = semver.clean(kustomizeVersion.name);
|
||||
if (version != null) {
|
||||
versions.push(version);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return evaluateVersions(versions, versionSpec);
|
||||
});
|
||||
}
|
||||
@@ -6936,15 +6936,15 @@ function acquireKustomize(version) {
|
||||
version = semver.clean(version) || '';
|
||||
let downloadUrl;
|
||||
let toolPath;
|
||||
let toolFilename = "kustomize";
|
||||
let toolName = "kustomize";
|
||||
if (osPlat == "win32") {
|
||||
let toolFilename = 'kustomize';
|
||||
const toolName = 'kustomize';
|
||||
if (osPlat === 'win32') {
|
||||
toolFilename = `${toolFilename}.exe`;
|
||||
}
|
||||
if (semver.gte(version, "3.3.0")) {
|
||||
if (semver.gte(version, '3.3.0')) {
|
||||
downloadUrl = `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${version}/kustomize_v${version}_%{os}_%{arch}.tar.gz`;
|
||||
}
|
||||
else if (semver.gte(version, "3.2.1")) {
|
||||
else if (semver.gte(version, '3.2.1')) {
|
||||
downloadUrl = `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${version}/kustomize_kustomize.v${version}_%{os}_%{arch}`;
|
||||
}
|
||||
else {
|
||||
@@ -6952,10 +6952,10 @@ function acquireKustomize(version) {
|
||||
}
|
||||
switch (osPlat) {
|
||||
case 'win32':
|
||||
if (semver.lte(version, "3.2.1"))
|
||||
if (semver.lte(version, '3.2.1'))
|
||||
throw new Error(`Unexpected OS '${osPlat}'`);
|
||||
downloadUrl = downloadUrl.replace('%{os}', 'windows');
|
||||
if (semver.lt(version, "3.3.0"))
|
||||
if (semver.lt(version, '3.3.0'))
|
||||
downloadUrl = `${downloadUrl}.exe`;
|
||||
break;
|
||||
case 'linux':
|
||||
@@ -6977,7 +6977,7 @@ function acquireKustomize(version) {
|
||||
}
|
||||
catch (err) {
|
||||
core.debug(err);
|
||||
throw `Failed to download version ${version}: ${err}`;
|
||||
throw new Error(`Failed to download version ${version}: ${err}`);
|
||||
}
|
||||
if (downloadUrl.endsWith('.tar.gz')) {
|
||||
toolPath = yield tc.extractTar(toolPath);
|
||||
|
||||
173
src/installer.ts
173
src/installer.ts
@@ -1,197 +1,202 @@
|
||||
// Load tempDirectory before it gets wiped by tool-cache
|
||||
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as restm from 'typed-rest-client/RestClient';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import * as core from '@actions/core'
|
||||
import * as tc from '@actions/tool-cache'
|
||||
import * as restm from 'typed-rest-client/RestClient'
|
||||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
import * as semver from 'semver'
|
||||
import * as fs from 'fs'
|
||||
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || ''
|
||||
|
||||
let osPlat: string = os.platform();
|
||||
let osArch: string = os.arch();
|
||||
const osPlat: string = os.platform()
|
||||
const osArch: string = os.arch()
|
||||
|
||||
if (!tempDirectory) {
|
||||
let baseLocation;
|
||||
let baseLocation
|
||||
if (process.platform === 'win32') {
|
||||
// On windows use the USERPROFILE env variable
|
||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||
baseLocation = process.env['USERPROFILE'] || 'C:\\'
|
||||
} else {
|
||||
if (process.platform === 'darwin') {
|
||||
baseLocation = '/Users';
|
||||
baseLocation = '/Users'
|
||||
} else {
|
||||
baseLocation = '/home';
|
||||
baseLocation = '/home'
|
||||
}
|
||||
}
|
||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||
tempDirectory = path.join(baseLocation, 'actions', 'temp')
|
||||
}
|
||||
|
||||
export async function getKustomize(versionSpec: string) {
|
||||
export async function getKustomize(versionSpec: string): Promise<void> {
|
||||
// check cache
|
||||
let toolPath: string;
|
||||
let toolPath: string
|
||||
|
||||
toolPath = tc.find('kustomize', versionSpec);
|
||||
toolPath = tc.find('kustomize', versionSpec)
|
||||
|
||||
// If not found in cache, download
|
||||
if (!toolPath) {
|
||||
let version: string;
|
||||
const c = semver.clean(versionSpec) || '';
|
||||
let version: string
|
||||
const c = semver.clean(versionSpec) || ''
|
||||
// If explicit version
|
||||
if (semver.valid(c) != null) {
|
||||
// version to download
|
||||
version = versionSpec;
|
||||
version = versionSpec
|
||||
} else {
|
||||
// query kustomize for a matching version
|
||||
version = await queryLatestMatch(versionSpec);
|
||||
version = await queryLatestMatch(versionSpec)
|
||||
if (!version) {
|
||||
throw new Error(
|
||||
`Unable to find Kustomize version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
// check cache
|
||||
toolPath = tc.find('kustomize', version);
|
||||
toolPath = tc.find('kustomize', version)
|
||||
}
|
||||
|
||||
if (!toolPath) {
|
||||
// download, extract, cache
|
||||
toolPath = await acquireKustomize(version);
|
||||
toolPath = await acquireKustomize(version)
|
||||
}
|
||||
}
|
||||
|
||||
core.addPath(toolPath);
|
||||
core.addPath(toolPath)
|
||||
}
|
||||
|
||||
interface IAsset {
|
||||
browser_download_url: string;
|
||||
name: string;
|
||||
browser_download_url: string
|
||||
name: string
|
||||
}
|
||||
|
||||
interface IKustomizeVersion {
|
||||
name: string;
|
||||
assets: IAsset[];
|
||||
name: string
|
||||
assets: IAsset[]
|
||||
}
|
||||
|
||||
async function queryLatestMatch(versionSpec: string): Promise<string> {
|
||||
let dataFileName: string;
|
||||
let dataFileName: string
|
||||
|
||||
switch (osPlat) {
|
||||
case 'linux':
|
||||
case 'darwin':
|
||||
case 'win32':
|
||||
dataFileName = osPlat;
|
||||
break;
|
||||
dataFileName = osPlat
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unexpected OS '${osPlat}'`);
|
||||
throw new Error(`Unexpected OS '${osPlat}'`)
|
||||
}
|
||||
|
||||
switch (osArch) {
|
||||
case 'x64':
|
||||
dataFileName = `${dataFileName}_amd64`;
|
||||
break;
|
||||
dataFileName = `${dataFileName}_amd64`
|
||||
break
|
||||
default:
|
||||
dataFileName = `${dataFileName}_${osArch}`;
|
||||
dataFileName = `${dataFileName}_${osArch}`
|
||||
}
|
||||
|
||||
let versions: string[] = [];
|
||||
let dataUrl = 'https://api.github.com/repos/kubernetes-sigs/kustomize/releases';
|
||||
let rest: restm.RestClient = new restm.RestClient('setup-kustomize');
|
||||
let kustomizeVersions: IKustomizeVersion[] = (await rest.get<IKustomizeVersion[]>(dataUrl)).result || [];
|
||||
const versions: string[] = []
|
||||
const dataUrl =
|
||||
'https://api.github.com/repos/kubernetes-sigs/kustomize/releases'
|
||||
const rest: restm.RestClient = new restm.RestClient('setup-kustomize')
|
||||
const kustomizeVersions: IKustomizeVersion[] =
|
||||
(await rest.get<IKustomizeVersion[]>(dataUrl)).result || []
|
||||
|
||||
kustomizeVersions.forEach((kustomizeVersion: IKustomizeVersion) => {
|
||||
if (kustomizeVersion.assets.some(asset => asset.name.includes(dataFileName))) {
|
||||
let version = semver.clean(kustomizeVersion.name);
|
||||
for (const kustomizeVersion of kustomizeVersions) {
|
||||
if (
|
||||
kustomizeVersion.assets.some(asset => asset.name.includes(dataFileName))
|
||||
) {
|
||||
const version = semver.clean(kustomizeVersion.name)
|
||||
|
||||
if (version != null) {
|
||||
versions.push(version);
|
||||
versions.push(version)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return evaluateVersions(versions, versionSpec);
|
||||
return evaluateVersions(versions, versionSpec)
|
||||
}
|
||||
|
||||
function evaluateVersions(versions: string[], versionSpec: string): string {
|
||||
let version = '';
|
||||
let version = ''
|
||||
|
||||
core.debug(`evaluating ${versions.length} versions`);
|
||||
core.debug(`evaluating ${versions.length} versions`)
|
||||
|
||||
versions = versions.sort((a, b) => {
|
||||
if (semver.gt(a, b)) {
|
||||
return 1;
|
||||
return 1
|
||||
}
|
||||
return -1;
|
||||
});
|
||||
return -1
|
||||
})
|
||||
|
||||
for (let i = versions.length - 1; i >= 0; i--) {
|
||||
const potential: string = versions[i];
|
||||
const satisfied: boolean = semver.satisfies(potential, versionSpec);
|
||||
const potential: string = versions[i]
|
||||
const satisfied: boolean = semver.satisfies(potential, versionSpec)
|
||||
if (satisfied) {
|
||||
version = potential;
|
||||
break;
|
||||
version = potential
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (version) {
|
||||
core.debug(`matched: ${version}`);
|
||||
core.debug(`matched: ${version}`)
|
||||
} else {
|
||||
core.debug('match not found');
|
||||
core.debug('match not found')
|
||||
}
|
||||
|
||||
return version;
|
||||
return version
|
||||
}
|
||||
|
||||
async function acquireKustomize(version: string): Promise<string> {
|
||||
version = semver.clean(version) || '';
|
||||
version = semver.clean(version) || ''
|
||||
|
||||
let downloadUrl: string;
|
||||
let toolPath: string;
|
||||
let toolFilename = "kustomize";
|
||||
let toolName = "kustomize";
|
||||
let downloadUrl: string
|
||||
let toolPath: string
|
||||
let toolFilename = 'kustomize'
|
||||
const toolName = 'kustomize'
|
||||
|
||||
if (osPlat == "win32") {
|
||||
if (osPlat === 'win32') {
|
||||
toolFilename = `${toolFilename}.exe`
|
||||
}
|
||||
|
||||
if (semver.gte(version, "3.3.0")) {
|
||||
downloadUrl = `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${version}/kustomize_v${version}_%{os}_%{arch}.tar.gz`;
|
||||
} else if (semver.gte(version, "3.2.1")) {
|
||||
downloadUrl = `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${version}/kustomize_kustomize.v${version}_%{os}_%{arch}`;
|
||||
if (semver.gte(version, '3.3.0')) {
|
||||
downloadUrl = `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${version}/kustomize_v${version}_%{os}_%{arch}.tar.gz`
|
||||
} else if (semver.gte(version, '3.2.1')) {
|
||||
downloadUrl = `https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${version}/kustomize_kustomize.v${version}_%{os}_%{arch}`
|
||||
} else {
|
||||
downloadUrl = `https://github.com/kubernetes-sigs/kustomize/releases/download/v${version}/kustomize_${version}_%{os}_%{arch}`
|
||||
}
|
||||
|
||||
switch (osPlat) {
|
||||
case 'win32':
|
||||
if (semver.lte(version, "3.2.1")) throw new Error(`Unexpected OS '${osPlat}'`);
|
||||
downloadUrl = downloadUrl.replace('%{os}', 'windows');
|
||||
if (semver.lt(version, "3.3.0")) downloadUrl = `${downloadUrl}.exe`;
|
||||
break;
|
||||
if (semver.lte(version, '3.2.1'))
|
||||
throw new Error(`Unexpected OS '${osPlat}'`)
|
||||
downloadUrl = downloadUrl.replace('%{os}', 'windows')
|
||||
if (semver.lt(version, '3.3.0')) downloadUrl = `${downloadUrl}.exe`
|
||||
break
|
||||
case 'linux':
|
||||
case 'darwin':
|
||||
downloadUrl = downloadUrl.replace('%{os}', osPlat);
|
||||
break;
|
||||
downloadUrl = downloadUrl.replace('%{os}', osPlat)
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unexpected OS '${osPlat}'`);
|
||||
throw new Error(`Unexpected OS '${osPlat}'`)
|
||||
}
|
||||
|
||||
switch (osArch) {
|
||||
case 'x64':
|
||||
downloadUrl = downloadUrl.replace('%{arch}', 'amd64');
|
||||
break;
|
||||
downloadUrl = downloadUrl.replace('%{arch}', 'amd64')
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unexpected Arch '${osArch}'`);
|
||||
throw new Error(`Unexpected Arch '${osArch}'`)
|
||||
}
|
||||
|
||||
try {
|
||||
toolPath = await tc.downloadTool(downloadUrl);
|
||||
toolPath = await tc.downloadTool(downloadUrl)
|
||||
} catch (err) {
|
||||
core.debug(err);
|
||||
throw `Failed to download version ${version}: ${err}`;
|
||||
core.debug(err)
|
||||
throw new Error(`Failed to download version ${version}: ${err}`)
|
||||
}
|
||||
|
||||
if (downloadUrl.endsWith('.tar.gz')) {
|
||||
toolPath = await tc.extractTar(toolPath);
|
||||
toolPath = await tc.extractTar(toolPath)
|
||||
toolPath = path.join(toolPath, toolFilename)
|
||||
}
|
||||
|
||||
@@ -199,8 +204,8 @@ async function acquireKustomize(version: string): Promise<string> {
|
||||
case 'linux':
|
||||
case 'darwin':
|
||||
fs.chmodSync(toolPath, 0o755)
|
||||
break;
|
||||
break
|
||||
}
|
||||
|
||||
return await tc.cacheFile(toolPath, toolFilename, toolName, version);
|
||||
return await tc.cacheFile(toolPath, toolFilename, toolName, version)
|
||||
}
|
||||
14
src/main.ts
14
src/main.ts
@@ -1,20 +1,20 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as installer from './installer';
|
||||
import * as core from '@actions/core'
|
||||
import * as installer from './installer'
|
||||
|
||||
async function run() {
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
//
|
||||
// Version is optional. If supplied, install / use from the tool cache
|
||||
// If not supplied then task is still used to setup proxy, auth, etc...
|
||||
//
|
||||
let version = core.getInput('kustomize-version');
|
||||
const version = core.getInput('kustomize-version')
|
||||
|
||||
if (version) {
|
||||
await installer.getKustomize(version);
|
||||
await installer.getKustomize(version)
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
run()
|
||||
|
||||
Reference in New Issue
Block a user