Skip to content

Add --context-file param to override cdk.context.json #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mavwolverine
Copy link

Fixes ##632

This is replacement for PR aws/aws-cdk#23912


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Jun 4, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team June 4, 2025 17:40
Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting this raised again. Made some comments, we also need unit and integration tests for this.

Comment on lines +14 to +15
let PROJECT_CONTEXT = DEFAULT_PROJECT_CONTEXT;
export { PROJECT_CONTEXT };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not do this. It's going to be confusing if this value changes bases on whether load() has been called or not.

You can just update the name of the variable to DEFAULT_PROJECT_CONTEXT everywhere, or maybe for now just update the docblock.

fs.existsSync(expandHomeDir(userProjectContextFile))
) {
info(`Using specified project context ${userProjectContextFile}`);
PROJECT_CONTEXT = userProjectContextFile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

if (
userProjectContextFile &&
typeof userProjectContextFile === 'string' &&
fs.existsSync(expandHomeDir(userProjectContextFile))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think t the filepath should be considered relative to the user's home directory. It's also not what is done later on.

@@ -122,6 +124,20 @@ export class Configuration {
public async load(): Promise<this> {
const userConfig = await loadAndLog(USER_DEFAULTS);
this._projectConfig = await loadAndLog(PROJECT_CONFIG);
var userProjectContextFile = this.commandLineArguments.subSettings(['contextFile']).get([]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll need to store the value as a class property

@mrgrain
Copy link
Contributor

mrgrain commented Jun 30, 2025

@mavwolverine Do you still have the time and interest to move this forward? All good if not.

@mavwolverine
Copy link
Author

@mrgrain
Interest - yes
time - currently started work on a new project, so little short on time.

@mrgrain mrgrain marked this pull request as draft June 30, 2025 15:05
auto-merge was automatically disabled June 30, 2025 15:05

Pull request was converted to draft

@mrgrain
Copy link
Contributor

mrgrain commented Jun 30, 2025

All good and totally understandable! I'm moving this into draft state for now, so we can easily filter it out until you or someone else picks it up again. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants