mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-04-16 11:32:19 +08:00
JSON structure fixes of config paths
This commit is contained in:
parent
d0f7e63ea0
commit
41514fca22
@ -26,7 +26,7 @@ exports.deploymentTypes = ['deployment', 'replicaset', 'daemonset', 'pod', 'stat
|
||||
exports.workloadTypes = ['deployment', 'replicaset', 'daemonset', 'pod', 'statefulset', 'job', 'cronjob'];
|
||||
exports.workloadTypesWithRolloutStatus = ['deployment', 'daemonset', 'statefulset'];
|
||||
function getWorkflowAnnotationsJson(lastSuccessRunSha, workflowFilePath, filePathConfigs) {
|
||||
return JSON.stringify(`{`
|
||||
return `{`
|
||||
+ `'run': '${process.env.GITHUB_RUN_ID}',`
|
||||
+ `'repository': '${process.env.GITHUB_REPOSITORY}',`
|
||||
+ `'workflow': '${process.env.GITHUB_WORKFLOW}',`
|
||||
@ -38,10 +38,11 @@ function getWorkflowAnnotationsJson(lastSuccessRunSha, workflowFilePath, filePat
|
||||
+ `'lastSuccessRunCommit': '${lastSuccessRunSha}',`
|
||||
+ `'branch': '${process.env.GITHUB_REF}',`
|
||||
+ `'deployTimestamp': '${Date.now()}',`
|
||||
+ `'manifestsPaths': '${filePathConfigs.manifestFilePaths}',`
|
||||
+ `'dockerfilePaths': '${filePathConfigs.buildConfigs}',`
|
||||
+ `'dockerfilePaths': ${JSON.stringify(filePathConfigs.dockerfilePaths)},`
|
||||
+ `'manifestsPaths': ${JSON.stringify(filePathConfigs.manifestFilePaths)},`
|
||||
+ `'helmChartPaths': ${JSON.stringify(filePathConfigs.helmChartPaths)},`
|
||||
+ `'provider': 'GitHub'`
|
||||
+ `}`);
|
||||
+ `}`;
|
||||
}
|
||||
exports.getWorkflowAnnotationsJson = getWorkflowAnnotationsJson;
|
||||
function getWorkflowAnnotationKeyLabel(workflowFilePath) {
|
||||
|
||||
@ -142,24 +142,21 @@ exports.annotateChildPods = annotateChildPods;
|
||||
function getFilePathsConfigs() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let filePathsConfig = {};
|
||||
const BUILD_CONFIG_KEY = 'buildConfigs';
|
||||
const MANIFEST_PATHS_KEY = 'manifestFilePaths';
|
||||
const HELM_CHART_KEY = 'helmChartFilePaths';
|
||||
const DOCKERFILE_PATH_KEY = 'dockerfilePaths';
|
||||
const DOCKERFILE_PATH_LABEL_KEY = 'dockerfile-path';
|
||||
const DOCKERFILE_PATH_KEY = 'dockerfilePath';
|
||||
const CONTAINER_REG_KEY = 'containerRegistryServer';
|
||||
let inputManifestFiles = inputParams.manifests || [];
|
||||
filePathsConfig[MANIFEST_PATHS_KEY] = JSON.stringify(inputManifestFiles);
|
||||
filePathsConfig[MANIFEST_PATHS_KEY] = inputManifestFiles;
|
||||
let helmChartPaths = process.env.HELM_CHART_PATHS || '';
|
||||
filePathsConfig[HELM_CHART_KEY] = helmChartPaths;
|
||||
//Fetch labels from each image
|
||||
let imageToBuildConfigMap = {};
|
||||
let imageToBuildConfigMap = [];
|
||||
let imageNames = core.getInput('images').split('\n');
|
||||
for (const image of imageNames) {
|
||||
let args = [image];
|
||||
let resultObj;
|
||||
let buildConfigMap = {};
|
||||
let containerRegistryName = image.toString().split('/')[0];
|
||||
let containerRegistryName = image;
|
||||
try {
|
||||
let usrname = process.env.CR_USERNAME || null;
|
||||
let pwd = process.env.CR_PASSWORD || null;
|
||||
@ -191,16 +188,11 @@ function getFilePathsConfigs() {
|
||||
if (!resultObj) {
|
||||
resultObj = resultObj[0];
|
||||
if (!(resultObj.Config) && !(resultObj.Config.Labels) && !(resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY])) {
|
||||
buildConfigMap[DOCKERFILE_PATH_KEY] = resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY];
|
||||
}
|
||||
//Add CR server name to build config
|
||||
buildConfigMap[CONTAINER_REG_KEY] = containerRegistryName;
|
||||
if (!resultObj.Id) {
|
||||
imageToBuildConfigMap[resultObj.Id] = buildConfigMap;
|
||||
imageToBuildConfigMap[image] = resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY];
|
||||
}
|
||||
}
|
||||
}
|
||||
filePathsConfig[BUILD_CONFIG_KEY] = JSON.stringify(imageToBuildConfigMap);
|
||||
filePathsConfig[DOCKERFILE_PATH_KEY] = imageToBuildConfigMap;
|
||||
return Promise.resolve(filePathsConfig);
|
||||
});
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ export const workloadTypes: string[] = ['deployment', 'replicaset', 'daemonset',
|
||||
export const workloadTypesWithRolloutStatus: string[] = ['deployment', 'daemonset', 'statefulset'];
|
||||
|
||||
export function getWorkflowAnnotationsJson(lastSuccessRunSha: string, workflowFilePath: string, filePathConfigs: any): string {
|
||||
return JSON.stringify(`{`
|
||||
return `{`
|
||||
+ `'run': '${process.env.GITHUB_RUN_ID}',`
|
||||
+ `'repository': '${process.env.GITHUB_REPOSITORY}',`
|
||||
+ `'workflow': '${process.env.GITHUB_WORKFLOW}',`
|
||||
@ -38,10 +38,11 @@ export function getWorkflowAnnotationsJson(lastSuccessRunSha: string, workflowFi
|
||||
+ `'lastSuccessRunCommit': '${lastSuccessRunSha}',`
|
||||
+ `'branch': '${process.env.GITHUB_REF}',`
|
||||
+ `'deployTimestamp': '${Date.now()}',`
|
||||
+ `'manifestsPaths': '${filePathConfigs.manifestFilePaths}',`
|
||||
+ `'dockerfilePaths': '${filePathConfigs.buildConfigs}',`
|
||||
+ `'dockerfilePaths': ${JSON.stringify(filePathConfigs.dockerfilePaths)},`
|
||||
+ `'manifestsPaths': ${JSON.stringify(filePathConfigs.manifestFilePaths)},`
|
||||
+ `'helmChartPaths': ${JSON.stringify(filePathConfigs.helmChartPaths)},`
|
||||
+ `'provider': 'GitHub'`
|
||||
+ `}`);
|
||||
+ `}`;
|
||||
}
|
||||
|
||||
export function getWorkflowAnnotationKeyLabel(workflowFilePath: string): string {
|
||||
|
||||
@ -132,28 +132,25 @@ export function annotateChildPods(kubectl: Kubectl, resourceType: string, resour
|
||||
export async function getFilePathsConfigs(): Promise<any> {
|
||||
|
||||
let filePathsConfig: any = {};
|
||||
const BUILD_CONFIG_KEY = 'buildConfigs';
|
||||
const MANIFEST_PATHS_KEY = 'manifestFilePaths';
|
||||
const HELM_CHART_KEY = 'helmChartFilePaths';
|
||||
const DOCKERFILE_PATH_KEY = 'dockerfilePaths';
|
||||
const DOCKERFILE_PATH_LABEL_KEY = 'dockerfile-path';
|
||||
const DOCKERFILE_PATH_KEY = 'dockerfilePath';
|
||||
const CONTAINER_REG_KEY = 'containerRegistryServer';
|
||||
|
||||
let inputManifestFiles = inputParams.manifests || [];
|
||||
filePathsConfig[MANIFEST_PATHS_KEY] = JSON.stringify(inputManifestFiles);
|
||||
filePathsConfig[MANIFEST_PATHS_KEY] = inputManifestFiles;
|
||||
|
||||
let helmChartPaths = process.env.HELM_CHART_PATHS || '';
|
||||
filePathsConfig[HELM_CHART_KEY] = helmChartPaths;
|
||||
|
||||
//Fetch labels from each image
|
||||
let imageToBuildConfigMap: any = {};
|
||||
let imageToBuildConfigMap: any = [];
|
||||
let imageNames = core.getInput('images').split('\n');
|
||||
|
||||
for(const image of imageNames){
|
||||
let args: string[] = [image];
|
||||
let resultObj: any;
|
||||
let buildConfigMap : any = {};
|
||||
let containerRegistryName = image.toString().split('/')[0];
|
||||
let containerRegistryName = image;
|
||||
|
||||
try{
|
||||
let usrname = process.env.CR_USERNAME || null;
|
||||
@ -190,20 +187,13 @@ export async function getFilePathsConfigs(): Promise<any> {
|
||||
|
||||
if(!resultObj){
|
||||
resultObj = resultObj[0];
|
||||
|
||||
if(!(resultObj.Config) && !(resultObj.Config.Labels) && !(resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY])){
|
||||
buildConfigMap[DOCKERFILE_PATH_KEY] = resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY];
|
||||
}
|
||||
|
||||
//Add CR server name to build config
|
||||
buildConfigMap[CONTAINER_REG_KEY] = containerRegistryName;
|
||||
if(!resultObj.Id){
|
||||
imageToBuildConfigMap[resultObj.Id] = buildConfigMap;
|
||||
imageToBuildConfigMap[image] = resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
filePathsConfig[BUILD_CONFIG_KEY] = JSON.stringify(imageToBuildConfigMap);
|
||||
filePathsConfig[DOCKERFILE_PATH_KEY] = imageToBuildConfigMap;
|
||||
|
||||
return Promise.resolve(filePathsConfig);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user