Skip to content

Commit 125df13

Browse files
committed
"Removed capacityProviderStrategy from function parameters and implementations in index.js and index.test.js"
1 parent 03d2b63 commit 125df13

File tree

2 files changed

+14
-61
lines changed

2 files changed

+14
-61
lines changed

index.js

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ const IGNORED_TASK_DEFINITION_ATTRIBUTES = [
2323
];
2424

2525
//Code to run task outside of a service aka (also known as) a one-off task
26-
async function runTask(ecs, capacityProviderStrategy, clusterName, taskDefArn, waitForMinutes) {
26+
async function runTask(ecs,clusterName, taskDefArn, waitForMinutes) {
2727
core.info('Running task')
2828

2929
const waitForTask = core.getInput('wait-for-task-stopped', { required: false }) || 'false';
3030
const startedBy = core.getInput('run-task-started-by', { required: false }) || 'GitHub-Actions';
31-
const launchType = core.getInput('run-task-launch-type', { required: false }) || 'FARGATE';
31+
const launchType = core.getInput('run-task-launch-type', { required: false })|| 'FARGATE';
3232
const subnetIds = core.getInput('run-task-subnets', { required: false }) || '';
3333
const securityGroupIds = core.getInput('run-task-security-groups', { required: false }) || '';
3434
const containerOverrides = JSON.parse(core.getInput('run-task-container-overrides', { required: false }) || '[]');
@@ -44,7 +44,6 @@ async function runTask(ecs, capacityProviderStrategy, clusterName, taskDefArn, w
4444
awsvpcConfiguration["securityGroups"] = securityGroupIds.split(',')
4545
}
4646

47-
4847
const runTaskResponse = await ecs.runTask({
4948
startedBy: startedBy,
5049
cluster: clusterName,
@@ -54,7 +53,6 @@ async function runTask(ecs, capacityProviderStrategy, clusterName, taskDefArn, w
5453
},
5554
launchType: launchType,
5655
networkConfiguration: Object.keys(awsvpcConfiguration).length === 0 ? {} : { awsvpcConfiguration: awsvpcConfiguration },
57-
capacityProviderStrategy: capacityProviderStrategy
5856

5957
});
6058

@@ -132,16 +130,14 @@ async function tasksExitCode(ecs, clusterName, taskArns) {
132130

133131

134132
// Deploy to a service that uses the 'ECS' deployment controller
135-
async function updateEcsService(ecs, capacityProviderStrategy, clusterName, service, taskDefArn, waitForService, waitForMinutes, forceNewDeployment, desiredCount) {
133+
async function updateEcsService(ecs, clusterName, service, taskDefArn, waitForService, waitForMinutes, forceNewDeployment, desiredCount) {
136134
core.debug('Updating the service');
137-
//const capacityProviderStrategy = core.getInput('capacity-provider-strategy',{required: false}) || '{}';
138135

139136
let params = {
140137
cluster: clusterName,
141138
service: service,
142139
taskDefinition: taskDefArn,
143140
forceNewDeployment: forceNewDeployment,
144-
capacityProviderStrategy: capacityProviderStrategy
145141
};
146142

147143
// Add the desiredCount property only if it is defined and a number.
@@ -395,17 +391,7 @@ async function run() {
395391
const forceNewDeployInput = core.getInput('force-new-deployment', { required: false }) || 'false';
396392
const forceNewDeployment = forceNewDeployInput.toLowerCase() === 'true';
397393
const desiredCount = parseInt((core.getInput('desired-count', {required: false})));
398-
const capacityProviderStrategy = core.getInput('capacity-provider-strategy',{required: false}) || [{base: 1, capacityProvider: 'FARGATE', weight: 1}];
399-
400-
if(capacityProviderStrategy){
401-
core.debug('Using capacity provider ommits the launchtype option')
402-
launchType = undefined;
403-
}
404-
else{
405-
core.debug('Using launch type ommits the capacity provider option')
406-
launchType = 'FARGATE' ;
407-
}
408-
394+
409395
// Register the task definition
410396
core.debug('Registering the task definition');
411397
const taskDefPath = path.isAbsolute(taskDefinitionFile) ?
@@ -433,13 +419,12 @@ async function run() {
433419

434420
if (shouldRunTask) {
435421
core.debug("Running one-off task...");
436-
await runTask(ecs, capacityProviderStrategy, clusterName, taskDefArn, waitForMinutes);
422+
await runTask(ecs, clusterName, taskDefArn, waitForMinutes);
437423
}
438424

439425
// Update the service with the new task definition
440426
if (service) {
441-
//const clusterName = cluster ? cluster : 'default';
442-
427+
443428
// Determine the deployment controller
444429
const describeResponse = await ecs.describeServices({
445430
services: [service],
@@ -459,7 +444,7 @@ async function run() {
459444
if (!serviceResponse.deploymentController || !serviceResponse.deploymentController.type || serviceResponse.deploymentController.type === 'ECS') {
460445
// Service uses the 'ECS' deployment controller, so we can call UpdateService
461446
core.debug('Updating service...');
462-
await updateEcsService(ecs, capacityProviderStrategy, clusterName, service, taskDefArn, waitForService, waitForMinutes, forceNewDeployment, desiredCount);
447+
await updateEcsService(ecs, clusterName, service, taskDefArn, waitForService, waitForMinutes, forceNewDeployment, desiredCount);
463448

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

index.test.js

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,7 @@ describe('Deploy to ECS', () => {
8585
() => Promise.resolve({ taskDefinition: { taskDefinitionArn: 'task:def:arn' } })
8686
);
8787

88-
mockEcsUpdateService.mockImplementation(() => Promise.resolve({
89-
90-
/*
91-
capacityProviderStrategy: [
92-
{
93-
base: number,
94-
capacityProvider: "string",
95-
weight: number
96-
}
97-
],
98-
*/
99-
}));
88+
mockEcsUpdateService.mockImplementation(() => Promise.resolve({}));
10089

10190
mockEcsDescribeServices.mockImplementation(
10291
() => Promise.resolve({
@@ -129,7 +118,6 @@ describe('Deploy to ECS', () => {
129118
mockRunTask.mockImplementation(
130119
() => Promise.resolve({
131120
failures: [],
132-
//capacityProviderName: 'FARGATE',
133121
tasks: [
134122
{
135123
containers: [
@@ -151,7 +139,6 @@ describe('Deploy to ECS', () => {
151139
mockEcsDescribeTasks.mockImplementation(
152140
() => Promise.resolve({
153141
failures: [],
154-
///capacityProviderName: 'FARGATE',
155142
tasks: [
156143
{
157144
containers: [
@@ -196,7 +183,6 @@ describe('Deploy to ECS', () => {
196183
service: 'service-456',
197184
taskDefinition: 'task:def:arn',
198185
forceNewDeployment: false,
199-
capacityProviderStrategy: [{base: 1, capacityProvider: 'FARGATE', weight: 1}]
200186
});
201187
expect(waitUntilServicesStable).toHaveBeenCalledTimes(0);
202188
expect(core.info).toBeCalledWith("Deployment started. Watch this deployment's progress in the Amazon ECS console: https://console.aws.amazon.com/ecs/home?region=fake-region#/clusters/cluster-789/services/service-456/events");
@@ -229,7 +215,6 @@ describe('Deploy to ECS', () => {
229215
service: 'service-456',
230216
taskDefinition: 'task:def:arn',
231217
forceNewDeployment: false,
232-
capacityProviderStrategy: [{base: 1, capacityProvider: 'FARGATE', weight: 1}]
233218

234219
});
235220
expect(waitUntilServicesStable).toHaveBeenCalledTimes(0);
@@ -736,7 +721,6 @@ describe('Deploy to ECS', () => {
736721
.mockReturnValueOnce('') // force-new-deployment
737722
.mockReturnValueOnce('') // task
738723
.mockReturnValueOnce('') // desired count
739-
.mockReturnValueOnce('') //capacity provider
740724
.mockReturnValueOnce('/hello/appspec.json') // codedeploy-appspec
741725
.mockReturnValueOnce('MyApplication') // codedeploy-application
742726
.mockReturnValueOnce('MyDeploymentGroup'); // codedeploy-deployment-group
@@ -959,7 +943,6 @@ describe('Deploy to ECS', () => {
959943
.mockReturnValueOnce('service-456') // service
960944
.mockReturnValueOnce('cluster-789') // cluster
961945
.mockReturnValueOnce('TRUE') // wait-for-service-stability
962-
//.mockReturnValueOnce('') // cap
963946
.mockReturnValueOnce(''); // desired count
964947

965948

@@ -976,8 +959,7 @@ describe('Deploy to ECS', () => {
976959
cluster: 'cluster-789',
977960
service: 'service-456',
978961
taskDefinition: 'task:def:arn',
979-
forceNewDeployment: false,
980-
capacityProviderStrategy: [{base: 1, capacityProvider: 'FARGATE', weight: 1}]
962+
forceNewDeployment: false
981963

982964
});
983965
expect(waitUntilServicesStable).toHaveBeenNthCalledWith(
@@ -1018,9 +1000,7 @@ describe('Deploy to ECS', () => {
10181000
cluster: 'cluster-789',
10191001
service: 'service-456',
10201002
taskDefinition: 'task:def:arn',
1021-
forceNewDeployment: false,
1022-
capacityProviderStrategy: [{base: 1, capacityProvider: 'FARGATE', weight: 1}]
1023-
1003+
forceNewDeployment: false
10241004
});
10251005
expect(waitUntilServicesStable).toHaveBeenNthCalledWith(
10261006
1,
@@ -1060,9 +1040,7 @@ describe('Deploy to ECS', () => {
10601040
cluster: 'cluster-789',
10611041
service: 'service-456',
10621042
taskDefinition: 'task:def:arn',
1063-
forceNewDeployment: false,
1064-
capacityProviderStrategy: [{base: 1, capacityProvider: 'FARGATE', weight: 1}]
1065-
1043+
forceNewDeployment: false
10661044
});
10671045
expect(waitUntilServicesStable).toHaveBeenNthCalledWith(
10681046
1,
@@ -1104,9 +1082,7 @@ describe('Deploy to ECS', () => {
11041082
desiredCount: 4,
11051083
service: 'service-456',
11061084
taskDefinition: 'task:def:arn',
1107-
forceNewDeployment: true,
1108-
capacityProviderStrategy: [{base: 1, capacityProvider: 'FARGATE', weight: 1}]
1109-
1085+
forceNewDeployment: true
11101086
});
11111087
});
11121088

@@ -1131,8 +1107,7 @@ describe('Deploy to ECS', () => {
11311107
cluster: 'default',
11321108
service: 'service-456',
11331109
taskDefinition: 'task:def:arn',
1134-
forceNewDeployment: false,
1135-
capacityProviderStrategy: [{base: 1, capacityProvider: 'FARGATE', weight: 1}]
1110+
forceNewDeployment: false
11361111
});
11371112
});
11381113

@@ -1160,7 +1135,6 @@ describe('Deploy to ECS', () => {
11601135
.mockReturnValueOnce('') // wait-for-minutes
11611136
.mockReturnValueOnce('') // force-new-deployment
11621137
.mockReturnValueOnce('') // desired-count
1163-
.mockReturnValueOnce('') //capacity provider
11641138
.mockReturnValueOnce('true'); // run-task
11651139

11661140

@@ -1183,7 +1157,6 @@ describe('Deploy to ECS', () => {
11831157
.mockReturnValueOnce('') // wait-for-minutes
11841158
.mockReturnValueOnce('') // force-new-deployment
11851159
.mockReturnValueOnce('') // desired-count
1186-
.mockReturnValueOnce('') //capacity provider
11871160
.mockReturnValueOnce('true') // run-task
11881161
.mockReturnValueOnce('false') // wait-for-task-stopped
11891162
.mockReturnValueOnce('someJoe') // run-task-started-by
@@ -1200,7 +1173,6 @@ describe('Deploy to ECS', () => {
12001173
expect(core.setOutput).toHaveBeenNthCalledWith(1, 'task-definition-arn', 'task:def:arn');
12011174
expect(mockRunTask).toHaveBeenCalledWith({
12021175
startedBy: 'someJoe',
1203-
capacityProviderStrategy: [{base: 1, capacityProvider: 'FARGATE', weight: 1}],
12041176
cluster: 'somecluster',
12051177
launchType: 'EC2',
12061178
taskDefinition: 'task:def:arn',
@@ -1221,7 +1193,6 @@ describe('Deploy to ECS', () => {
12211193
.mockReturnValueOnce('') // wait-for-minutes
12221194
.mockReturnValueOnce('') // force-new-deployment
12231195
.mockReturnValueOnce('') // desired-count
1224-
.mockReturnValueOnce('') //capacity provider
12251196
.mockReturnValueOnce('true') // run-task
12261197
.mockReturnValueOnce('false') // wait-for-task-stopped
12271198
.mockReturnValueOnce('someJoe') // run-task-started-by
@@ -1243,13 +1214,11 @@ describe('Deploy to ECS', () => {
12431214
cluster: 'somecluster',
12441215
service: 'service-456',
12451216
taskDefinition: 'task:def:arn',
1246-
forceNewDeployment: false,
1247-
capacityProviderStrategy: [{base: 1, capacityProvider: 'FARGATE', weight: 1}]
1217+
forceNewDeployment: false
12481218

12491219
});
12501220
expect(mockRunTask).toHaveBeenCalledWith({
12511221
startedBy: 'someJoe',
1252-
capacityProviderStrategy: [{base: 1, capacityProvider: 'FARGATE', weight: 1}],
12531222
cluster: 'somecluster',
12541223
taskDefinition: 'task:def:arn',
12551224
launchType: 'EC2',
@@ -1270,7 +1239,6 @@ describe('Deploy to ECS', () => {
12701239
.mockReturnValueOnce('') // wait-for-minutes
12711240
.mockReturnValueOnce('') // force-new-deployment
12721241
.mockReturnValueOnce('') // desired-count
1273-
.mockReturnValueOnce('') //capacity provider
12741242
.mockReturnValueOnce('true') // run-task
12751243
.mockReturnValueOnce('true') ; // wait-for-task-stopped
12761244

0 commit comments

Comments
 (0)