fix age calculations
parent
ebca70b530
commit
388a42d514
|
|
@ -1984,9 +1984,9 @@ const base_stack_formation_1 = __nccwpck_require__(29643);
|
|||
class AwsCliCommands {
|
||||
static awsListAll() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield AwsCliCommands.awsListStacks(undefined, true);
|
||||
yield AwsCliCommands.awsListStacks();
|
||||
yield AwsCliCommands.awsListTasks();
|
||||
yield AwsCliCommands.awsListLogGroups(undefined, true);
|
||||
yield AwsCliCommands.awsListLogGroups();
|
||||
});
|
||||
}
|
||||
static garbageCollectAws() {
|
||||
|
|
@ -2008,7 +2008,7 @@ class AwsCliCommands {
|
|||
const ageDate = new Date(date.getTime() - Date.now());
|
||||
return ageDate.getDay() > 0;
|
||||
}
|
||||
static awsListStacks(perResultCallback = false, verbose = false) {
|
||||
static awsListStacks(perResultCallback = false) {
|
||||
var _a, _b;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
process.env.AWS_REGION = input_1.default.region;
|
||||
|
|
@ -2016,18 +2016,18 @@ class AwsCliCommands {
|
|||
const stacks = ((_a = (yield CF.listStacks().promise()).StackSummaries) === null || _a === void 0 ? void 0 : _a.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE')) || [];
|
||||
cloud_runner_logger_1.default.log(`Stacks ${stacks.length}`);
|
||||
for (const element of stacks) {
|
||||
const ageDate = new Date(element.CreationTime.getTime() - Date.now());
|
||||
if (verbose)
|
||||
cloud_runner_logger_1.default.log(`Task Stack ${element.StackName} - Age D${ageDate.getDay()} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
||||
const ageDate = new Date(Date.now() - element.CreationTime.getTime());
|
||||
// if (verbose)
|
||||
cloud_runner_logger_1.default.log(`Task Stack ${element.StackName} - Age D${Math.floor(ageDate.getHours() / 24)} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
||||
if (perResultCallback)
|
||||
yield perResultCallback(element);
|
||||
}
|
||||
const baseStacks = ((_b = (yield CF.listStacks().promise()).StackSummaries) === null || _b === void 0 ? void 0 : _b.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE' && _x.TemplateDescription === base_stack_formation_1.BaseStackFormation.baseStackDecription)) || [];
|
||||
cloud_runner_logger_1.default.log(`Base Stacks ${baseStacks.length}`);
|
||||
for (const element of baseStacks) {
|
||||
const ageDate = new Date(element.CreationTime.getTime() - Date.now());
|
||||
if (verbose)
|
||||
cloud_runner_logger_1.default.log(`Base Stack ${element.StackName} - Age D${ageDate.getHours()} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
||||
const ageDate = new Date(Date.now() - element.CreationTime.getTime());
|
||||
// if (verbose)
|
||||
cloud_runner_logger_1.default.log(`Task Stack ${element.StackName} - Age D${Math.floor(ageDate.getHours() / 24)} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
||||
if (perResultCallback)
|
||||
yield perResultCallback(element);
|
||||
}
|
||||
|
|
@ -2071,7 +2071,7 @@ class AwsCliCommands {
|
|||
}
|
||||
});
|
||||
}
|
||||
static awsListLogGroups(perResultCallback = false, verbose = false) {
|
||||
static awsListLogGroups(perResultCallback = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
process.env.AWS_REGION = input_1.default.region;
|
||||
const ecs = new aws_sdk_1.default.CloudWatchLogs();
|
||||
|
|
@ -2091,15 +2091,15 @@ class AwsCliCommands {
|
|||
cloud_runner_logger_1.default.log(`Skipping ${element.logGroupName} no createdAt date`);
|
||||
continue;
|
||||
}
|
||||
const ageDate = new Date(new Date(element.creationTime).getTime() - Date.now());
|
||||
if (verbose)
|
||||
cloud_runner_logger_1.default.log(`Log Group Name ${element.logGroupName} - Age D${ageDate.getDay()} H${ageDate.getHours()} M${ageDate.getMinutes()} - 1d old ${AwsCliCommands.isOlderThan1day(new Date(element.creationTime))}`);
|
||||
const ageDate = new Date(Date.now() - element.creationTime);
|
||||
// if (verbose)
|
||||
cloud_runner_logger_1.default.log(`Task Stack ${element.logGroupName} - Age D${Math.floor(ageDate.getHours() / 24)} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
||||
if (perResultCallback)
|
||||
yield perResultCallback(element, element);
|
||||
}
|
||||
});
|
||||
}
|
||||
static awsListJobs(perResultCallback = false, verbose = false) {
|
||||
static awsListJobs(perResultCallback = false) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
process.env.AWS_REGION = input_1.default.region;
|
||||
|
|
@ -2107,9 +2107,9 @@ class AwsCliCommands {
|
|||
const stacks = ((_a = (yield CF.listStacks().promise()).StackSummaries) === null || _a === void 0 ? void 0 : _a.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE' && _x.TemplateDescription !== base_stack_formation_1.BaseStackFormation.baseStackDecription)) || [];
|
||||
cloud_runner_logger_1.default.log(`Stacks ${stacks.length}`);
|
||||
for (const element of stacks) {
|
||||
const ageDate = new Date(element.CreationTime.getTime() - Date.now());
|
||||
if (verbose)
|
||||
cloud_runner_logger_1.default.log(`Task Stack ${element.StackName} - Age D${ageDate.getDay()} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
||||
const ageDate = new Date(Date.now() - element.CreationTime.getTime());
|
||||
// if (verbose)
|
||||
cloud_runner_logger_1.default.log(`Task Stack ${element.StackName} - Age D${Math.floor(ageDate.getHours() / 24)} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
||||
if (perResultCallback)
|
||||
yield perResultCallback(element);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -7,9 +7,9 @@ import { BaseStackFormation } from '../cloud-formations/base-stack-formation';
|
|||
export class AwsCliCommands {
|
||||
@CliFunction(`aws-list-all`, `List all resources`)
|
||||
static async awsListAll() {
|
||||
await AwsCliCommands.awsListStacks(undefined, true);
|
||||
await AwsCliCommands.awsListStacks();
|
||||
await AwsCliCommands.awsListTasks();
|
||||
await AwsCliCommands.awsListLogGroups(undefined, true);
|
||||
await AwsCliCommands.awsListLogGroups();
|
||||
}
|
||||
@CliFunction(`aws-garbage-collect-list`, `garbage collect aws resources not in use !WIP!`)
|
||||
static async garbageCollectAws() {
|
||||
|
|
@ -32,7 +32,7 @@ export class AwsCliCommands {
|
|||
return ageDate.getDay() > 0;
|
||||
}
|
||||
@CliFunction(`aws-list-stacks`, `List stacks`)
|
||||
static async awsListStacks(perResultCallback: any = false, verbose: boolean = false) {
|
||||
static async awsListStacks(perResultCallback: any = false) {
|
||||
process.env.AWS_REGION = Input.region;
|
||||
const CF = new AWS.CloudFormation();
|
||||
const stacks =
|
||||
|
|
@ -42,11 +42,14 @@ export class AwsCliCommands {
|
|||
) || [];
|
||||
CloudRunnerLogger.log(`Stacks ${stacks.length}`);
|
||||
for (const element of stacks) {
|
||||
const ageDate = new Date(element.CreationTime.getTime() - Date.now());
|
||||
if (verbose)
|
||||
CloudRunnerLogger.log(
|
||||
`Task Stack ${element.StackName} - Age D${ageDate.getDay()} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
||||
);
|
||||
const ageDate: Date = new Date(Date.now() - element.CreationTime.getTime());
|
||||
|
||||
// if (verbose)
|
||||
CloudRunnerLogger.log(
|
||||
`Task Stack ${element.StackName} - Age D${Math.floor(
|
||||
ageDate.getHours() / 24,
|
||||
)} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
||||
);
|
||||
if (perResultCallback) await perResultCallback(element);
|
||||
}
|
||||
const baseStacks =
|
||||
|
|
@ -56,13 +59,14 @@ export class AwsCliCommands {
|
|||
) || [];
|
||||
CloudRunnerLogger.log(`Base Stacks ${baseStacks.length}`);
|
||||
for (const element of baseStacks) {
|
||||
const ageDate = new Date(element.CreationTime.getTime() - Date.now());
|
||||
if (verbose)
|
||||
CloudRunnerLogger.log(
|
||||
`Base Stack ${
|
||||
element.StackName
|
||||
} - Age D${ageDate.getHours()} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
||||
);
|
||||
const ageDate: Date = new Date(Date.now() - element.CreationTime.getTime());
|
||||
|
||||
// if (verbose)
|
||||
CloudRunnerLogger.log(
|
||||
`Task Stack ${element.StackName} - Age D${Math.floor(
|
||||
ageDate.getHours() / 24,
|
||||
)} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
||||
);
|
||||
if (perResultCallback) await perResultCallback(element);
|
||||
}
|
||||
if (stacks === undefined) {
|
||||
|
|
@ -104,7 +108,7 @@ export class AwsCliCommands {
|
|||
}
|
||||
}
|
||||
@CliFunction(`aws-list-log-groups`, `List tasks`)
|
||||
static async awsListLogGroups(perResultCallback: any = false, verbose: boolean = false) {
|
||||
static async awsListLogGroups(perResultCallback: any = false) {
|
||||
process.env.AWS_REGION = Input.region;
|
||||
const ecs = new AWS.CloudWatchLogs();
|
||||
let logStreamInput: AWS.CloudWatchLogs.DescribeLogGroupsRequest = {
|
||||
|
|
@ -124,21 +128,20 @@ export class AwsCliCommands {
|
|||
CloudRunnerLogger.log(`Skipping ${element.logGroupName} no createdAt date`);
|
||||
continue;
|
||||
}
|
||||
const ageDate = new Date(new Date(element.creationTime).getTime() - Date.now());
|
||||
if (verbose)
|
||||
CloudRunnerLogger.log(
|
||||
`Log Group Name ${
|
||||
element.logGroupName
|
||||
} - Age D${ageDate.getDay()} H${ageDate.getHours()} M${ageDate.getMinutes()} - 1d old ${AwsCliCommands.isOlderThan1day(
|
||||
new Date(element.creationTime),
|
||||
)}`,
|
||||
);
|
||||
const ageDate: Date = new Date(Date.now() - element.creationTime);
|
||||
|
||||
// if (verbose)
|
||||
CloudRunnerLogger.log(
|
||||
`Task Stack ${element.logGroupName} - Age D${Math.floor(
|
||||
ageDate.getHours() / 24,
|
||||
)} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
||||
);
|
||||
if (perResultCallback) await perResultCallback(element, element);
|
||||
}
|
||||
}
|
||||
|
||||
@CliFunction(`aws-list-jobs`, `List tasks`)
|
||||
static async awsListJobs(perResultCallback: any = false, verbose: boolean = false) {
|
||||
static async awsListJobs(perResultCallback: any = false) {
|
||||
process.env.AWS_REGION = Input.region;
|
||||
const CF = new AWS.CloudFormation();
|
||||
const stacks =
|
||||
|
|
@ -148,11 +151,14 @@ export class AwsCliCommands {
|
|||
) || [];
|
||||
CloudRunnerLogger.log(`Stacks ${stacks.length}`);
|
||||
for (const element of stacks) {
|
||||
const ageDate = new Date(element.CreationTime.getTime() - Date.now());
|
||||
if (verbose)
|
||||
CloudRunnerLogger.log(
|
||||
`Task Stack ${element.StackName} - Age D${ageDate.getDay()} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
||||
);
|
||||
const ageDate: Date = new Date(Date.now() - element.CreationTime.getTime());
|
||||
|
||||
// if (verbose)
|
||||
CloudRunnerLogger.log(
|
||||
`Task Stack ${element.StackName} - Age D${Math.floor(
|
||||
ageDate.getHours() / 24,
|
||||
)} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
||||
);
|
||||
if (perResultCallback) await perResultCallback(element);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue