Skip to content

Commit

Permalink
fix: Make CDKTF_LOG_FILE_DIRECTORY a common flag available on all c…
Browse files Browse the repository at this point in the history
…ommands (#3495)

<!--

Unless this is a very simple 1-line-of-code change, please create a new
issue describing the change you're proposing first, then link to it from
this PR.

Read more about our process in our contributing guide:
https://github.com/hashicorp/terraform-cdk/blob/main/CONTRIBUTING.md

-->

### Related issue

Fixes #3489 

### Description

We were using `CDKTF_LOG_FILE_DIRECTORY` within our logger, but we never
made it into a supported CLI flag. CDKTF configures
[yargs](https://yargs.js.org/) in a way that all environment variables
with the `CDKTF_` prefix are treated as CLI flags. For commands that had
[`strict`](https://yargs.js.org/docs/#api-reference-strictenabledtrue)
enabled, that means that setting any non-supported flag with the
`CDKTF_` prefix would cause the command to fail. This PR now adds
support for this flag and it should work across all commands.

---------

Co-authored-by: Ansgar Mertens <ansgar@hashicorp.com>
  • Loading branch information
mutahhir and ansgarm committed Feb 19, 2024
1 parent 65fbca7 commit 95aaeb5
Show file tree
Hide file tree
Showing 2 changed files with 255 additions and 175 deletions.
4 changes: 4 additions & 0 deletions packages/cdktf-cli/src/bin/cdktf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ yargs
required: false,
desc: "Which log level should be written. Only supported via setting the env CDKTF_LOG_LEVEL",
})
.option("log-file-directory", {
require: false,
desc: "The directory path where CDKTF should create `cdktf.log` and print logs at the `debug` level. If not set, CDKTF writes logs to standard out at the level specified in `CDKTF_LOG_LEVEL`. Only supported via setting the env CDKTF_LOG_FILE_DIRECTORY",
})
.option("context-json", {
required: false,
hidden: true,
Expand Down
Loading

0 comments on commit 95aaeb5

Please sign in to comment.