Skip to content

Commit 64cfd0b

Browse files
committed
Add parsing to overrideContainerCommand to allow chaning multiple commands into a single line using a backslash as line appender
1 parent 578513a commit 64cfd0b

File tree

5 files changed

+4857
-2843
lines changed

5 files changed

+4857
-2843
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.7

index.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const main = async () => {
2121
const overrideContainer = core.getInput('override-container', {required: false});
2222
const overrideContainerCommand = core.getMultilineInput('override-container-command', {required: false});
2323
const overrideContainerEnvironment = core.getMultilineInput('override-container-environment', {required: false});
24-
2524

2625
// Build Task parameters
2726
const taskRequestParams = {
@@ -46,13 +45,35 @@ const main = async () => {
4645

4746
if (overrideContainerCommand.length) {
4847
core.debug(`overrideContainer and overrideContainerCommand has been specified. Overriding.`);
49-
overrides.command = overrideContainerCommand
48+
49+
// Iterate over each item in the array and check for line appender character
50+
core.debug(`Parsing overrideContainerCommand and merging line appender strings.`);
51+
overrideContainerCommand.map((x, i, arr) => {
52+
if (x.endsWith('\\')) {
53+
// Remove line appender character
54+
arr[i] = x.replace(/\\$/, '')
55+
56+
// Check if not the last item in array
57+
if (arr.length - 1 !== i) {
58+
// Prepend the current item to the next item and set current item to null
59+
arr[i+1] = arr[i] + arr[i+1]
60+
arr[i] = null
61+
}
62+
}
63+
console.log(JSON.stringify(arr))
64+
})
65+
66+
// Filter out any null values
67+
const parsedCommand = overrideContainerCommand.filter(x => x)
68+
core.debug(`Resulting command: ${JSON.stringify(parsedCommand)}`)
69+
70+
overrides.command = parsedCommand
5071
}
5172

5273
if(overrideContainerEnvironment.length) {
5374
core.debug(`overrideContainer and overrideContainerEnvironment has been specified. Overriding.`);
5475
overrides.environment = overrideContainerEnvironment.map(x => {
55-
const parts=x.split(/=(.*)/)
76+
const parts= x.split(/=(.*)/)
5677
return {
5778
name: parts[0],
5879
value: parts[1]
@@ -100,7 +121,7 @@ const main = async () => {
100121
return false;
101122
}
102123

103-
// Create a WLogFilterStream if logOptions are found
124+
// Create a CWLogFilterStream if logOptions are found
104125
if (container.logConfiguration && container.logConfiguration.logDriver === 'awslogs') {
105126
const logStreamName = [container.logConfiguration.options['awslogs-stream-prefix'], container.name, taskId].join('/')
106127
core.debug(`Found matching container with 'awslogs' logDriver. Creating LogStream for '${logStreamName}'`);

0 commit comments

Comments
 (0)