-
Notifications
You must be signed in to change notification settings - Fork 34
feat: Implement returning error code to anta functions #196
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
Conversation
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Conflicts have been resolved. A maintainer will review the pull request shortly. |
anta/cli/__init__.py
Outdated
@@ -55,11 +55,15 @@ | |||
), | |||
callback=setup_logging, | |||
) | |||
@click.option("--ignore-status", show_envvar=True, default=False, help="Always exit with success", is_eager=True) | |||
@click.option("--ignore-error", show_envvar=True, default=False, help="Only report failures and not errors", is_eager=True) | |||
def anta(ctx: click.Context, inventory: AntaInventory, **kwargs: Dict[str, Any]) -> None: |
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.
Possible to do that:
def anta(ctx: click.Context, inventory: AntaInventory, **kwargs: Dict[str, Any]) -> None: | |
def anta(ctx: click.Context, inventory: AntaInventory, ignore_status: bool, ignore_error: bool, **kwargs: Dict[str, Any]) -> None: |
anta/cli/__init__.py
Outdated
@@ -55,11 +55,15 @@ | |||
), | |||
callback=setup_logging, | |||
) | |||
@click.option("--ignore-status", show_envvar=True, default=False, help="Always exit with success", is_eager=True) |
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.
is_eager is not needed here.
Also, defining options like this means you wants a boolean as parameter.
anta --help
--ignore-status BOOLEAN Always exit with success [env var:
ANTA_IGNORE_STATUS]
--ignore-error BOOLEAN Only report failures and not errors [env
var: ANTA_IGNORE_ERROR]
You need
@click.option("--ignore-status", show_envvar=True, default=False, help="Always exit with success", is_eager=True) | |
@click.option("--ignore-status", is_flag=True, show_envvar=True, default=False, help="Always exit with success") |
Could you also update the insecure flag with the is_flag=True param ?
Fixes #192 (even if apparently I can't even name my branches right!)
Behavior tested locally with the various new CLI flags