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
74 changes: 37 additions & 37 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,45 +168,45 @@ async function run() {
containerDef.environment.push(variable);
}
})
}

if (secrets) {
// If secrets array is missing, create it
if (!Array.isArray(containerDef.secrets)) {
containerDef.secrets = [];
}

// Get pairs by splitting on newlines
secrets.split('\n').forEach(function (line) {
// Trim whitespace
const trimmedLine = line.trim();
// Skip if empty
if (trimmedLine.length === 0) { return; }
// Split on =
const separatorIdx = trimmedLine.indexOf("=");
// If there's nowhere to split
if (separatorIdx === -1) {
throw new Error(
`Cannot parse the secret '${trimmedLine}'. Secret pairs must be of the form NAME=valueFrom,
where valueFrom is an arn from parameter store or secrets manager. See AWS documentation for more information:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html.`);
}
// Build object
const secret = {
name: trimmedLine.substring(0, separatorIdx),
valueFrom: trimmedLine.substring(separatorIdx + 1),
};

// Search container definition environment for one matching name
const secretDef = containerDef.secrets.find((s) => s.name == secret.name);
if (secretDef) {
// If found, update
secretDef.valueFrom = secret.valueFrom;
} else {
// Else, create
containerDef.secrets.push(secret);
}
})
if (secrets) {
// If secrets array is missing, create it
if (!Array.isArray(containerDef.secrets)) {
containerDef.secrets = [];
}

// Get pairs by splitting on newlines
secrets.split('\n').forEach(function (line) {
// Trim whitespace
const trimmedLine = line.trim();
// Skip if empty
if (trimmedLine.length === 0) { return; }
// Split on =
const separatorIdx = trimmedLine.indexOf("=");
// If there's nowhere to split
if (separatorIdx === -1) {
throw new Error(
`Cannot parse the secret '${trimmedLine}'. Secret pairs must be of the form NAME=valueFrom,
where valueFrom is an arn from parameter store or secrets manager. See AWS documentation for more information:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html.`);
}
// Build object
const secret = {
name: trimmedLine.substring(0, separatorIdx),
valueFrom: trimmedLine.substring(separatorIdx + 1),
};

// Search container definition environment for one matching name
const secretDef = containerDef.secrets.find((s) => s.name == secret.name);
if (secretDef) {
// If found, update
secretDef.valueFrom = secret.valueFrom;
} else {
// Else, create
containerDef.secrets.push(secret);
}
})
}

if (logConfigurationLogDriver) {
Expand Down
72 changes: 36 additions & 36 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,45 +162,45 @@ async function run() {
containerDef.environment.push(variable);
}
})
}

if (secrets) {
// If secrets array is missing, create it
if (!Array.isArray(containerDef.secrets)) {
containerDef.secrets = [];
}
if (secrets) {
// If secrets array is missing, create it
if (!Array.isArray(containerDef.secrets)) {
containerDef.secrets = [];
}

// Get pairs by splitting on newlines
secrets.split('\n').forEach(function (line) {
// Trim whitespace
const trimmedLine = line.trim();
// Skip if empty
if (trimmedLine.length === 0) { return; }
// Split on =
const separatorIdx = trimmedLine.indexOf("=");
// If there's nowhere to split
if (separatorIdx === -1) {
throw new Error(
`Cannot parse the secret '${trimmedLine}'. Secret pairs must be of the form NAME=valueFrom,
where valueFrom is an arn from parameter store or secrets manager. See AWS documentation for more information:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html.`);
}
// Build object
const secret = {
name: trimmedLine.substring(0, separatorIdx),
valueFrom: trimmedLine.substring(separatorIdx + 1),
};
// Get pairs by splitting on newlines
secrets.split('\n').forEach(function (line) {
// Trim whitespace
const trimmedLine = line.trim();
// Skip if empty
if (trimmedLine.length === 0) { return; }
// Split on =
const separatorIdx = trimmedLine.indexOf("=");
// If there's nowhere to split
if (separatorIdx === -1) {
throw new Error(
`Cannot parse the secret '${trimmedLine}'. Secret pairs must be of the form NAME=valueFrom,
where valueFrom is an arn from parameter store or secrets manager. See AWS documentation for more information:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html.`);
}
// Build object
const secret = {
name: trimmedLine.substring(0, separatorIdx),
valueFrom: trimmedLine.substring(separatorIdx + 1),
};

// Search container definition environment for one matching name
const secretDef = containerDef.secrets.find((s) => s.name == secret.name);
if (secretDef) {
// If found, update
secretDef.valueFrom = secret.valueFrom;
} else {
// Else, create
containerDef.secrets.push(secret);
}
})
}
// Search container definition environment for one matching name
const secretDef = containerDef.secrets.find((s) => s.name == secret.name);
if (secretDef) {
// If found, update
secretDef.valueFrom = secret.valueFrom;
} else {
// Else, create
containerDef.secrets.push(secret);
}
})
}

if (logConfigurationLogDriver) {
Expand Down