Skip to content
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

Serialize ValidationRules and Error when output format is Yaml or Json #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jpescalona
Copy link

@jpescalona jpescalona commented Dec 3, 2024

Description: Errors are not printed when ouput is JSON or YAML format.

Steps to reproduce:

  • Create an alert rule file with failures (argocd-example.yaml.txt)
  • Use example/validation.yaml config file provided in project repository in examples folder.
  • Execute promruval with --output argument with yaml or json
$ ./promruval validate --config-file=$(pwd)/examples/validation.yaml /tmp/rules/argocd.yaml --output json > /tmp/output.json
INFO[2024-12-03T14:06:11+01:00] processing file                               file/tmp/rules/argocd.yaml progress=1/1
INFO[2024-12-03T14:06:11+01:00] successfully dumped cache to file             file_name=.promruval_cache.json
INFO[2024-12-03T14:06:11+01:00] cache dumped                                  duration="246.631µs"
$ ./promruval validate --config-file=$(pwd)/examples/validation.yaml /tmp/rules/argocd.yaml --output yaml > /tmp/output.yaml
INFO[2024-12-03T14:06:16+01:00] processing file                               file=/tmp/rules/argocd.yaml progress=1/1
INFO[2024-12-03T14:06:16+01:00] successfully dumped cache to file             file_name=.promruval_cache.json
INFO[2024-12-03T14:06:16+01:00] cache dumped                                  duration="313.77µs"

Current results:
Output on YAML or JSON format does not contain Error values, see attached output files:

Expected results:
Output of YAML and JSON format contain Error values, see attached files:

Which operating system are you using? Linux Fedora 41 6.11.10-300.fc41.x86_64

go version go1.23.3 linux/amd64

Additional details:

After some research, it seems JSON or YAML Marshal does not work for Error struct: golang/go#5161

@jpescalona
Copy link
Author

Please, feel free to provide feedback about the code, given i'm newbie on golang :)

@jpescalona jpescalona force-pushed the serialize_error_objects_on_json_and_yaml_output branch from 2df820f to 0d9f3c2 Compare December 3, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant