Skip to content

Commit

Permalink
patch(fix): octo-aws-cdk | image input for dockerExecutable can be co…
Browse files Browse the repository at this point in the history
…mmon.
  • Loading branch information
rash805115 committed Aug 8, 2024
1 parent cc6d3d1 commit 3682a5f
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 18 deletions.
2 changes: 2 additions & 0 deletions dictionary.dic
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ arn
ascii
autogenerated
automation
automations
aws
awsvpc
axios
Expand Down Expand Up @@ -64,6 +65,7 @@ loglayer
lstat
mdx
microservice
microservices
mnt
nacl
nginx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ import { ProcessUtility } from '../../../utilities/process/process.utility.js';
export class AddImageModelAction implements IModelAction {
readonly ACTION_NAME: string = 'AddImageModelAction';

collectInput(diff: Diff): string[] {
const { imageId } = diff.model as Image;

return [`input.image.${imageId}.dockerExecutable`];
collectInput(): string[] {
return ['input.image.dockerExecutable'];
}

filter(diff: Diff): boolean {
Expand All @@ -34,7 +32,7 @@ export class AddImageModelAction implements IModelAction {
async handle(diff: Diff, actionInputs: ActionInputs, actionOutputs: ActionOutputs): Promise<ActionOutputs> {
const { dockerOptions, imageId } = diff.model as Image;

const dockerExec = actionInputs[`input.image.${imageId}.dockerExecutable`] as string;
const dockerExec = actionInputs['input.image.dockerExecutable'] as string;

// Build command to build image.
const dockerfileParts = parse(dockerOptions.dockerfilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Image UT', () => {
beforeEach(async () => {
testModuleContainer = new TestModuleContainer({
inputs: {
'input.image.quadnix/test:0.0.1.dockerExecutable': 'docker',
'input.image.dockerExecutable': 'docker',
},
});
await testModuleContainer.initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import { EcrService } from '../ecr.service.model.js';
export class AddEcrServiceModelAction implements IModelAction {
readonly ACTION_NAME: string = 'AddEcrServiceModelAction';

collectInput(diff: Diff): string[] {
const imageInputs = (diff.model as EcrService).images.map((i) => `input.image.${i.imageId}.dockerExecutable`);
return [...imageInputs];
collectInput(): string[] {
return ['input.image.dockerExecutable'];
}

filter(diff: Diff): boolean {
Expand All @@ -35,9 +34,9 @@ export class AddEcrServiceModelAction implements IModelAction {
const awsRegionIds = (diff.model as EcrService).awsRegionIds;
const images = (diff.model as EcrService).images;

const dockerExec = actionInputs['input.image.dockerExecutable'] as string;
for (const awsRegionId of awsRegionIds) {
for (const image of images) {
const dockerExec = actionInputs[`input.image.${image.imageId}.dockerExecutable`] as string;
const dockerfileParts = parse(image.dockerOptions.dockerfilePath);

// Create ECR.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ import { EcrService } from '../ecr.service.model.js';
export class AddImageToEcrModelAction implements IModelAction {
readonly ACTION_NAME: string = 'AddImageToEcrModelAction';

collectInput(diff: Diff): string[] {
const { image } = diff.value as { image: Image };

return [`input.image.${image.imageId}.dockerExecutable`];
collectInput(): string[] {
return ['input.image.dockerExecutable'];
}

filter(diff: Diff): boolean {
Expand All @@ -36,7 +34,7 @@ export class AddImageToEcrModelAction implements IModelAction {
// Get properties.
const { awsRegionId, image } = diff.value as { awsRegionId: string; image: Image };

const dockerExec = actionInputs[`input.image.${image.imageId}.dockerExecutable`] as string;
const dockerExec = actionInputs['input.image.dockerExecutable'] as string;
const dockerfileParts = parse(image.dockerOptions.dockerfilePath);

// Create ECR.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ describe('EcrService UT', () => {
},
},
inputs: {
'input.image.imageName:0.0.1.dockerExecutable': 'docker',
'input.image.imageName:0.0.2.dockerExecutable': 'docker',
'input.image.dockerExecutable': 'docker',
},
});
await testModuleContainer.initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Image & ECRService E2E Test', () => {
const octoAws = new OctoAws();
await octoAws.initialize(new LocalStateProvider(__dirname));
octoAws.registerInputs({
'input.image.quadnix/test:0.0.1.dockerExecutable': 'docker',
'input.image.dockerExecutable': 'docker',
});

const app = new App('test');
Expand Down

0 comments on commit 3682a5f

Please sign in to comment.