-
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
Add -ignore-empty-output flag #23008
Add -ignore-empty-output flag #23008
Conversation
Hi @jgrancell! Sorry for the slow response here, and thanks for working on this. We usually try to keep the number of options and other configurables in the CLI commands to a minimum and instead try to find a single behavior that's a good compromise between the various use-cases, because that makes Terraform easier to learn and use and it gives fewer different codepaths to maintain compatibility with as Terraform evolves. With that in mind, I was thinking about ways we could potentially meet your goal here without adding an extra option. It feels to me like there being no outputs defined is not really an error, because there being no outputs is a perfectly legitimate situation true of many reasonable configurations. We include the extra error message in the output in order to avoid a confusing situation where the command would otherwise produce no output at all, but I think we could reasonably continue to produce that error message while returning exit status zero. Therefore I'd like to propose a smaller change to make the exit status be zero when we display this error message, and make that be the default (and only) behavior. Folks who are running Terraform manually at a shell will still see the same result, while folks who are running Terraform in automation will avoid having to treat the zero-outputs case as special. For those who do want to treat zero outputs as special for some reason, they can use What do you think? Would that simplification still allow you to achieve your goals here? Thanks again for working on this! |
Thanks @jgrancell! I'm going to merge this now. |
Sounds good @apparentlymart . Thanks. Time to find a new bug to work on from the backlog. |
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. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This PR adds an
-ignore-empty-output
flag to theterraform output
command.With this flag, when
terraform output -ignore-empty-flag
is run against no state or empty state, the exit status is 0 and the output is not from Error().Without this flag, when
terraform output
is run against no state or empty state, the exit status remains 1 and the output continues to be from Error().When merged, resolves #18975