Skip to content

Commit

Permalink
MWPW-164197 - Clear the Blocked Queue by Pausing a Project
Browse files Browse the repository at this point in the history
  • Loading branch information
arshadparwaiz committed Dec 13, 2024
1 parent 6859845 commit 076fa6c
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
81 changes: 81 additions & 0 deletions actions/graybox/pause-project-in-queue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* ************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2024 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
************************************************************************* */

// eslint-disable-next-line import/no-extraneous-dependencies
const initFilesWrapper = require('./filesWrapper');
const { getAioLogger } = require('../utils');
/**
* This Action Sets the project status to paused in Project Queue & the Project Status JSON of that project
*/
async function main(params) {
const logger = getAioLogger();
const filesWrapper = await initFilesWrapper(logger);
let responsePayload = 'Graybox Pause Project in Project Queue action invoked';
let responseCode = 200;
logger.info(responsePayload);
try {
const { projectPath } = params;
logger.info(`Project to be paused :: ${projectPath}`);
const projectQueuePath = 'graybox_promote/project_queue.json';
if (await filesWrapper.fileExists(projectQueuePath)) {
const projectQueue = await filesWrapper.readFileIntoObject(projectQueuePath);
if (projectQueue) {
const index = projectQueue.findIndex((obj) => obj.projectPath === projectPath);
if (!index) {
responsePayload = `No project with ${projectPath} path exists in the project queue`;
return {
code: responseCode,
payload: responsePayload,
};
}
logger.info(`In Pause Project Action, Before pausing, Project Queue Json: ${JSON.stringify(projectQueue)}`);
projectQueue[index].status = 'paused';
await filesWrapper.writeFile(projectQueuePath, projectQueue);
const project = projectQueue[index].projectPath;
logger.info(`In Pause Project Action, After pausing, Project Queue Json: ${JSON.stringify(projectQueue)}`);
const projectStatusJson = await filesWrapper.readFileIntoObject(`graybox_promote${project}/status.json`);
logger.info(`In Pause Graybox Project, Before Pausing Project Status Json: ${JSON.stringify(projectStatusJson)}`);
projectStatusJson.status = 'paused';
await filesWrapper.writeFile(`graybox_promote${project}/status.json`, projectStatusJson);
} else {
responsePayload = `Project Queue empty. No project with ${projectPath} path exists`;
return {
code: responseCode,
payload: responsePayload,
};
}
} else {
responsePayload = 'Project Queue file doesn\'t exist in AIO';
return {
code: responseCode,
payload: responsePayload,
};
}
} catch (err) {
responsePayload = 'Unknown error occurred';
logger.error(`${responsePayload}: ${err}`);
responsePayload = err;
responseCode = 500;
}

return {
code: responseCode,
payload: responsePayload,
};
}

exports.main = main;
6 changes: 6 additions & 0 deletions app.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ application:
limits:
timeout: 3600000
memorySize: 2048
pause-project-in-queue:
function: actions/graybox/pause-project-in-queue.js
web: 'yes'
runtime: nodejs:18
inputs:
LOG_LEVEL: debug
preview-sched:
function: actions/graybox/preview-sched.js
web: 'no'
Expand Down

0 comments on commit 076fa6c

Please sign in to comment.