-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Disable terminal colors when not an interactive terminal #15264
Comments
@mcandre you can use |
This should be fixed. A simple if (isatty(STDOUT_FILENO)) nocolorarg=1; or the equivalent for the language is all that is needed. |
Some Terraform commands are missing support for |
We want to spit these out right away, instead of asking the caller to re-run with --log-level=debug. The -no-color additions work around [1]; without them stripping newlines doesn't work, because there are color escapes in the way. Inserting a bug to test: $ git diff -U1 diff --git a/pkg/tfvars/tfvars.go b/pkg/tfvars/tfvars.go index d5f5543..8f44646 100644 --- a/pkg/tfvars/tfvars.go +++ b/pkg/tfvars/tfvars.go @@ -19,3 +19,3 @@ type config struct { Name string `json:"tectonic_cluster_name,omitempty"` - BaseDomain string `json:"tectonic_base_domain,omitempty"` + BaseDomain string `json:"xtectonic_base_domain,omitempty"` Masters int `json:"tectonic_master_count,omitempty"` $ hack/build.sh $ openshift-install cluster INFO Fetching OS image... INFO Using Terraform to create cluster... ERROR Failed to read tfstate ("/tmp/openshift-install-122374392/terraform.tfstate"): open /tmp/openshift-install-122374392/terraform.tfstate: no such file or directory ERROR Error: Error asking for user input: missing required value for "tectonic_base_domain" FATAL Failed to generate Cluster: failed to generate asset Cluster: failed to run terraform: failed to execute Terraform: exit status 1 [1]: hashicorp/terraform#15264
Would be great to be able to set |
cough |
You can use TF_CLI_ARGS environment variable, as advised here: #23708 (comment) |
|
|
I got bitten by this one recently and it was quite annoying so I went ahead and fixed it 🙂 |
We don't intend to automatically disable Terraform's terminal color output when not attached to an interactive terminal. There is software integrating with Terraform which redirects its output to a pipe or a file and expects the color UI output to remain, which means that we can't change this behavior for backwards compatibility reasons. The If you find a command which does not correctly support |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
When terraform is run by CI, or piped to
less
, or otherwise run in a non-tty environment, terminal codes should be disabled for more readable output.The text was updated successfully, but these errors were encountered: