Skip to content

Commit cc55281

Browse files
authoredNov 16, 2021
Update index.js
1 parent c670af4 commit cc55281

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed
 

‎index.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,36 @@ function removeIgnoredAttributes(taskDef) {
7979
return taskDef;
8080
}
8181

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+
82112
async function run() {
83113
try {
84114
const agent = 'amazon-ecs-run-task-for-github-actions'
@@ -104,7 +134,7 @@ async function run() {
104134
taskDefinitionFile :
105135
path.join(process.env.GITHUB_WORKSPACE, taskDefinitionFile);
106136
const fileContents = fs.readFileSync(taskDefPath, 'utf8');
107-
const taskDefContents = removeIgnoredAttributes(cleanNullKeys(yaml.parse(fileContents)));
137+
const taskDefContents = maintainValidObjects(removeIgnoredAttributes(cleanNullKeys(yaml.parse(fileContents))));
108138

109139
let registerResponse;
110140
try {

0 commit comments

Comments
 (0)