Skip to content

Commit

Permalink
[DOP-4171]: Add ability to pass snooty parser version to cdk
Browse files Browse the repository at this point in the history
  • Loading branch information
branberry committed Jan 24, 2024
1 parent f2b22c4 commit 4e30595
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { LogGroup } from 'aws-cdk-lib/aws-logs';
import { Bucket } from 'aws-cdk-lib/aws-s3';
import { Construct } from 'constructs';
import path from 'path';
import { getSnootyParserVersion } from '../../../utils/env';

const SNOOTY_CACHE_BUCKET_NAME = 'snooty-parse-cache';

Expand Down Expand Up @@ -40,10 +41,13 @@ export class CacheUpdaterWorkerConstruct extends Construct {

const containerName = 'cacheUpdaterWorkerImage';
const taskDefLogGroup = new LogGroup(this, 'cacheUpdaterWorkerLogGroup');

const snootyParserVersion = getSnootyParserVersion();

taskDefinition.addContainer('cacheUpdaterWorkerImage', {
image: ContainerImage.fromAsset(path.join(__dirname, '../../../../'), {
file: 'src/cache-updater/Dockerfile.cacheUpdater',
buildArgs: { SNOOTY_PARSER_VERSION: '0.15.2' }, // TODO: Update this to use a context variable
buildArgs: { SNOOTY_PARSER_VERSION: snootyParserVersion },
exclude: ['tests/', 'node_modules/', 'cdk-infra/'], // adding this just in case it doesn't pick up our dockerignore
}),
environment: {
Expand Down
7 changes: 7 additions & 0 deletions cdk-infra/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const autoBuilderContextVariables = [
'customFeatureName',
'env',
'useCustomBuckets',
'snootyParserVersion',
] as const;

export type SnootyEnv = (typeof snootyEnvs)[number];
Expand Down Expand Up @@ -76,7 +77,13 @@ export function getEnv(): AutoBuilderEnv {
export function isEnhanced(): boolean {
return !!contextVarsMap.get('enhanced');
}
export function getSnootyParserVersion(): string {
checkContextInit();
const snootyParserVersion = contextVarsMap.get('snootyParserVersion');
if (!snootyParserVersion) throw new Error('Error! The context variable snootyParserVersion is not defined.');

return snootyParserVersion;
}
export function getFeatureName(): string {
checkContextInit();

Expand Down

0 comments on commit 4e30595

Please sign in to comment.