Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ const IGNORED_TASK_DEFINITION_ATTRIBUTES = [
'taskDefinitionArn',
'requiresAttributes',
'revision',
'status'
'status',
'registeredAt',
'deregisteredAt',
'registeredBy'
];

const WAIT_DEFAULT_DELAY_SEC = 5;
Expand Down Expand Up @@ -209,6 +212,36 @@ function removeIgnoredAttributes(taskDef) {
return taskDef;
}

function maintainValidObjects(taskDef) {
if (validateProxyConfigurations(taskDef)) {
taskDef.proxyConfiguration.properties.forEach((property, index, arr) => {
if (!('value' in property)) {
arr[index].value = '';
}
if (!('name' in property)) {
arr[index].name = '';
}
});
}

if(taskDef && taskDef.containerDefinitions){
taskDef.containerDefinitions.forEach((container) => {
if(container.environment){
container.environment.forEach((property, index, arr) => {
if (!('value' in property)) {
arr[index].value = '';
}
});
}
});
}
return taskDef;
}

function validateProxyConfigurations(taskDef){
return 'proxyConfiguration' in taskDef && taskDef.proxyConfiguration.type && taskDef.proxyConfiguration.type == 'APPMESH' && taskDef.proxyConfiguration.properties && taskDef.proxyConfiguration.properties.length > 0;
}

async function run() {
try {
const agent = 'amazon-ecs-run-task-for-github-actions'
Expand All @@ -234,7 +267,7 @@ async function run() {
taskDefinitionFile :
path.join(process.env.GITHUB_WORKSPACE, taskDefinitionFile);
const fileContents = fs.readFileSync(taskDefPath, 'utf8');
const taskDefContents = removeIgnoredAttributes(cleanNullKeys(yaml.parse(fileContents)));
const taskDefContents = maintainValidObjects(removeIgnoredAttributes(cleanNullKeys(yaml.parse(fileContents))));

let registerResponse;
try {
Expand Down
37 changes: 35 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ const IGNORED_TASK_DEFINITION_ATTRIBUTES = [
'taskDefinitionArn',
'requiresAttributes',
'revision',
'status'
'status',
'registeredAt',
'deregisteredAt',
'registeredBy'
];

const WAIT_DEFAULT_DELAY_SEC = 5;
Expand Down Expand Up @@ -76,6 +79,36 @@ function removeIgnoredAttributes(taskDef) {
return taskDef;
}

function maintainValidObjects(taskDef) {
if (validateProxyConfigurations(taskDef)) {
taskDef.proxyConfiguration.properties.forEach((property, index, arr) => {
if (!('value' in property)) {
arr[index].value = '';
}
if (!('name' in property)) {
arr[index].name = '';
}
});
}

if(taskDef && taskDef.containerDefinitions){
taskDef.containerDefinitions.forEach((container) => {
if(container.environment){
container.environment.forEach((property, index, arr) => {
if (!('value' in property)) {
arr[index].value = '';
}
});
}
});
}
return taskDef;
}

function validateProxyConfigurations(taskDef){
return 'proxyConfiguration' in taskDef && taskDef.proxyConfiguration.type && taskDef.proxyConfiguration.type == 'APPMESH' && taskDef.proxyConfiguration.properties && taskDef.proxyConfiguration.properties.length > 0;
}

async function run() {
try {
const agent = 'amazon-ecs-run-task-for-github-actions'
Expand All @@ -101,7 +134,7 @@ async function run() {
taskDefinitionFile :
path.join(process.env.GITHUB_WORKSPACE, taskDefinitionFile);
const fileContents = fs.readFileSync(taskDefPath, 'utf8');
const taskDefContents = removeIgnoredAttributes(cleanNullKeys(yaml.parse(fileContents)));
const taskDefContents = maintainValidObjects(removeIgnoredAttributes(cleanNullKeys(yaml.parse(fileContents))));

let registerResponse;
try {
Expand Down
16 changes: 12 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.