-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MWPW-164197 - Clear the Blocked Queue by Pausing a Project
- Loading branch information
1 parent
6859845
commit 076fa6c
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters