-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add --no-warnings flag to suppress warning messages
This PR implements the feature requested in issue #2295, adding the ability to suppress warning messages when running chainsaw test. The implementation: - Adds a new --no-warnings command line flag to the test command - Creates a new filtered sink (NewFilteredSink) that skips logs with WarnStatus - Updates the test command to use the filtered sink when --no-warnings is set - Adds unit tests for the new filtered sink functionality - Adds integration tests for the --no-warnings flag - Creates comprehensive documentation for output control options - Provides examples demonstrating the flag's usage This improves user experience by allowing cleaner output during test runs where warnings might be expected or irrelevant. Resolves: #2295 Signed-off-by: Karthik babu Manam <[email protected]>
- Loading branch information
1 parent
951b7d1
commit 7db8a0a
Showing
12 changed files
with
322 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Output Control Example | ||
|
||
This example demonstrates how to use Chainsaw's output control features, specifically the `--no-warnings` flag. | ||
|
||
## Overview | ||
|
||
The test in this directory intentionally generates warning messages that can be suppressed using the `--no-warnings` flag. | ||
|
||
## Files | ||
|
||
- `chainsaw-test.yaml`: Contains a test that generates a warning message | ||
|
||
## Usage | ||
|
||
Run the test with and without the `--no-warnings` flag to see the difference: | ||
|
||
```bash | ||
# Run with warnings (default) | ||
chainsaw test ./examples/output-control | ||
|
||
# Run with warnings suppressed | ||
chainsaw test --no-warnings ./examples/output-control | ||
``` | ||
|
||
## Expected Output | ||
|
||
### With Warnings (Default) | ||
|
||
``` | ||
| XX:XX:XX | warning-example | step-warning-example | COMMAND | WARN | This is a warning message that would be suppressed with --no-warnings | ||
| XX:XX:XX | warning-example | step-warning-example | COMMAND | DONE | | ||
``` | ||
|
||
### With Warnings Suppressed | ||
|
||
``` | ||
| XX:XX:XX | warning-example | step-warning-example | COMMAND | DONE | | ||
``` | ||
|
||
The warning message is completely removed from the output when using the `--no-warnings` flag. | ||
|
||
## Additional Resources | ||
|
||
For more information on output control options, see the [Output Control documentation](https://kyverno.github.io/chainsaw/latest/reference/output-control/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: warning-example | ||
spec: | ||
steps: | ||
- name: step-warning-example | ||
try: | ||
- operation: | ||
command: | ||
# Generate a warning message in the logs | ||
script: | | ||
echo "This is a warning message that would be suppressed with --no-warnings" | ||
# Exit with code 0 to ensure the test succeeds | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.