mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-04-12 09:22:19 +08:00
LF/CRLF fix
This commit is contained in:
parent
41514fca22
commit
ef8defce31
108
lib/constants.js
108
lib/constants.js
@ -1,54 +1,54 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getWorkflowAnnotationKeyLabel = exports.getWorkflowAnnotationsJson = exports.workloadTypesWithRolloutStatus = exports.workloadTypes = exports.deploymentTypes = exports.ServiceTypes = exports.DiscoveryAndLoadBalancerResource = exports.KubernetesWorkload = void 0;
|
exports.getWorkflowAnnotationKeyLabel = exports.getWorkflowAnnotationsJson = exports.workloadTypesWithRolloutStatus = exports.workloadTypes = exports.deploymentTypes = exports.ServiceTypes = exports.DiscoveryAndLoadBalancerResource = exports.KubernetesWorkload = void 0;
|
||||||
class KubernetesWorkload {
|
class KubernetesWorkload {
|
||||||
}
|
}
|
||||||
exports.KubernetesWorkload = KubernetesWorkload;
|
exports.KubernetesWorkload = KubernetesWorkload;
|
||||||
KubernetesWorkload.pod = 'Pod';
|
KubernetesWorkload.pod = 'Pod';
|
||||||
KubernetesWorkload.replicaset = 'Replicaset';
|
KubernetesWorkload.replicaset = 'Replicaset';
|
||||||
KubernetesWorkload.deployment = 'Deployment';
|
KubernetesWorkload.deployment = 'Deployment';
|
||||||
KubernetesWorkload.statefulSet = 'StatefulSet';
|
KubernetesWorkload.statefulSet = 'StatefulSet';
|
||||||
KubernetesWorkload.daemonSet = 'DaemonSet';
|
KubernetesWorkload.daemonSet = 'DaemonSet';
|
||||||
KubernetesWorkload.job = 'job';
|
KubernetesWorkload.job = 'job';
|
||||||
KubernetesWorkload.cronjob = 'cronjob';
|
KubernetesWorkload.cronjob = 'cronjob';
|
||||||
class DiscoveryAndLoadBalancerResource {
|
class DiscoveryAndLoadBalancerResource {
|
||||||
}
|
}
|
||||||
exports.DiscoveryAndLoadBalancerResource = DiscoveryAndLoadBalancerResource;
|
exports.DiscoveryAndLoadBalancerResource = DiscoveryAndLoadBalancerResource;
|
||||||
DiscoveryAndLoadBalancerResource.service = 'service';
|
DiscoveryAndLoadBalancerResource.service = 'service';
|
||||||
DiscoveryAndLoadBalancerResource.ingress = 'ingress';
|
DiscoveryAndLoadBalancerResource.ingress = 'ingress';
|
||||||
class ServiceTypes {
|
class ServiceTypes {
|
||||||
}
|
}
|
||||||
exports.ServiceTypes = ServiceTypes;
|
exports.ServiceTypes = ServiceTypes;
|
||||||
ServiceTypes.loadBalancer = 'LoadBalancer';
|
ServiceTypes.loadBalancer = 'LoadBalancer';
|
||||||
ServiceTypes.nodePort = 'NodePort';
|
ServiceTypes.nodePort = 'NodePort';
|
||||||
ServiceTypes.clusterIP = 'ClusterIP';
|
ServiceTypes.clusterIP = 'ClusterIP';
|
||||||
exports.deploymentTypes = ['deployment', 'replicaset', 'daemonset', 'pod', 'statefulset'];
|
exports.deploymentTypes = ['deployment', 'replicaset', 'daemonset', 'pod', 'statefulset'];
|
||||||
exports.workloadTypes = ['deployment', 'replicaset', 'daemonset', 'pod', 'statefulset', 'job', 'cronjob'];
|
exports.workloadTypes = ['deployment', 'replicaset', 'daemonset', 'pod', 'statefulset', 'job', 'cronjob'];
|
||||||
exports.workloadTypesWithRolloutStatus = ['deployment', 'daemonset', 'statefulset'];
|
exports.workloadTypesWithRolloutStatus = ['deployment', 'daemonset', 'statefulset'];
|
||||||
function getWorkflowAnnotationsJson(lastSuccessRunSha, workflowFilePath, filePathConfigs) {
|
function getWorkflowAnnotationsJson(lastSuccessRunSha, workflowFilePath, filePathConfigs) {
|
||||||
return `{`
|
return `{`
|
||||||
+ `'run': '${process.env.GITHUB_RUN_ID}',`
|
+ `'run': '${process.env.GITHUB_RUN_ID}',`
|
||||||
+ `'repository': '${process.env.GITHUB_REPOSITORY}',`
|
+ `'repository': '${process.env.GITHUB_REPOSITORY}',`
|
||||||
+ `'workflow': '${process.env.GITHUB_WORKFLOW}',`
|
+ `'workflow': '${process.env.GITHUB_WORKFLOW}',`
|
||||||
+ `'workflowFileName': '${workflowFilePath.replace(".github/workflows/", "")}',`
|
+ `'workflowFileName': '${workflowFilePath.replace(".github/workflows/", "")}',`
|
||||||
+ `'jobName': '${process.env.GITHUB_JOB}',`
|
+ `'jobName': '${process.env.GITHUB_JOB}',`
|
||||||
+ `'createdBy': '${process.env.GITHUB_ACTOR}',`
|
+ `'createdBy': '${process.env.GITHUB_ACTOR}',`
|
||||||
+ `'runUri': 'https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}',`
|
+ `'runUri': 'https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}',`
|
||||||
+ `'commit': '${process.env.GITHUB_SHA}',`
|
+ `'commit': '${process.env.GITHUB_SHA}',`
|
||||||
+ `'lastSuccessRunCommit': '${lastSuccessRunSha}',`
|
+ `'lastSuccessRunCommit': '${lastSuccessRunSha}',`
|
||||||
+ `'branch': '${process.env.GITHUB_REF}',`
|
+ `'branch': '${process.env.GITHUB_REF}',`
|
||||||
+ `'deployTimestamp': '${Date.now()}',`
|
+ `'deployTimestamp': '${Date.now()}',`
|
||||||
+ `'dockerfilePaths': ${JSON.stringify(filePathConfigs.dockerfilePaths)},`
|
+ `'dockerfilePaths': ${JSON.stringify(filePathConfigs.dockerfilePaths)},`
|
||||||
+ `'manifestsPaths': ${JSON.stringify(filePathConfigs.manifestFilePaths)},`
|
+ `'manifestsPaths': ${JSON.stringify(filePathConfigs.manifestFilePaths)},`
|
||||||
+ `'helmChartPaths': ${JSON.stringify(filePathConfigs.helmChartPaths)},`
|
+ `'helmChartPaths': ${JSON.stringify(filePathConfigs.helmChartPaths)},`
|
||||||
+ `'provider': 'GitHub'`
|
+ `'provider': 'GitHub'`
|
||||||
+ `}`;
|
+ `}`;
|
||||||
}
|
}
|
||||||
exports.getWorkflowAnnotationsJson = getWorkflowAnnotationsJson;
|
exports.getWorkflowAnnotationsJson = getWorkflowAnnotationsJson;
|
||||||
function getWorkflowAnnotationKeyLabel(workflowFilePath) {
|
function getWorkflowAnnotationKeyLabel(workflowFilePath) {
|
||||||
const hashKey = require("crypto").createHash("MD5")
|
const hashKey = require("crypto").createHash("MD5")
|
||||||
.update(`${process.env.GITHUB_REPOSITORY}/${workflowFilePath}`)
|
.update(`${process.env.GITHUB_REPOSITORY}/${workflowFilePath}`)
|
||||||
.digest("hex");
|
.digest("hex");
|
||||||
return `githubWorkflow_${hashKey}`;
|
return `githubWorkflow_${hashKey}`;
|
||||||
}
|
}
|
||||||
exports.getWorkflowAnnotationKeyLabel = getWorkflowAnnotationKeyLabel;
|
exports.getWorkflowAnnotationKeyLabel = getWorkflowAnnotationKeyLabel;
|
||||||
|
|||||||
@ -1,211 +1,211 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
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 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); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getCurrentTime = exports.getRandomInt = exports.sleep = exports.getFilePathsConfigs = exports.annotateChildPods = exports.getWorkflowFilePath = exports.getLastSuccessfulRunSha = exports.checkForErrors = exports.isEqual = exports.getExecutableExtension = void 0;
|
exports.getCurrentTime = exports.getRandomInt = exports.sleep = exports.getFilePathsConfigs = exports.annotateChildPods = exports.getWorkflowFilePath = exports.getLastSuccessfulRunSha = exports.checkForErrors = exports.isEqual = exports.getExecutableExtension = void 0;
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
const core = require("@actions/core");
|
const core = require("@actions/core");
|
||||||
const githubClient_1 = require("../githubClient");
|
const githubClient_1 = require("../githubClient");
|
||||||
const httpClient_1 = require("./httpClient");
|
const httpClient_1 = require("./httpClient");
|
||||||
const exec = require("./exec");
|
const exec = require("./exec");
|
||||||
const inputParams = require("../input-parameters");
|
const inputParams = require("../input-parameters");
|
||||||
function getExecutableExtension() {
|
function getExecutableExtension() {
|
||||||
if (os.type().match(/^Win/)) {
|
if (os.type().match(/^Win/)) {
|
||||||
return '.exe';
|
return '.exe';
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
exports.getExecutableExtension = getExecutableExtension;
|
exports.getExecutableExtension = getExecutableExtension;
|
||||||
function isEqual(str1, str2, ignoreCase) {
|
function isEqual(str1, str2, ignoreCase) {
|
||||||
if (str1 == null && str2 == null) {
|
if (str1 == null && str2 == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (str1 == null || str2 == null) {
|
if (str1 == null || str2 == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (ignoreCase) {
|
if (ignoreCase) {
|
||||||
return str1.toUpperCase() === str2.toUpperCase();
|
return str1.toUpperCase() === str2.toUpperCase();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return str1 === str2;
|
return str1 === str2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.isEqual = isEqual;
|
exports.isEqual = isEqual;
|
||||||
function checkForErrors(execResults, warnIfError) {
|
function checkForErrors(execResults, warnIfError) {
|
||||||
if (execResults.length !== 0) {
|
if (execResults.length !== 0) {
|
||||||
let stderr = '';
|
let stderr = '';
|
||||||
execResults.forEach(result => {
|
execResults.forEach(result => {
|
||||||
if (result && result.stderr) {
|
if (result && result.stderr) {
|
||||||
if (result.code !== 0) {
|
if (result.code !== 0) {
|
||||||
stderr += result.stderr + '\n';
|
stderr += result.stderr + '\n';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.warning(result.stderr);
|
core.warning(result.stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (stderr.length > 0) {
|
if (stderr.length > 0) {
|
||||||
if (warnIfError) {
|
if (warnIfError) {
|
||||||
core.warning(stderr.trim());
|
core.warning(stderr.trim());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error(stderr.trim());
|
throw new Error(stderr.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkForErrors = checkForErrors;
|
exports.checkForErrors = checkForErrors;
|
||||||
function getLastSuccessfulRunSha(kubectl, namespaceName, annotationKey) {
|
function getLastSuccessfulRunSha(kubectl, namespaceName, annotationKey) {
|
||||||
try {
|
try {
|
||||||
const result = kubectl.getResource('namespace', namespaceName);
|
const result = kubectl.getResource('namespace', namespaceName);
|
||||||
if (result) {
|
if (result) {
|
||||||
if (result.stderr) {
|
if (result.stderr) {
|
||||||
core.warning(`${result.stderr}`);
|
core.warning(`${result.stderr}`);
|
||||||
return process.env.GITHUB_SHA;
|
return process.env.GITHUB_SHA;
|
||||||
}
|
}
|
||||||
else if (result.stdout) {
|
else if (result.stdout) {
|
||||||
const annotationsSet = JSON.parse(result.stdout).metadata.annotations;
|
const annotationsSet = JSON.parse(result.stdout).metadata.annotations;
|
||||||
if (annotationsSet && annotationsSet[annotationKey]) {
|
if (annotationsSet && annotationsSet[annotationKey]) {
|
||||||
return JSON.parse(annotationsSet[annotationKey].replace(/'/g, '"')).commit;
|
return JSON.parse(annotationsSet[annotationKey].replace(/'/g, '"')).commit;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 'NA';
|
return 'NA';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
core.warning(`Failed to get commits from cluster. ${JSON.stringify(ex)}`);
|
core.warning(`Failed to get commits from cluster. ${JSON.stringify(ex)}`);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getLastSuccessfulRunSha = getLastSuccessfulRunSha;
|
exports.getLastSuccessfulRunSha = getLastSuccessfulRunSha;
|
||||||
function getWorkflowFilePath(githubToken) {
|
function getWorkflowFilePath(githubToken) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let workflowFilePath = process.env.GITHUB_WORKFLOW;
|
let workflowFilePath = process.env.GITHUB_WORKFLOW;
|
||||||
if (!workflowFilePath.startsWith('.github/workflows/')) {
|
if (!workflowFilePath.startsWith('.github/workflows/')) {
|
||||||
const githubClient = new githubClient_1.GitHubClient(process.env.GITHUB_REPOSITORY, githubToken);
|
const githubClient = new githubClient_1.GitHubClient(process.env.GITHUB_REPOSITORY, githubToken);
|
||||||
const response = yield githubClient.getWorkflows();
|
const response = yield githubClient.getWorkflows();
|
||||||
if (response) {
|
if (response) {
|
||||||
if (response.statusCode == httpClient_1.StatusCodes.OK
|
if (response.statusCode == httpClient_1.StatusCodes.OK
|
||||||
&& response.body
|
&& response.body
|
||||||
&& response.body.total_count) {
|
&& response.body.total_count) {
|
||||||
if (response.body.total_count > 0) {
|
if (response.body.total_count > 0) {
|
||||||
for (let workflow of response.body.workflows) {
|
for (let workflow of response.body.workflows) {
|
||||||
if (process.env.GITHUB_WORKFLOW === workflow.name) {
|
if (process.env.GITHUB_WORKFLOW === workflow.name) {
|
||||||
workflowFilePath = workflow.path;
|
workflowFilePath = workflow.path;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (response.statusCode != httpClient_1.StatusCodes.OK) {
|
else if (response.statusCode != httpClient_1.StatusCodes.OK) {
|
||||||
core.debug(`An error occured while getting list of workflows on the repo. Statuscode: ${response.statusCode}, StatusMessage: ${response.statusMessage}`);
|
core.debug(`An error occured while getting list of workflows on the repo. Statuscode: ${response.statusCode}, StatusMessage: ${response.statusMessage}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.warning(`Failed to get response from workflow list API`);
|
core.warning(`Failed to get response from workflow list API`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Promise.resolve(workflowFilePath);
|
return Promise.resolve(workflowFilePath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getWorkflowFilePath = getWorkflowFilePath;
|
exports.getWorkflowFilePath = getWorkflowFilePath;
|
||||||
function annotateChildPods(kubectl, resourceType, resourceName, annotationKeyValStr, allPods) {
|
function annotateChildPods(kubectl, resourceType, resourceName, annotationKeyValStr, allPods) {
|
||||||
const commandExecutionResults = [];
|
const commandExecutionResults = [];
|
||||||
let owner = resourceName;
|
let owner = resourceName;
|
||||||
if (resourceType.toLowerCase().indexOf('deployment') > -1) {
|
if (resourceType.toLowerCase().indexOf('deployment') > -1) {
|
||||||
owner = kubectl.getNewReplicaSet(resourceName);
|
owner = kubectl.getNewReplicaSet(resourceName);
|
||||||
}
|
}
|
||||||
if (allPods && allPods.items && allPods.items.length > 0) {
|
if (allPods && allPods.items && allPods.items.length > 0) {
|
||||||
allPods.items.forEach((pod) => {
|
allPods.items.forEach((pod) => {
|
||||||
const owners = pod.metadata.ownerReferences;
|
const owners = pod.metadata.ownerReferences;
|
||||||
if (owners) {
|
if (owners) {
|
||||||
owners.forEach(ownerRef => {
|
owners.forEach(ownerRef => {
|
||||||
if (ownerRef.name === owner) {
|
if (ownerRef.name === owner) {
|
||||||
commandExecutionResults.push(kubectl.annotate('pod', pod.metadata.name, annotationKeyValStr));
|
commandExecutionResults.push(kubectl.annotate('pod', pod.metadata.name, annotationKeyValStr));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return commandExecutionResults;
|
return commandExecutionResults;
|
||||||
}
|
}
|
||||||
exports.annotateChildPods = annotateChildPods;
|
exports.annotateChildPods = annotateChildPods;
|
||||||
function getFilePathsConfigs() {
|
function getFilePathsConfigs() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let filePathsConfig = {};
|
let filePathsConfig = {};
|
||||||
const MANIFEST_PATHS_KEY = 'manifestFilePaths';
|
const MANIFEST_PATHS_KEY = 'manifestFilePaths';
|
||||||
const HELM_CHART_KEY = 'helmChartFilePaths';
|
const HELM_CHART_KEY = 'helmChartFilePaths';
|
||||||
const DOCKERFILE_PATH_KEY = 'dockerfilePaths';
|
const DOCKERFILE_PATH_KEY = 'dockerfilePaths';
|
||||||
const DOCKERFILE_PATH_LABEL_KEY = 'dockerfile-path';
|
const DOCKERFILE_PATH_LABEL_KEY = 'dockerfile-path';
|
||||||
let inputManifestFiles = inputParams.manifests || [];
|
let inputManifestFiles = inputParams.manifests || [];
|
||||||
filePathsConfig[MANIFEST_PATHS_KEY] = inputManifestFiles;
|
filePathsConfig[MANIFEST_PATHS_KEY] = inputManifestFiles;
|
||||||
let helmChartPaths = process.env.HELM_CHART_PATHS || '';
|
let helmChartPaths = process.env.HELM_CHART_PATHS || '';
|
||||||
filePathsConfig[HELM_CHART_KEY] = helmChartPaths;
|
filePathsConfig[HELM_CHART_KEY] = helmChartPaths;
|
||||||
//Fetch labels from each image
|
//Fetch labels from each image
|
||||||
let imageToBuildConfigMap = [];
|
let imageToBuildConfigMap = [];
|
||||||
let imageNames = core.getInput('images').split('\n');
|
let imageNames = core.getInput('images').split('\n');
|
||||||
for (const image of imageNames) {
|
for (const image of imageNames) {
|
||||||
let args = [image];
|
let args = [image];
|
||||||
let resultObj;
|
let resultObj;
|
||||||
let containerRegistryName = image;
|
let containerRegistryName = image;
|
||||||
try {
|
try {
|
||||||
let usrname = process.env.CR_USERNAME || null;
|
let usrname = process.env.CR_USERNAME || null;
|
||||||
let pwd = process.env.CR_PASSWORD || null;
|
let pwd = process.env.CR_PASSWORD || null;
|
||||||
if (pwd && usrname) {
|
if (pwd && usrname) {
|
||||||
let loginArgs = [containerRegistryName, '--username', usrname, '--password', pwd];
|
let loginArgs = [containerRegistryName, '--username', usrname, '--password', pwd];
|
||||||
yield exec.exec('docker login ', loginArgs, true).then(res => {
|
yield exec.exec('docker login ', loginArgs, true).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(`docker login failed with: ${res.stderr.match(/(.*)\s*$/)[0]}`);
|
throw new Error(`docker login failed with: ${res.stderr.match(/(.*)\s*$/)[0]}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
yield exec.exec('docker pull ', args, true).then(res => {
|
yield exec.exec('docker pull ', args, true).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(`docker images pull failed with: ${res.stderr.match(/(.*)\s*$/)[0]}`);
|
throw new Error(`docker images pull failed with: ${res.stderr.match(/(.*)\s*$/)[0]}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
yield exec.exec('docker inspect --type=image', args, true).then(res => {
|
yield exec.exec('docker inspect --type=image', args, true).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(`docker inspect call failed with: ${res.stderr.match(/(.*)\s*$/)[0]}`);
|
throw new Error(`docker inspect call failed with: ${res.stderr.match(/(.*)\s*$/)[0]}`);
|
||||||
}
|
}
|
||||||
if (!res.stdout) {
|
if (!res.stdout) {
|
||||||
resultObj = JSON.parse(res.stdout);
|
resultObj = JSON.parse(res.stdout);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
core.warning(`Failed to get dockerfile paths for image ${image.toString()} | ` + ex);
|
core.warning(`Failed to get dockerfile paths for image ${image.toString()} | ` + ex);
|
||||||
}
|
}
|
||||||
if (!resultObj) {
|
if (!resultObj) {
|
||||||
resultObj = resultObj[0];
|
resultObj = resultObj[0];
|
||||||
if (!(resultObj.Config) && !(resultObj.Config.Labels) && !(resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY])) {
|
if (!(resultObj.Config) && !(resultObj.Config.Labels) && !(resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY])) {
|
||||||
imageToBuildConfigMap[image] = resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY];
|
imageToBuildConfigMap[image] = resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filePathsConfig[DOCKERFILE_PATH_KEY] = imageToBuildConfigMap;
|
filePathsConfig[DOCKERFILE_PATH_KEY] = imageToBuildConfigMap;
|
||||||
return Promise.resolve(filePathsConfig);
|
return Promise.resolve(filePathsConfig);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getFilePathsConfigs = getFilePathsConfigs;
|
exports.getFilePathsConfigs = getFilePathsConfigs;
|
||||||
function sleep(timeout) {
|
function sleep(timeout) {
|
||||||
return new Promise(resolve => setTimeout(resolve, timeout));
|
return new Promise(resolve => setTimeout(resolve, timeout));
|
||||||
}
|
}
|
||||||
exports.sleep = sleep;
|
exports.sleep = sleep;
|
||||||
function getRandomInt(max) {
|
function getRandomInt(max) {
|
||||||
return Math.floor(Math.random() * Math.floor(max));
|
return Math.floor(Math.random() * Math.floor(max));
|
||||||
}
|
}
|
||||||
exports.getRandomInt = getRandomInt;
|
exports.getRandomInt = getRandomInt;
|
||||||
function getCurrentTime() {
|
function getCurrentTime() {
|
||||||
return new Date().getTime();
|
return new Date().getTime();
|
||||||
}
|
}
|
||||||
exports.getCurrentTime = getCurrentTime;
|
exports.getCurrentTime = getCurrentTime;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user