-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
JSON output fetching fixes #1462
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if my suggestions are not relevant, I will approve it.
modules/terraform/cmd.go
Outdated
} | ||
_, tgLogSet := options.EnvVars["TERRAGRUNT_DISABLE_LOG_FORMATTING"] | ||
if !tgLogSet { | ||
options.EnvVars["TERRAGRUNT_DISABLE_LOG_FORMATTING"] = "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This env var is deprecated, please use TERRAGRUNT_LOG_FORMAT=key-value
*But only if you use the latest version that supports log format.
modules/terraform/output.go
Outdated
|
||
var ( | ||
ansiLineRegex = regexp.MustCompile(`(?m)^\x1b\[[0-9;]*m.*`) | ||
tgLogLevel = regexp.MustCompile(`.*time=\S+ level=\S+ prefix=\S+ binary=\S+ msg=.*`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use TERRAGRUNT_LOG_CUSTOM_FORMAT="%msg(color=disable)"
to get rid of cleanJson
function at all.
*But only if you use the latest version that supports custom log format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Output still has lines like:
time=2024-12-05UTC17:32:10Z level=stdout tf-path=terraform msg=Initializing the backend...
which requires cleaning when parsing output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nit comments but overall LGTM.
} | ||
_, tgLogSet := options.EnvVars["TERRAGRUNT_LOG_FORMAT"] | ||
if !tgLogSet { | ||
options.EnvVars["TERRAGRUNT_LOG_FORMAT"] = "key-value" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what this does? It could be great to add some comments explanining the default behaviour here and below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added description
const skipJsonLogLine = " msg=" | ||
|
||
var ( | ||
ansiLineRegex = regexp.MustCompile(`(?m)^\x1b\[[0-9;]*m.*`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we add comments on what these regex mean in plain English?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Included changes:
Fixes #1453.
Fixes #1461.
TODOs
Read the Gruntwork contribution guidelines.
Release Notes (draft)
Added / Removed / Updated [X].
Updated output parsing from Terragrunt
Migration Guide