Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adf-cli k8s-clean-app - Add more logs and default interval #5826

Merged
merged 1 commit into from
Jul 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/cli/scripts/kubectl-clean-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,26 @@ async function main(args) {
useContext(args);

const applications = args.apps.includes(',') ? args.apps.split(',') : [args.apps];

const interval = args.intervalTime ? args.intervalTime : '30 min';
const extractTimeRange = interval.split(' ')[0];
logger.info(`Extract time ${extractTimeRange} from interval: ${interval}`);

for (let i = 0; i < applications.length; i++ ) {
logger.info(`Perform action on app: ${applications[i]}`);
if (args.enableLike) {
const applicationsByName = await getApplicationsByName(args, alfrescoJsApiDevops, applications[i]);
logger.info(`Found ${applicationsByName.length} apps`);
for (let y = 0; y < applicationsByName.length; y++ ) {
const extractTimeRange = args.intervalTime.split(' ')[0];
const application = applicationsByName[y].entry;
logger.info(`Analyze app: ${application.name} `);
const diffAsMinutes = moment.duration(moment().diff(moment(application.createdAt))).asMinutes();
if (diffAsMinutes > extractTimeRange) {
logger.info(`The app: ${application} is older than ${args.intervalTime}. Can delete it`);
logger.info(`The app: ${application} is older than ${interval}. Can delete it`);
await undeployApplication(args, alfrescoJsApiDevops, application.name);
await deleteDescriptor(args, alfrescoJsApiDevops, application.name);
await deleteProjectByName(args, alfrescoJsApiModeler, application.name);
} else {
logger.info(`The app: ${application} is recent than ${args.intervalTime}. Skip delete`);
logger.info(`The app: ${application} is recent than ${interval}. Skip delete`);
}
}
} else {
Expand Down