mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-27 23:39:27 +08:00
Added reading dockerfile from env var, code cleanup
This commit is contained in:
@@ -150,14 +150,24 @@ function getFilePathsConfigs() {
|
||||
filePathsConfig[MANIFEST_PATHS_KEY] = inputManifestFiles;
|
||||
let helmChartPaths = (process.env.HELM_CHART_PATHS && process.env.HELM_CHART_PATHS.split('\n').filter(path => path != "")) || [];
|
||||
filePathsConfig[HELM_CHART_KEY] = helmChartPaths;
|
||||
//Fetch labels from each image
|
||||
//Parsing dockerfile paths for images
|
||||
let imageNames = core.getInput('images').split('\n');
|
||||
let imageDockerfilePathList = [];
|
||||
let imageDockerfilePathMap = {};
|
||||
let pathKey, pathVal;
|
||||
//Fetching from env var if available
|
||||
let dockerfilePathsList = (process.env.DOCKERFILEPATHS && process.env.DOCKERFILEPATHS.split('\n')) || [];
|
||||
dockerfilePathsList.forEach(path => {
|
||||
if (path) {
|
||||
pathKey = path.split(' ')[0];
|
||||
pathVal = path.split(' ')[1];
|
||||
imageDockerfilePathMap[pathKey] = pathVal;
|
||||
}
|
||||
});
|
||||
//Fetching from image lable if available
|
||||
for (const image of imageNames) {
|
||||
let args = [image];
|
||||
let resultObj;
|
||||
let containerRegistryName = image;
|
||||
let imageDockerfilePathObj = {};
|
||||
try {
|
||||
let usrname = process.env.CR_USERNAME || null;
|
||||
let pwd = process.env.CR_PASSWORD || null;
|
||||
@@ -189,15 +199,17 @@ function getFilePathsConfigs() {
|
||||
if (resultObj) {
|
||||
resultObj = resultObj[0];
|
||||
if ((resultObj.Config) && (resultObj.Config.Labels) && (resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY])) {
|
||||
imageDockerfilePathObj[image] = resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY];
|
||||
pathVal = resultObj.Config.Labels[DOCKERFILE_PATH_LABEL_KEY];
|
||||
}
|
||||
else {
|
||||
imageDockerfilePathObj[image] = 'Not available';
|
||||
pathVal = 'Not available';
|
||||
}
|
||||
if (!imageDockerfilePathMap[image]) { //If (image : someVal) does not exist from env var parsing then add
|
||||
imageDockerfilePathMap[image] = pathVal;
|
||||
}
|
||||
imageDockerfilePathList.push(imageDockerfilePathObj);
|
||||
}
|
||||
}
|
||||
filePathsConfig[DOCKERFILE_PATH_KEY] = imageDockerfilePathList;
|
||||
filePathsConfig[DOCKERFILE_PATH_KEY] = imageDockerfilePathMap;
|
||||
return Promise.resolve(filePathsConfig);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user