Skip to content

Commit ed647d7

Browse files
nathanielramNathaniel Ram
authored and
Nathaniel Ram
committed
Update index.js
1 parent 17cf388 commit ed647d7

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

index.js

Lines changed: 35 additions & 2 deletions
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 {

0 commit comments

Comments
 (0)