do not share build parameters in tests - in cloud runner this will cause conflicts with resouces of the same name
parent
eae5a32b93
commit
912cad6b2a
|
|
@ -1173,6 +1173,70 @@ class AWSBaseStack {
|
||||||
exports.AWSBaseStack = AWSBaseStack;
|
exports.AWSBaseStack = AWSBaseStack;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 44776:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.AWSCloudFormationTemplates = void 0;
|
||||||
|
const fs = __importStar(__nccwpck_require__(57147));
|
||||||
|
class AWSCloudFormationTemplates {
|
||||||
|
static getParameterTemplate(p1) {
|
||||||
|
return `
|
||||||
|
${p1}:
|
||||||
|
Type: String
|
||||||
|
Default: ''
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
static getSecretTemplate(p1) {
|
||||||
|
return `
|
||||||
|
${p1}Secret:
|
||||||
|
Type: AWS::SecretsManager::Secret
|
||||||
|
Properties:
|
||||||
|
Name: '${p1}'
|
||||||
|
SecretString: !Ref ${p1}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
static getSecretDefinitionTemplate(p1, p2) {
|
||||||
|
return `
|
||||||
|
- Name: '${p1}'
|
||||||
|
ValueFrom: !Ref ${p2}Secret
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
static insertAtTemplate(template, insertionKey, insertion) {
|
||||||
|
const index = template.search(insertionKey) + insertionKey.length + '\n'.length;
|
||||||
|
template = [template.slice(0, index), insertion, template.slice(index)].join('');
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
static readTaskCloudFormationTemplate() {
|
||||||
|
return fs.readFileSync(`${__dirname}/cloud-formations/task-def-formation.yml`, 'utf8');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.AWSCloudFormationTemplates = AWSCloudFormationTemplates;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 83683:
|
/***/ 83683:
|
||||||
|
|
@ -1253,7 +1317,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.AWSJobStack = void 0;
|
exports.AWSJobStack = void 0;
|
||||||
const aws_templates_1 = __nccwpck_require__(6436);
|
const aws_cloud_formation_templates_1 = __nccwpck_require__(44776);
|
||||||
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
||||||
const aws_error_1 = __nccwpck_require__(83683);
|
const aws_error_1 = __nccwpck_require__(83683);
|
||||||
class AWSJobStack {
|
class AWSJobStack {
|
||||||
|
|
@ -1263,7 +1327,7 @@ class AWSJobStack {
|
||||||
setupCloudFormations(CF, buildGuid, image, entrypoint, commands, mountdir, workingdir, secrets) {
|
setupCloudFormations(CF, buildGuid, image, entrypoint, commands, mountdir, workingdir, secrets) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const taskDefStackName = `${this.baseStackName}-${buildGuid}`;
|
const taskDefStackName = `${this.baseStackName}-${buildGuid}`;
|
||||||
let taskDefCloudFormation = aws_templates_1.AWSTemplates.readTaskCloudFormationTemplate();
|
let taskDefCloudFormation = aws_cloud_formation_templates_1.AWSCloudFormationTemplates.readTaskCloudFormationTemplate();
|
||||||
for (const secret of secrets) {
|
for (const secret of secrets) {
|
||||||
secret.ParameterKey = `${buildGuid.replace(/[^\dA-Za-z]/g, '')}${secret.ParameterKey.replace(/[^\dA-Za-z]/g, '')}`;
|
secret.ParameterKey = `${buildGuid.replace(/[^\dA-Za-z]/g, '')}${secret.ParameterKey.replace(/[^\dA-Za-z]/g, '')}`;
|
||||||
if (typeof secret.ParameterValue == 'number') {
|
if (typeof secret.ParameterValue == 'number') {
|
||||||
|
|
@ -1273,9 +1337,9 @@ class AWSJobStack {
|
||||||
secrets = secrets.filter((x) => x !== secret);
|
secrets = secrets.filter((x) => x !== secret);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
taskDefCloudFormation = aws_templates_1.AWSTemplates.insertAtTemplate(taskDefCloudFormation, 'p1 - input', aws_templates_1.AWSTemplates.getParameterTemplate(secret.ParameterKey));
|
taskDefCloudFormation = aws_cloud_formation_templates_1.AWSCloudFormationTemplates.insertAtTemplate(taskDefCloudFormation, 'p1 - input', aws_cloud_formation_templates_1.AWSCloudFormationTemplates.getParameterTemplate(secret.ParameterKey));
|
||||||
taskDefCloudFormation = aws_templates_1.AWSTemplates.insertAtTemplate(taskDefCloudFormation, 'p2 - secret', aws_templates_1.AWSTemplates.getSecretTemplate(`${secret.ParameterKey}`));
|
taskDefCloudFormation = aws_cloud_formation_templates_1.AWSCloudFormationTemplates.insertAtTemplate(taskDefCloudFormation, 'p2 - secret', aws_cloud_formation_templates_1.AWSCloudFormationTemplates.getSecretTemplate(`${secret.ParameterKey}`));
|
||||||
taskDefCloudFormation = aws_templates_1.AWSTemplates.insertAtTemplate(taskDefCloudFormation, 'p3 - container def', aws_templates_1.AWSTemplates.getSecretDefinitionTemplate(secret.EnvironmentVariable, secret.ParameterKey));
|
taskDefCloudFormation = aws_cloud_formation_templates_1.AWSCloudFormationTemplates.insertAtTemplate(taskDefCloudFormation, 'p3 - container def', aws_cloud_formation_templates_1.AWSCloudFormationTemplates.getSecretDefinitionTemplate(secret.EnvironmentVariable, secret.ParameterKey));
|
||||||
}
|
}
|
||||||
const secretsMappedToCloudFormationParameters = secrets.map((x) => {
|
const secretsMappedToCloudFormationParameters = secrets.map((x) => {
|
||||||
return { ParameterKey: x.ParameterKey.replace(/[^\dA-Za-z]/g, ''), ParameterValue: x.ParameterValue };
|
return { ParameterKey: x.ParameterKey.replace(/[^\dA-Za-z]/g, ''), ParameterValue: x.ParameterValue };
|
||||||
|
|
@ -1586,70 +1650,6 @@ class AWSTaskRunner {
|
||||||
exports["default"] = AWSTaskRunner;
|
exports["default"] = AWSTaskRunner;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 6436:
|
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.AWSTemplates = void 0;
|
|
||||||
const fs = __importStar(__nccwpck_require__(57147));
|
|
||||||
class AWSTemplates {
|
|
||||||
static getParameterTemplate(p1) {
|
|
||||||
return `
|
|
||||||
${p1}:
|
|
||||||
Type: String
|
|
||||||
Default: ''
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
static getSecretTemplate(p1) {
|
|
||||||
return `
|
|
||||||
${p1}Secret:
|
|
||||||
Type: AWS::SecretsManager::Secret
|
|
||||||
Properties:
|
|
||||||
Name: '${p1}'
|
|
||||||
SecretString: !Ref ${p1}
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
static getSecretDefinitionTemplate(p1, p2) {
|
|
||||||
return `
|
|
||||||
- Name: '${p1}'
|
|
||||||
ValueFrom: !Ref ${p2}Secret
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
static insertAtTemplate(template, insertionKey, insertion) {
|
|
||||||
const index = template.search(insertionKey) + insertionKey.length + '\n'.length;
|
|
||||||
template = [template.slice(0, index), insertion, template.slice(index)].join('');
|
|
||||||
return template;
|
|
||||||
}
|
|
||||||
static readTaskCloudFormationTemplate() {
|
|
||||||
return fs.readFileSync(`${__dirname}/cloud-formations/task-def-formation.yml`, 'utf8');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.AWSTemplates = AWSTemplates;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 37569:
|
/***/ 37569:
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
export class AWSTemplates {
|
export class AWSCloudFormationTemplates {
|
||||||
public static getParameterTemplate(p1) {
|
public static getParameterTemplate(p1) {
|
||||||
return `
|
return `
|
||||||
${p1}:
|
${p1}:
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import * as SDK from 'aws-sdk';
|
import * as SDK from 'aws-sdk';
|
||||||
import CloudRunnerAWSTaskDef from './cloud-runner-aws-task-def';
|
import CloudRunnerAWSTaskDef from './cloud-runner-aws-task-def';
|
||||||
import CloudRunnerSecret from '../services/cloud-runner-secret';
|
import CloudRunnerSecret from '../services/cloud-runner-secret';
|
||||||
import { AWSTemplates } from './aws-templates';
|
import { AWSCloudFormationTemplates } from './aws-cloud-formation-templates';
|
||||||
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||||
import { AWSError } from './aws-error';
|
import { AWSError } from './aws-error';
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ export class AWSJobStack {
|
||||||
secrets: CloudRunnerSecret[],
|
secrets: CloudRunnerSecret[],
|
||||||
): Promise<CloudRunnerAWSTaskDef> {
|
): Promise<CloudRunnerAWSTaskDef> {
|
||||||
const taskDefStackName = `${this.baseStackName}-${buildGuid}`;
|
const taskDefStackName = `${this.baseStackName}-${buildGuid}`;
|
||||||
let taskDefCloudFormation = AWSTemplates.readTaskCloudFormationTemplate();
|
let taskDefCloudFormation = AWSCloudFormationTemplates.readTaskCloudFormationTemplate();
|
||||||
for (const secret of secrets) {
|
for (const secret of secrets) {
|
||||||
secret.ParameterKey = `${buildGuid.replace(/[^\dA-Za-z]/g, '')}${secret.ParameterKey.replace(
|
secret.ParameterKey = `${buildGuid.replace(/[^\dA-Za-z]/g, '')}${secret.ParameterKey.replace(
|
||||||
/[^\dA-Za-z]/g,
|
/[^\dA-Za-z]/g,
|
||||||
|
|
@ -35,20 +35,20 @@ export class AWSJobStack {
|
||||||
secrets = secrets.filter((x) => x !== secret);
|
secrets = secrets.filter((x) => x !== secret);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
taskDefCloudFormation = AWSTemplates.insertAtTemplate(
|
taskDefCloudFormation = AWSCloudFormationTemplates.insertAtTemplate(
|
||||||
taskDefCloudFormation,
|
taskDefCloudFormation,
|
||||||
'p1 - input',
|
'p1 - input',
|
||||||
AWSTemplates.getParameterTemplate(secret.ParameterKey),
|
AWSCloudFormationTemplates.getParameterTemplate(secret.ParameterKey),
|
||||||
);
|
);
|
||||||
taskDefCloudFormation = AWSTemplates.insertAtTemplate(
|
taskDefCloudFormation = AWSCloudFormationTemplates.insertAtTemplate(
|
||||||
taskDefCloudFormation,
|
taskDefCloudFormation,
|
||||||
'p2 - secret',
|
'p2 - secret',
|
||||||
AWSTemplates.getSecretTemplate(`${secret.ParameterKey}`),
|
AWSCloudFormationTemplates.getSecretTemplate(`${secret.ParameterKey}`),
|
||||||
);
|
);
|
||||||
taskDefCloudFormation = AWSTemplates.insertAtTemplate(
|
taskDefCloudFormation = AWSCloudFormationTemplates.insertAtTemplate(
|
||||||
taskDefCloudFormation,
|
taskDefCloudFormation,
|
||||||
'p3 - container def',
|
'p3 - container def',
|
||||||
AWSTemplates.getSecretDefinitionTemplate(secret.EnvironmentVariable, secret.ParameterKey),
|
AWSCloudFormationTemplates.getSecretDefinitionTemplate(secret.EnvironmentVariable, secret.ParameterKey),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const secretsMappedToCloudFormationParameters = secrets.map((x) => {
|
const secretsMappedToCloudFormationParameters = secrets.map((x) => {
|
||||||
|
|
|
||||||
|
|
@ -219,3 +219,4 @@ Metadata:
|
||||||
target:
|
target:
|
||||||
id: aece53ae-b82d-4267-bc16-ed964b05db27
|
id: aece53ae-b82d-4267-bc16-ed964b05db27
|
||||||
z: 13
|
z: 13
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,9 @@ describe('Cloud Runner', () => {
|
||||||
const results = await CloudRunner.run(buildParameter, baseImage.toString());
|
const results = await CloudRunner.run(buildParameter, baseImage.toString());
|
||||||
const libraryString = 'Rebuilding Library because the asset database could not be found!';
|
const libraryString = 'Rebuilding Library because the asset database could not be found!';
|
||||||
expect(results).toContain(libraryString);
|
expect(results).toContain(libraryString);
|
||||||
const results2 = await CloudRunner.run(buildParameter, baseImage.toString());
|
const buildParameter2 = await BuildParameters.create();
|
||||||
|
const baseImage2 = new ImageTag(buildParameter2);
|
||||||
|
const results2 = await CloudRunner.run(buildParameter2, baseImage2.toString());
|
||||||
expect(results2).toEqual(expect.not.stringContaining(libraryString));
|
expect(results2).toEqual(expect.not.stringContaining(libraryString));
|
||||||
delete CLI.options;
|
delete CLI.options;
|
||||||
}, 1000000);
|
}, 1000000);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue