fix: suppress informational messages in JSON output mode
Description
- fix: suppress informational messages in JSON output mode
Previously, when using --output json flag, both variable list and
iteration list commands would output informational messages to stdout
alongside the JSON data, contaminating the output and making it invalid
JSON that cannot be parsed by machines.
Changes made:
-
variable list (internal/commands/variable/list/list.go):
- Wrap "Listing variables for the X group" message in json check
- Wrap "Listing variables for the instance" message in json check
- Wrap "Listing variables from the X project" message in json check
-
iteration list (internal/commands/iteration/list/iteration_list.go):
- Move formatted iteration output into text-only branches
- Previously the fmt.Fprintln was executed unconditionally after the JSON output, appending the entire formatted iteration list to the JSON output
These changes follow the pattern used in other correctly-implemented list commands (mr list, label list, project list, ci list) where informational output is suppressed when JSON format is requested.
Related to merge request !2515 (merged) which clarified log targets by renaming Log/Logf to LogError/LogErrorf.
Resolves: #8127 (closed)
Related Issues
Resolves #[issue_number]