Skip to content

Commit ae6c2ec

Browse files
committed
handle enableECSManagedTagsInput
when no input enableECSManagedTagsInput, not include it to request params
1 parent 405ede4 commit ae6c2ec

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
@@ -131,18 +131,21 @@ async function tasksExitCode(ecs, clusterName, taskArns) {
131131
}
132132

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

137137
let params = {
138138
cluster: clusterName,
139139
service: service,
140140
taskDefinition: taskDefArn,
141141
forceNewDeployment: forceNewDeployment,
142-
enableECSManagedTags: enableECSManagedTags,
143142
propagateTags: propagateTags
144143
};
145144

145+
if (enableECSManagedTagsInput !== "") {
146+
params.enableECSManagedTags = enableECSManagedTagsInput.toLowerCase() === 'true';
147+
}
148+
146149
// Add the desiredCount property only if it is defined and a number.
147150
if (!isNaN(desiredCount) && desiredCount !== undefined) {
148151
params.desiredCount = desiredCount;
@@ -396,7 +399,7 @@ async function run() {
396399
const forceNewDeployInput = core.getInput('force-new-deployment', { required: false }) || 'false';
397400
const forceNewDeployment = forceNewDeployInput.toLowerCase() === 'true';
398401
const desiredCount = parseInt((core.getInput('desired-count', {required: false})));
399-
const enableECSManagedTagsInput = core.getInput('enable-ecs-managed-tags', { required: false }) || 'false';
402+
const enableECSManagedTagsInput = core.getInput('enable-ecs-managed-tags', { required: false }) || '';
400403
const enableECSManagedTags = enableECSManagedTagsInput.toLowerCase() === 'true';
401404
const propagateTags = core.getInput('propagate-tags', { required: false }) || 'NONE';
402405

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

455458
} else if (serviceResponse.deploymentController.type === 'CODE_DEPLOY') {
456459
// 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
});
@@ -1229,7 +1222,6 @@ describe('Deploy to ECS', () => {
12291222
service: 'service-456',
12301223
taskDefinition: 'task:def:arn',
12311224
forceNewDeployment: false,
1232-
enableECSManagedTags: false,
12331225
propagateTags: 'NONE',
12341226
});
12351227
expect(mockRunTask).toHaveBeenCalledWith({
@@ -1501,4 +1493,4 @@ describe('Deploy to ECS', () => {
15011493
propagateTags: 'SERVICE'
15021494
});
15031495
});
1504-
});
1496+
});

0 commit comments

Comments
 (0)