mirror of
https://github.com/Azure/k8s-set-context.git
synced 2026-06-22 23:09:31 +08:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ffb4da395 | |||
| cbdd016f5e | |||
| 3624a1fc64 | |||
| ab43e1cba5 | |||
| f7b05df5e5 | |||
| 6332864ca0 | |||
| d7e25ce077 | |||
| 0689e8a931 | |||
| 03c6fe6b8a | |||
| b0cfd07ecc | |||
| ccc0c881dc | |||
| e617f31159 | |||
| 778581b6aa | |||
| 6331e961d2 |
+73
-38
@@ -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);
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
+1
-32
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user