From 38d6bc72e5877b8eb640e995218d42b8fedf1a47 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 27 Jan 2023 15:32:33 -0500 Subject: [PATCH] v3 new release (#78) * fix broken build - switch to ncc build (#56) * switch to ncc build * update * bump ncc * Vidya reddy/vercel ncc (#58) * updated action file with node16 * Code consistency using prettier and its workflow * Enforce Prettier * code fix * code fix * code fix * add vercel/ncc to build script * modified action file Co-authored-by: Vidya Reddy * Bump @actions/core from 1.2.6 to 1.9.1 (#62) Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.6 to 1.9.1. - [Release notes](https://github.com/actions/toolkit/releases) - [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core) --- updated-dependencies: - dependency-name: "@actions/core" dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Added the bug report and feature request form (#63) * Added the bug report and feature request form * updated the url * Systax error fixes (#64) * Bump jose from 2.0.5 to 2.0.6 (#65) Bumps [jose](https://github.com/panva/jose) from 2.0.5 to 2.0.6. - [Release notes](https://github.com/panva/jose/releases) - [Changelog](https://github.com/panva/jose/blob/v2.0.6/CHANGELOG.md) - [Commits](https://github.com/panva/jose/compare/v2.0.5...v2.0.6) --- updated-dependencies: - dependency-name: jose dependency-type: indirect ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update @actions/core (#68) to address https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ * Bump qs from 6.5.2 to 6.5.3 (#73) Bumps [qs](https://github.com/ljharb/qs) from 6.5.2 to 6.5.3. - [Release notes](https://github.com/ljharb/qs/releases) - [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md) - [Commits](https://github.com/ljharb/qs/compare/v6.5.2...v6.5.3) --- updated-dependencies: - dependency-name: qs dependency-type: indirect ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update README with v3 version (#72) * Bump json5 from 2.2.1 to 2.2.3 (#75) Bumps [json5](https://github.com/json5/json5) from 2.2.1 to 2.2.3. - [Release notes](https://github.com/json5/json5/releases) - [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md) - [Commits](https://github.com/json5/json5/compare/v2.2.1...v2.2.3) --- updated-dependencies: - dependency-name: json5 dependency-type: indirect ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump minimatch from 3.0.4 to 3.1.2 (#74) Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2. - [Release notes](https://github.com/isaacs/minimatch/releases) - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2) --- updated-dependencies: - dependency-name: minimatch dependency-type: indirect ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * separate action and execution (#77) * Add node modules and compiled JavaScript from main --------- Signed-off-by: dependabot[bot] Co-authored-by: David Gamero Co-authored-by: Vidya Reddy <59590642+Vidya2606@users.noreply.github.com> Co-authored-by: Vidya Reddy Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sumner Warren Co-authored-by: Oliver King --- lib/index.js | 111 ++++++++++++++++++---------- src/{run.test.ts => action.test.ts} | 2 +- src/action.ts | 33 +++++++++ src/run.ts | 33 +-------- 4 files changed, 108 insertions(+), 71 deletions(-) rename src/{run.test.ts => action.test.ts} (97%) create mode 100644 src/action.ts diff --git a/lib/index.js b/lib/index.js index 00e10921..89a68828 100644 --- a/lib/index.js +++ b/lib/index.js @@ -188874,6 +188874,77 @@ try { } catch (er) {} +/***/ }), + +/***/ 27289: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.run = void 0; +const core = __importStar(__nccwpck_require__(26024)); +const path = __importStar(__nccwpck_require__(71017)); +const fs = __importStar(__nccwpck_require__(57147)); +const cluster_1 = __nccwpck_require__(68077); +const utils_1 = __nccwpck_require__(76077); +/** + * Sets the Kubernetes context based on supplied action inputs + */ +function run() { + return __awaiter(this, void 0, void 0, function* () { + // get inputs + const clusterType = (0, cluster_1.parseCluster)(core.getInput('cluster-type', { + required: true + })); + const runnerTempDirectory = process.env['RUNNER_TEMP']; + const kubeconfigPath = path.join(runnerTempDirectory, `kubeconfig_${Date.now()}`); + // get kubeconfig and update context + const kubeconfig = yield (0, utils_1.getKubeconfig)(clusterType); + const kubeconfigWithContext = (0, utils_1.setContext)(kubeconfig); + // output kubeconfig + core.debug(`Writing kubeconfig contents to ${kubeconfigPath}`); + fs.writeFileSync(kubeconfigPath, kubeconfigWithContext); + fs.chmodSync(kubeconfigPath, '600'); + core.debug('Setting KUBECONFIG environment variable'); + core.exportVariable('KUBECONFIG', kubeconfigPath); + }); +} +exports.run = run; + + /***/ }), /***/ 63297: @@ -189170,47 +189241,11 @@ var __importStar = (this && this.__importStar) || function (mod) { __setModuleDefault(result, mod); return result; }; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.run = void 0; +const action_1 = __nccwpck_require__(27289); const core = __importStar(__nccwpck_require__(26024)); -const path = __importStar(__nccwpck_require__(71017)); -const fs = __importStar(__nccwpck_require__(57147)); -const cluster_1 = __nccwpck_require__(68077); -const utils_1 = __nccwpck_require__(76077); -/** - * Sets the Kubernetes context based on supplied action inputs - */ -function run() { - return __awaiter(this, void 0, void 0, function* () { - // get inputs - const clusterType = (0, cluster_1.parseCluster)(core.getInput('cluster-type', { - required: true - })); - const runnerTempDirectory = process.env['RUNNER_TEMP']; - const kubeconfigPath = path.join(runnerTempDirectory, `kubeconfig_${Date.now()}`); - // get kubeconfig and update context - const kubeconfig = yield (0, utils_1.getKubeconfig)(clusterType); - const kubeconfigWithContext = (0, utils_1.setContext)(kubeconfig); - // output kubeconfig - core.debug(`Writing kubeconfig contents to ${kubeconfigPath}`); - fs.writeFileSync(kubeconfigPath, kubeconfigWithContext); - fs.chmodSync(kubeconfigPath, '600'); - core.debug('Setting KUBECONFIG environment variable'); - core.exportVariable('KUBECONFIG', kubeconfigPath); - }); -} -exports.run = run; // Run the application -run().catch(core.setFailed); +(0, action_1.run)().catch(core.setFailed); /***/ }), diff --git a/src/run.test.ts b/src/action.test.ts similarity index 97% rename from src/run.test.ts rename to src/action.test.ts index 91d62e84..456fc477 100644 --- a/src/run.test.ts +++ b/src/action.test.ts @@ -1,5 +1,5 @@ import {getRequiredInputError} from '../tests/util' -import {run} from './run' +import {run} from './action' import fs from 'fs' import * as utils from './utils' diff --git a/src/action.ts b/src/action.ts new file mode 100644 index 00000000..91342696 --- /dev/null +++ b/src/action.ts @@ -0,0 +1,33 @@ +import * as core from '@actions/core' +import * as path from 'path' +import * as fs from 'fs' +import {Cluster, parseCluster} from './types/cluster' +import {setContext, getKubeconfig} from './utils' + +/** + * Sets the Kubernetes context based on supplied action inputs + */ +export async function run() { + // get inputs + const clusterType: Cluster | undefined = parseCluster( + core.getInput('cluster-type', { + required: true + }) + ) + const runnerTempDirectory: string = process.env['RUNNER_TEMP'] + const kubeconfigPath: string = path.join( + runnerTempDirectory, + `kubeconfig_${Date.now()}` + ) + + // get kubeconfig and update context + const kubeconfig: string = await getKubeconfig(clusterType) + const kubeconfigWithContext: string = setContext(kubeconfig) + + // output kubeconfig + core.debug(`Writing kubeconfig contents to ${kubeconfigPath}`) + fs.writeFileSync(kubeconfigPath, kubeconfigWithContext) + fs.chmodSync(kubeconfigPath, '600') + core.debug('Setting KUBECONFIG environment variable') + core.exportVariable('KUBECONFIG', kubeconfigPath) +} diff --git a/src/run.ts b/src/run.ts index 9bb23014..893a07ad 100644 --- a/src/run.ts +++ b/src/run.ts @@ -1,36 +1,5 @@ +import {run} from './action' import * as core from '@actions/core' -import * as path from 'path' -import * as fs from 'fs' -import {Cluster, parseCluster} from './types/cluster' -import {setContext, getKubeconfig} from './utils' - -/** - * Sets the Kubernetes context based on supplied action inputs - */ -export async function run() { - // get inputs - const clusterType: Cluster | undefined = parseCluster( - core.getInput('cluster-type', { - required: true - }) - ) - const runnerTempDirectory: string = process.env['RUNNER_TEMP'] - const kubeconfigPath: string = path.join( - runnerTempDirectory, - `kubeconfig_${Date.now()}` - ) - - // get kubeconfig and update context - const kubeconfig: string = await getKubeconfig(clusterType) - const kubeconfigWithContext: string = setContext(kubeconfig) - - // output kubeconfig - core.debug(`Writing kubeconfig contents to ${kubeconfigPath}`) - fs.writeFileSync(kubeconfigPath, kubeconfigWithContext) - fs.chmodSync(kubeconfigPath, '600') - core.debug('Setting KUBECONFIG environment variable') - core.exportVariable('KUBECONFIG', kubeconfigPath) -} // Run the application run().catch(core.setFailed)