Skip to content

Commit 91299ec

Browse files
nathanielramNathaniel Ram
authored and
Nathaniel Ram
committed
Updated ignored task definition attributes and some validation
1 parent 17cf388 commit 91299ec

File tree

3 files changed

+82
-8
lines changed

3 files changed

+82
-8
lines changed

dist/index.js

+35-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ const IGNORED_TASK_DEFINITION_ATTRIBUTES = [
143143
'taskDefinitionArn',
144144
'requiresAttributes',
145145
'revision',
146-
'status'
146+
'status',
147+
'registeredAt',
148+
'deregisteredAt',
149+
'registeredBy'
147150
];
148151

149152
const WAIT_DEFAULT_DELAY_SEC = 5;
@@ -209,6 +212,36 @@ function removeIgnoredAttributes(taskDef) {
209212
return taskDef;
210213
}
211214

215+
function maintainValidObjects(taskDef) {
216+
if (validateProxyConfigurations(taskDef)) {
217+
taskDef.proxyConfiguration.properties.forEach((property, index, arr) => {
218+
if (!('value' in property)) {
219+
arr[index].value = '';
220+
}
221+
if (!('name' in property)) {
222+
arr[index].name = '';
223+
}
224+
});
225+
}
226+
227+
if(taskDef && taskDef.containerDefinitions){
228+
taskDef.containerDefinitions.forEach((container) => {
229+
if(container.environment){
230+
container.environment.forEach((property, index, arr) => {
231+
if (!('value' in property)) {
232+
arr[index].value = '';
233+
}
234+
});
235+
}
236+
});
237+
}
238+
return taskDef;
239+
}
240+
241+
function validateProxyConfigurations(taskDef){
242+
return 'proxyConfiguration' in taskDef && taskDef.proxyConfiguration.type && taskDef.proxyConfiguration.type == 'APPMESH' && taskDef.proxyConfiguration.properties && taskDef.proxyConfiguration.properties.length > 0;
243+
}
244+
212245
async function run() {
213246
try {
214247
const agent = 'amazon-ecs-run-task-for-github-actions'
@@ -234,7 +267,7 @@ async function run() {
234267
taskDefinitionFile :
235268
path.join(process.env.GITHUB_WORKSPACE, taskDefinitionFile);
236269
const fileContents = fs.readFileSync(taskDefPath, 'utf8');
237-
const taskDefContents = removeIgnoredAttributes(cleanNullKeys(yaml.parse(fileContents)));
270+
const taskDefContents = maintainValidObjects(removeIgnoredAttributes(cleanNullKeys(yaml.parse(fileContents))));
238271

239272
let registerResponse;
240273
try {

index.js

+35-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ const IGNORED_TASK_DEFINITION_ATTRIBUTES = [
1010
'taskDefinitionArn',
1111
'requiresAttributes',
1212
'revision',
13-
'status'
13+
'status',
14+
'registeredAt',
15+
'deregisteredAt',
16+
'registeredBy'
1417
];
1518

1619
const WAIT_DEFAULT_DELAY_SEC = 5;
@@ -76,6 +79,36 @@ function removeIgnoredAttributes(taskDef) {
7679
return taskDef;
7780
}
7881

82+
function maintainValidObjects(taskDef) {
83+
if (validateProxyConfigurations(taskDef)) {
84+
taskDef.proxyConfiguration.properties.forEach((property, index, arr) => {
85+
if (!('value' in property)) {
86+
arr[index].value = '';
87+
}
88+
if (!('name' in property)) {
89+
arr[index].name = '';
90+
}
91+
});
92+
}
93+
94+
if(taskDef && taskDef.containerDefinitions){
95+
taskDef.containerDefinitions.forEach((container) => {
96+
if(container.environment){
97+
container.environment.forEach((property, index, arr) => {
98+
if (!('value' in property)) {
99+
arr[index].value = '';
100+
}
101+
});
102+
}
103+
});
104+
}
105+
return taskDef;
106+
}
107+
108+
function validateProxyConfigurations(taskDef){
109+
return 'proxyConfiguration' in taskDef && taskDef.proxyConfiguration.type && taskDef.proxyConfiguration.type == 'APPMESH' && taskDef.proxyConfiguration.properties && taskDef.proxyConfiguration.properties.length > 0;
110+
}
111+
79112
async function run() {
80113
try {
81114
const agent = 'amazon-ecs-run-task-for-github-actions'
@@ -101,7 +134,7 @@ async function run() {
101134
taskDefinitionFile :
102135
path.join(process.env.GITHUB_WORKSPACE, taskDefinitionFile);
103136
const fileContents = fs.readFileSync(taskDefPath, 'utf8');
104-
const taskDefContents = removeIgnoredAttributes(cleanNullKeys(yaml.parse(fileContents)));
137+
const taskDefContents = maintainValidObjects(removeIgnoredAttributes(cleanNullKeys(yaml.parse(fileContents))));
105138

106139
let registerResponse;
107140
try {

package-lock.json

+12-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)