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
PR to add Thiserror to cfn-guard #329
PR to add Thiserror to cfn-guard #329
Conversation
956f2d8
to
a2b2204
Compare
@@ -8,10 +8,12 @@ mod rules; | |||
mod utils; | |||
|
|||
use crate::commands::{MIGRATE, OUTPUT, PARSE_TREE, RULEGEN}; | |||
use crate::utils::writer::WriteBuffer::Stderr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this used?
@@ -62,7 +64,10 @@ fn main() -> Result<(), Error> { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be somewhere before this block, we initialize Stdout to be the err buffer, right?
#[case] rules_arg: &str, | ||
#[case] expected_writer_output: &str, | ||
#[case] expected_status_code: i32, | ||
) { | ||
let mut writer = Writer::new(WBVec(vec![])); | ||
let mut writer = Writer::new_with_custom_stderr(WBVec(vec![])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we were going to remove these custom constructors to replace it with a generic one all across the code base, no?
* Improve handling of function references for test command (#331) * improving handling for tagged values for test command * removing shorthand functions from known issues * PR to add Thiserror to cfn-guard (#329) * PR to add thiserror to guard * cleanup * clippy lints * printing errs to stderr instead of stdout * merge conflicts * rustfmt * cleaning up code * Redirected verbose output from stdout to custom writer and added unit… (#332) * Redirected verbose output from stdout to custom writer and added unit tests * Updated one more occurrence & removed new line from 2 places --------- Co-authored-by: Akshay Rane <raneaks@amazon.com> * Addit cargo-audit to CI + bump up clap to 3.0 (#330) * init commit, bumped up clap to 3.0 * cargo audit for CI * reverting last commit + changing cargo-audit to not be part of build step, only ran every night * changing cronjob to run at noon instead of midnight * fixing error in cronjob scheduling * Implemented custom reader, increasing test coverage for validate command. (#334) * init commit for reader + more unit tests for validate * init commit for reader + more unit tests for validate * temp * temp2 * rebasing * clippy lints for validate * more tests for validate * adding thiserror license to attributions * removing useless code * renaming tests * fix failing test * fixes as per comments * attribution update * moved get_reader fn to utils * Update CONTRIBUTING.md (#335) * Clap4 (#336) * init commit, bumped up clap to 3.0 * cargo audit for CI * reverting last commit + changing cargo-audit to not be part of build step, only ran every night * init commit bumping up to clap4 * cleaning some code up * temp commit * rebasing + fixing small bug * cleanup * adding help messages * adding more tests for test_command * more tests for prev engine * improving code style * typo * fixed unecessary match * cleaning up test command * fixes as per comments * fixes as per comments * fixed failing build * Added integration tests against aws-guard-rules-registry on Ubuntu (#337) * Added GitHub action for integration test with rules registry * Changed branch name for testing * Changed ref tag * Changed repo param * Removed tags temporarily * Added temp in-place replacement and main branch as ref * Corrected the sequence of commands * Added parse-tree integration tests * Changed dir and limited build to one crate * Added names to each job * Added logic to allow capturing of exit codes * Testing exit code script * Added if as part of error handling * Added statements for test command * Version before changing branch * Changed branches * Bug fix for output arg being pulled before we enter command context * Workaround to skip comments only files * Added test remote branch back * Corrected the condition * Made SKIPPED_RULE_COUNT a variable * Updated display messages * Removed tabs * Updated branches * Updated code to extract OUTPUT arg from subcommand instead of the app --------- Co-authored-by: Akshay Rane <raneaks@amazon.com> * Update check-tags-present.guard (#313) replaced "is" with "if". Also. can you provide more detailed explanation for this guard file * Adding structured evaluator (#339) * init commit for reader + more unit tests for validate * implemented structured reporter + some small refactorings * clippy lints * adding structured reporter for payload code path * adding test for structured payload * cleanup * adding previoius-engine as a conflict with structured * adding fix for recursive serialization issue * adding test for structured yaml * Added deprecated short flag for print-json in parse-tree (#345) * Added deprecated short flag for print-json in parse-tree * Formatting changes * Added docs --------- Co-authored-by: Akshay Rane <raneaks@amazon.com> --------- Co-authored-by: Akshay Rane <aks.rane@gmail.com> Co-authored-by: Akshay Rane <raneaks@amazon.com> Co-authored-by: swiercek <111157886+swiercek@users.noreply.github.com> Co-authored-by: Aishwarya4400 <50081627+Aishwarya4400@users.noreply.github.com>
Issue #, if available:
Description of changes:
This pr changes the way we handle errors to use the popular rust crate called thiserror. This helps us reduce nesting for enum variants, allowing for more readable code. This change also makes it easier to integrate with other crates in the future.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license