Skip to content

Commit e5032d5

Browse files
committed
Merge branch 'master' into enableECSManagedTags
2 parents 52c40fc + 6b5f48e commit e5032d5

File tree

5 files changed

+87
-547
lines changed

5 files changed

+87
-547
lines changed

dist/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const IGNORED_TASK_DEFINITION_ATTRIBUTES = [
2727
];
2828

2929
// Method to run a stand-alone task with desired inputs
30-
async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
30+
async function runTask(ecs, clusterName, taskDefArn, waitForMinutes, enableECSManagedTags) {
3131
core.info('Running task')
3232

3333
const waitForTask = core.getInput('wait-for-task-stopped', { required: false }) || 'false';
@@ -60,7 +60,8 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
6060
containerOverrides: containerOverrides
6161
},
6262
launchType: launchType,
63-
networkConfiguration: Object.keys(awsvpcConfiguration).length === 0 ? null : { awsvpcConfiguration: awsvpcConfiguration }
63+
networkConfiguration: Object.keys(awsvpcConfiguration).length === 0 ? null : { awsvpcConfiguration: awsvpcConfiguration },
64+
enableECSManagedTags: enableECSManagedTags
6465
});
6566

6667
core.debug(`Run task response ${JSON.stringify(runTaskResponse)}`)
@@ -427,7 +428,7 @@ async function run() {
427428
core.debug(`shouldRunTask: ${shouldRunTask}`);
428429
if (shouldRunTask) {
429430
core.debug("Running ad-hoc task...");
430-
await runTask(ecs, clusterName, taskDefArn, waitForMinutes);
431+
await runTask(ecs, clusterName, taskDefArn, waitForMinutes, enableECSManagedTags);
431432
}
432433

433434
// Update the service with the new task definition

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const IGNORED_TASK_DEFINITION_ATTRIBUTES = [
2121
];
2222

2323
// Method to run a stand-alone task with desired inputs
24-
async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
24+
async function runTask(ecs, clusterName, taskDefArn, waitForMinutes, enableECSManagedTags) {
2525
core.info('Running task')
2626

2727
const waitForTask = core.getInput('wait-for-task-stopped', { required: false }) || 'false';
@@ -54,7 +54,8 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) {
5454
containerOverrides: containerOverrides
5555
},
5656
launchType: launchType,
57-
networkConfiguration: Object.keys(awsvpcConfiguration).length === 0 ? null : { awsvpcConfiguration: awsvpcConfiguration }
57+
networkConfiguration: Object.keys(awsvpcConfiguration).length === 0 ? null : { awsvpcConfiguration: awsvpcConfiguration },
58+
enableECSManagedTags: enableECSManagedTags
5859
});
5960

6061
core.debug(`Run task response ${JSON.stringify(runTaskResponse)}`)
@@ -421,7 +422,7 @@ async function run() {
421422
core.debug(`shouldRunTask: ${shouldRunTask}`);
422423
if (shouldRunTask) {
423424
core.debug("Running ad-hoc task...");
424-
await runTask(ecs, clusterName, taskDefArn, waitForMinutes);
425+
await runTask(ecs, clusterName, taskDefArn, waitForMinutes, enableECSManagedTags);
425426
}
426427

427428
// Update the service with the new task definition

index.test.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,9 +1121,9 @@ describe('Deploy to ECS', () => {
11211121
.mockReturnValueOnce('') // cluster
11221122
.mockReturnValueOnce('') // wait-for-service-stability
11231123
.mockReturnValueOnce('') // wait-for-minutes
1124+
.mockReturnValueOnce('') // enable-ecs-managed-tags
11241125
.mockReturnValueOnce('') // force-new-deployment
11251126
.mockReturnValueOnce('') // desired-count
1126-
.mockReturnValueOnce('') // enable-ecs-managed-tags
11271127
.mockReturnValueOnce('true'); // run-task
11281128

11291129
await run();
@@ -1138,7 +1138,8 @@ describe('Deploy to ECS', () => {
11381138
launchType: 'FARGATE',
11391139
taskDefinition: 'task:def:arn',
11401140
overrides: {"containerOverrides": []},
1141-
networkConfiguration: null
1141+
networkConfiguration: null,
1142+
enableECSManagedTags: false
11421143
});
11431144

11441145
expect(core.setOutput).toHaveBeenNthCalledWith(2, 'run-task-arn', ["arn:aws:ecs:fake-region:account_id:task/arn"]);
@@ -1154,7 +1155,7 @@ describe('Deploy to ECS', () => {
11541155
.mockReturnValueOnce('') // wait-for-minutes
11551156
.mockReturnValueOnce('') // force-new-deployment
11561157
.mockReturnValueOnce('') // desired-count
1157-
.mockReturnValueOnce('') // enable-ecs-managed-tags
1158+
.mockReturnValueOnce('true') // enable-ecs-managed-tags
11581159
.mockReturnValueOnce('true') // run-task
11591160
.mockReturnValueOnce('false') // wait-for-task-stopped
11601161
.mockReturnValueOnce('someJoe') // run-task-started-by
@@ -1174,7 +1175,8 @@ describe('Deploy to ECS', () => {
11741175
launchType: 'EC2',
11751176
taskDefinition: 'task:def:arn',
11761177
overrides: { containerOverrides: [{ name: 'someapp', command: 'somecmd' }] },
1177-
networkConfiguration: { awsvpcConfiguration: { subnets: ['a', 'b'], securityGroups: ['c', 'd'], assignPublicIp: "DISABLED" } }
1178+
networkConfiguration: { awsvpcConfiguration: { subnets: ['a', 'b'], securityGroups: ['c', 'd'], assignPublicIp: "DISABLED" } },
1179+
enableECSManagedTags: true
11781180
});
11791181
expect(core.setOutput).toHaveBeenNthCalledWith(2, 'run-task-arn', ["arn:aws:ecs:fake-region:account_id:task/arn"]);
11801182
});
@@ -1220,7 +1222,8 @@ describe('Deploy to ECS', () => {
12201222
taskDefinition: 'task:def:arn',
12211223
launchType: 'EC2',
12221224
overrides: { containerOverrides: [{ name: 'someapp', command: 'somecmd' }] },
1223-
networkConfiguration: { awsvpcConfiguration: { subnets: ['a', 'b'], securityGroups: ['c', 'd'], assignPublicIp: "DISABLED" } }
1225+
networkConfiguration: { awsvpcConfiguration: { subnets: ['a', 'b'], securityGroups: ['c', 'd'], assignPublicIp: "DISABLED" } },
1226+
enableECSManagedTags: false
12241227
});
12251228
expect(core.setOutput).toHaveBeenNthCalledWith(2, 'run-task-arn', ["arn:aws:ecs:fake-region:account_id:task/arn"]);
12261229
});
@@ -1276,7 +1279,8 @@ describe('Deploy to ECS', () => {
12761279
taskDefinition: 'task:def:arn',
12771280
launchType: 'EC2',
12781281
overrides: { containerOverrides: [] },
1279-
networkConfiguration: null
1282+
networkConfiguration: null,
1283+
enableECSManagedTags: false
12801284
});
12811285
});
12821286

@@ -1443,7 +1447,7 @@ describe('Deploy to ECS', () => {
14431447
expect(core.setFailed).toHaveBeenNthCalledWith(2, 'Could not parse');
14441448
});
14451449

1446-
test('deployment with enable-ecs-managed-tags', async () => {
1450+
test('enable ecs managed tags on deployment', async () => {
14471451
core.getInput = jest
14481452
.fn()
14491453
.mockReturnValueOnce('task-definition.json') // task-definition
@@ -1452,7 +1456,7 @@ describe('Deploy to ECS', () => {
14521456
.mockReturnValueOnce('false') // wait-for-service-stability
14531457
.mockReturnValueOnce('') // wait-for-minutes
14541458
.mockReturnValueOnce('') // force-new-deployment
1455-
.mockReturnValueOnce('1') // desired count is number
1459+
.mockReturnValueOnce('') // desired count
14561460
.mockReturnValueOnce('true'); // enable-ecs-managed-tags
14571461

14581462
await run();
@@ -1466,7 +1470,6 @@ describe('Deploy to ECS', () => {
14661470
});
14671471
expect(mockEcsUpdateService).toHaveBeenNthCalledWith(1, {
14681472
cluster: 'cluster-789',
1469-
desiredCount: 1,
14701473
service: 'service-456',
14711474
taskDefinition: 'task:def:arn',
14721475
forceNewDeployment: false,

0 commit comments

Comments
 (0)