Skip to content

Commit a392108

Browse files
committed
handle enableECSManagedTagsInput
when no input enableECSManagedTagsInput, not include it to request params
1 parent 8d85c2a commit a392108

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,21 @@ async function tasksExitCode(ecs, clusterName, taskArns) {
133133
}
134134

135135
// Deploy to a service that uses the 'ECS' deployment controller
136-
async function updateEcsService(ecs, clusterName, service, taskDefArn, waitForService, waitForMinutes, forceNewDeployment, desiredCount, enableECSManagedTags, propagateTags) {
136+
async function updateEcsService(ecs, clusterName, service, taskDefArn, waitForService, waitForMinutes, forceNewDeployment, desiredCount, enableECSManagedTagsInput, propagateTags) {
137137
core.debug('Updating the service');
138138

139139
let params = {
140140
cluster: clusterName,
141141
service: service,
142142
taskDefinition: taskDefArn,
143143
forceNewDeployment: forceNewDeployment,
144-
enableECSManagedTags: enableECSManagedTags,
145144
propagateTags: propagateTags
146145
};
147146

147+
if (enableECSManagedTagsInput !== "") {
148+
params.enableECSManagedTags = enableECSManagedTagsInput.toLowerCase() === 'true';
149+
}
150+
148151
// Add the desiredCount property only if it is defined and a number.
149152
if (!isNaN(desiredCount) && desiredCount !== undefined) {
150153
params.desiredCount = desiredCount;
@@ -398,7 +401,7 @@ async function run() {
398401
const forceNewDeployInput = core.getInput('force-new-deployment', { required: false }) || 'false';
399402
const forceNewDeployment = forceNewDeployInput.toLowerCase() === 'true';
400403
const desiredCount = parseInt((core.getInput('desired-count', {required: false})));
401-
const enableECSManagedTagsInput = core.getInput('enable-ecs-managed-tags', { required: false }) || 'false';
404+
const enableECSManagedTagsInput = core.getInput('enable-ecs-managed-tags', { required: false }) || '';
402405
const enableECSManagedTags = enableECSManagedTagsInput.toLowerCase() === 'true';
403406
const propagateTags = core.getInput('propagate-tags', { required: false }) || 'NONE';
404407

@@ -452,7 +455,7 @@ async function run() {
452455
if (!serviceResponse.deploymentController || !serviceResponse.deploymentController.type || serviceResponse.deploymentController.type === 'ECS') {
453456
// Service uses the 'ECS' deployment controller, so we can call UpdateService
454457
core.debug('Updating service...');
455-
await updateEcsService(ecs, clusterName, service, taskDefArn, waitForService, waitForMinutes, forceNewDeployment, desiredCount, enableECSManagedTags, propagateTags);
458+
await updateEcsService(ecs, clusterName, service, taskDefArn, waitForService, waitForMinutes, forceNewDeployment, desiredCount, enableECSManagedTagsInput, propagateTags);
456459

457460
} else if (serviceResponse.deploymentController.type === 'CODE_DEPLOY') {
458461
// Service uses CodeDeploy, so we should start a CodeDeploy deployment

index.test.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ describe('Deploy to ECS', () => {
183183
service: 'service-456',
184184
taskDefinition: 'task:def:arn',
185185
forceNewDeployment: false,
186-
enableECSManagedTags: false,
187186
propagateTags: 'NONE'
188187
});
189188
expect(waitUntilServicesStable).toHaveBeenCalledTimes(0);
@@ -216,7 +215,6 @@ describe('Deploy to ECS', () => {
216215
service: 'service-456',
217216
taskDefinition: 'task:def:arn',
218217
forceNewDeployment: false,
219-
enableECSManagedTags: false,
220218
propagateTags: 'NONE'
221219
});
222220
expect(waitUntilServicesStable).toHaveBeenCalledTimes(0);
@@ -951,7 +949,6 @@ describe('Deploy to ECS', () => {
951949
service: 'service-456',
952950
taskDefinition: 'task:def:arn',
953951
forceNewDeployment: false,
954-
enableECSManagedTags: false,
955952
propagateTags: 'NONE'
956953
});
957954
expect(waitUntilServicesStable).toHaveBeenNthCalledWith(
@@ -992,7 +989,6 @@ describe('Deploy to ECS', () => {
992989
service: 'service-456',
993990
taskDefinition: 'task:def:arn',
994991
forceNewDeployment: false,
995-
enableECSManagedTags: false,
996992
propagateTags: 'NONE'
997993
});
998994
expect(waitUntilServicesStable).toHaveBeenNthCalledWith(
@@ -1033,7 +1029,6 @@ describe('Deploy to ECS', () => {
10331029
service: 'service-456',
10341030
taskDefinition: 'task:def:arn',
10351031
forceNewDeployment: false,
1036-
enableECSManagedTags: false,
10371032
propagateTags: 'NONE'
10381033
});
10391034
expect(waitUntilServicesStable).toHaveBeenNthCalledWith(
@@ -1076,7 +1071,6 @@ describe('Deploy to ECS', () => {
10761071
service: 'service-456',
10771072
taskDefinition: 'task:def:arn',
10781073
forceNewDeployment: true,
1079-
enableECSManagedTags: false,
10801074
propagateTags: 'NONE'
10811075
});
10821076
});
@@ -1102,7 +1096,6 @@ describe('Deploy to ECS', () => {
11021096
service: 'service-456',
11031097
taskDefinition: 'task:def:arn',
11041098
forceNewDeployment: false,
1105-
enableECSManagedTags: false,
11061099
propagateTags: 'NONE'
11071100
});
11081101
});
@@ -1273,7 +1266,6 @@ describe('Deploy to ECS', () => {
12731266
service: 'service-456',
12741267
taskDefinition: 'task:def:arn',
12751268
forceNewDeployment: false,
1276-
enableECSManagedTags: false,
12771269
propagateTags: 'NONE',
12781270
});
12791271
expect(mockRunTask).toHaveBeenCalledWith({
@@ -1547,4 +1539,4 @@ describe('Deploy to ECS', () => {
15471539
propagateTags: 'SERVICE'
15481540
});
15491541
});
1550-
});
1542+
});

0 commit comments

Comments
 (0)