From fcc966ea7b80a56eb8f215e737c69c0ee0641732 Mon Sep 17 00:00:00 2001 From: Eik Emil Bengtsson Date: Thu, 5 May 2022 14:01:17 +0200 Subject: [PATCH] fix path issue (#3) --- action.yaml | 2 +- dist/index.js | 9 ++++ package-lock.json | 122 +++++++++++++++++++++++++++++++++++++++++++++- src/kubectl.ts | 6 +++ src/kustomize.ts | 7 +++ src/run.ts | 2 +- 6 files changed, 145 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index f04ffbc..f008eeb 100644 --- a/action.yaml +++ b/action.yaml @@ -20,7 +20,7 @@ inputs: kubectl: description: 'The version of kustomize to use' required: true - default: '1.20.9' + default: '1.23.6' namesuffix: description: 'Add suffix to all resources' required: false diff --git a/dist/index.js b/dist/index.js index 18d067d..33a7763 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8208,6 +8208,8 @@ exports.setupKustomize = void 0; const os = __importStar(__webpack_require__(87)); const toolCache = __importStar(__webpack_require__(533)); const core = __importStar(__webpack_require__(470)); +const path = __importStar(__webpack_require__(622)); +const fs = __importStar(__webpack_require__(747)); const getKustomizeLink = (version) => { switch (os.type()) { case 'Linux': @@ -8220,6 +8222,7 @@ const getKustomizeLink = (version) => { throw Error("Could not find correct OS"); } }; +const getToolWithExtension = (toolName) => os.type() == 'Windows_NT' ? `${toolName}.exe` : toolName; exports.setupKustomize = (version) => __awaiter(void 0, void 0, void 0, function* () { const toolName = 'kustomize'; let cachedToolpath = toolCache.find(toolName, version); @@ -8228,6 +8231,8 @@ exports.setupKustomize = (version) => __awaiter(void 0, void 0, void 0, function const unzipped = yield toolCache.extractTar(location); cachedToolpath = yield toolCache.cacheDir(unzipped, toolName, version); } + const kustomizePath = path.join(cachedToolpath, getToolWithExtension(toolName)); + fs.chmodSync(kustomizePath, '777'); core.addPath(cachedToolpath); }); @@ -11645,6 +11650,8 @@ exports.setupKubectl = void 0; const os = __importStar(__webpack_require__(87)); const toolCache = __importStar(__webpack_require__(533)); const core = __importStar(__webpack_require__(470)); +const path = __importStar(__webpack_require__(622)); +const fs = __importStar(__webpack_require__(747)); const getkubectlDownloadURL = (version) => { switch (os.type()) { case 'Linux': @@ -11665,6 +11672,8 @@ exports.setupKubectl = (version) => __awaiter(void 0, void 0, void 0, function* const location = yield toolCache.downloadTool(getkubectlDownloadURL(version)); cachedToolpath = yield toolCache.cacheFile(location, getToolWithExtension(toolName), toolName, version); } + const kubectlPath = path.join(cachedToolpath, getToolWithExtension(toolName)); + fs.chmodSync(kubectlPath, '777'); core.addPath(cachedToolpath); }); diff --git a/package-lock.json b/package-lock.json index 6049915..6507f57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,128 @@ { "name": "deploy-with-kustomize-action", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "deploy-with-kustomize-action", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@actions/core": "1.2.6", + "@actions/exec": "^1.0.0", + "@actions/io": "^1.0.0", + "@actions/tool-cache": "1.6.0", + "yaml": "^1.10.0" + }, + "devDependencies": { + "@types/node": "^12.12.67", + "@zeit/ncc": "^0.22.3", + "typescript": "^3.9.7" + } + }, + "node_modules/@actions/core": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz", + "integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==" + }, + "node_modules/@actions/exec": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.4.tgz", + "integrity": "sha512-4DPChWow9yc9W3WqEbUj8Nr86xkpyE29ZzWjXucHItclLbEW6jr80Zx4nqv18QL6KK65+cifiQZXvnqgTV6oHw==", + "dependencies": { + "@actions/io": "^1.0.1" + } + }, + "node_modules/@actions/http-client": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.9.tgz", + "integrity": "sha512-0O4SsJ7q+MK0ycvXPl2e6bMXV7dxAXOGjrXS1eTF9s2S401Tp6c/P3c3Joz04QefC1J6Gt942Wl2jbm3f4mLcg==", + "dependencies": { + "tunnel": "0.0.6" + } + }, + "node_modules/@actions/io": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.2.tgz", + "integrity": "sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg==" + }, + "node_modules/@actions/tool-cache": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.6.0.tgz", + "integrity": "sha512-+fyEBImPD3m5I0o6DflCO0NHY180LPoX8Lo6y4Iez+V17kO8kfkH0VHxb8mUdmD6hn9dWA9Ch1JA20fXoIYUeQ==", + "dependencies": { + "@actions/core": "^1.2.3", + "@actions/exec": "^1.0.0", + "@actions/http-client": "^1.0.8", + "@actions/io": "^1.0.1", + "semver": "^6.1.0", + "uuid": "^3.3.2" + } + }, + "node_modules/@types/node": { + "version": "12.12.67", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.67.tgz", + "integrity": "sha512-R48tgL2izApf+9rYNH+3RBMbRpPeW3N8f0I9HMhggeq4UXwBDqumJ14SDs4ctTMhG11pIOduZ4z3QWGOiMc9Vg==", + "dev": true + }, + "node_modules/@zeit/ncc": { + "version": "0.22.3", + "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.22.3.tgz", + "integrity": "sha512-jnCLpLXWuw/PAiJiVbLjA8WBC0IJQbFeUwF4I9M+23MvIxTxk5pD4Q8byQBSPmHQjz5aBoA7AKAElQxMpjrCLQ==", + "deprecated": "@zeit/ncc is no longer maintained. Please use @vercel/ncc instead.", + "dev": true, + "bin": { + "ncc": "dist/ncc/cli.js" + } + }, + "node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", + "engines": { + "node": ">=0.6.11 <=0.7.0 || >=0.7.3" + } + }, + "node_modules/typescript": { + "version": "3.9.7", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz", + "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "bin": { + "uuid": "bin/uuid" + } + }, + "node_modules/yaml": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.0.tgz", + "integrity": "sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==", + "engines": { + "node": ">= 6" + } + } + }, "dependencies": { "@actions/core": { "version": "1.2.6", diff --git a/src/kubectl.ts b/src/kubectl.ts index 0cac177..cfc5293 100644 --- a/src/kubectl.ts +++ b/src/kubectl.ts @@ -1,6 +1,9 @@ import * as os from 'os'; import * as toolCache from '@actions/tool-cache' import * as core from '@actions/core' +import * as path from 'path'; +import * as fs from 'fs'; + const getkubectlDownloadURL = (version: string): string => { switch (os.type()) { @@ -27,5 +30,8 @@ export const setupKubectl = async (version) => { cachedToolpath = await toolCache.cacheFile(location, getToolWithExtension(toolName), toolName, version) } + const kubectlPath = path.join(cachedToolpath, getToolWithExtension(toolName)); + fs.chmodSync(kubectlPath, '777'); + core.addPath(cachedToolpath) } diff --git a/src/kustomize.ts b/src/kustomize.ts index a7ef463..0719e0b 100644 --- a/src/kustomize.ts +++ b/src/kustomize.ts @@ -1,6 +1,8 @@ import * as os from 'os'; import * as toolCache from '@actions/tool-cache' import * as core from '@actions/core' +import * as path from 'path'; +import * as fs from 'fs'; const getKustomizeLink = (version: string): string => { switch (os.type()) { @@ -16,6 +18,8 @@ const getKustomizeLink = (version: string): string => { } } +const getToolWithExtension = (toolName) => os.type() == 'Windows_NT' ? `${toolName}.exe` : toolName; + export const setupKustomize = async (version) => { const toolName = 'kustomize'; @@ -26,5 +30,8 @@ export const setupKustomize = async (version) => { cachedToolpath = await toolCache.cacheDir(unzipped, toolName, version) } + const kustomizePath = path.join(cachedToolpath, getToolWithExtension(toolName)); + fs.chmodSync(kustomizePath, '777'); + core.addPath(cachedToolpath) } diff --git a/src/run.ts b/src/run.ts index 63d9f15..2728f58 100644 --- a/src/run.ts +++ b/src/run.ts @@ -104,4 +104,4 @@ const execHelper = async (tool, args: string[], options: exec.ExecOptions = {}) return exitCode } -run().catch(core.setFailed) \ No newline at end of file +run().catch(core.setFailed)