Repository navigation
fix: Update workspace list implementation to tolerate warnings present in stdout output - #562
Conversation
|
This change is motivated by this update to Terraform Core, but it can be merged independently of that PR. Due to that I'm opening this PR for review. |
| current = line | ||
| } | ||
|
|
||
| if line != url.PathEscape(line) { |
There was a problem hiding this comment.
oof, this is precisely why we need JSON output. Kinda regret we even added support for this command here so early. 😂 😭
There was a problem hiding this comment.
FWIW I felt very dirty adding this code 😭 , but I'm working on JSON output!
|
I'll save merging this for when the JSON output for |
I think that merging both at the same time makes sense but keep in mind that we tend to maintain some level of compatibility within terraform-exec and so like with other commands with discussed, this implies initially introducing the JSON version as All that is to say that this patch will stay around until at least v1 and JSON cannot directly replace it yet. |
…ent in stdout output This is likely to be flaky and the best resolution is to add machine-readable output support to the workspace commands!
a98340c to
7a47383
Compare
|
I found some evidence of terraform-plugin-testing falling over due to warnings in the output from running |
05dfddb to
7a47383
Compare
|
Looks like the failing tests are due to the mismatch between hashicorp/terraform and hashicorp/terraform-exec - solved by #620 I hope. |
|
It looks like the E2E test failure is unrelated to this PR but will need addressing |

Note: This is likely to be flaky once warnings start being present in the command's stdout output. The best resolution is to add machine-readable output support to the workspace commands! I'm working on this.
Related Issue
N/A
Description
I'm proposing some changes to the
workspace listcommand to migrate it from using cli.Ui to view.View when rendering human-readable output. The command doesn't support machine-readable output, yet.That migration process will cause warning diagnostics to be sent to stdout instead of stderr, which is what happens currently. Due to this, terraform-exec is written to parse
workspace list's human-readable output under the assumption that stdout will only include the list of workspaces. This assumption is currently correct but might not be in future.If a warning is present in stdout the current parsing code will assume every non-empty line is a workspace name.
This PR introduces some light filtering of non-empty lines to determine if the string is part of a warning or a workspace name. This is based on how Terraform validates workspace names; URL escaping.
Rollback Plan
Changes to Security Controls
N/A