Skip to content

Commit

Permalink
Clarify log output from fidesctl status (#480)
Browse files Browse the repository at this point in the history
* Log success message only when successful

* Don't check status when running status

* Use a more straightforward conditional
  • Loading branch information
PSalant726 authored Apr 8, 2022
1 parent 8d7f2fd commit 8c474f5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion fidesctl/src/fidesctl/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ def cli(ctx: click.Context, config_path: str, local: bool) -> None:
click.echo(cli.get_help(ctx))

# Check the server health and version if an API command is invoked
if ctx.invoked_subcommand in [command.name for command in API_COMMANDS]:
if (
ctx.invoked_subcommand in [command.name for command in API_COMMANDS]
and ctx.invoked_subcommand != "status"
):
check_server(VERSION, config.cli.server_url)

if ctx.invoked_subcommand != "init": # init also handles this workflow
Expand Down
1 change: 0 additions & 1 deletion fidesctl/src/fidesctl/cli/commands/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def status(ctx: click.Context) -> None:
cli_version=cli_version,
server_url=server_url,
)
echo_green("Server is reachable and the client/server application versions match.")


@click.command()
Expand Down
10 changes: 7 additions & 3 deletions fidesctl/src/fidesctl/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from fideslog.sdk.python.exceptions import AnalyticsException
from fideslog.sdk.python.utils import OPT_OUT_COPY

from fidesctl.core.config.utils import get_config_from_file, update_config_file
from fidesctl.core.utils import echo_red, check_response
from fidesctl.core import api as _api
from fidesctl.core.config.utils import get_config_from_file, update_config_file
from fidesctl.core.utils import check_response, echo_green, echo_red


def check_server(cli_version: str, server_url: str) -> None:
Expand All @@ -31,7 +31,11 @@ def check_server(cli_version: str, server_url: str) -> None:
raise SystemExit(1)

server_version = health_response.json()["version"]
if str(server_version) != str(cli_version):
if str(server_version) == str(cli_version):
echo_green(
"Server is reachable and the client/server application versions match."
)
else:
echo_red(
f"Mismatched versions!\nServer Version: {server_version}\nCLI Version: {cli_version}"
)
Expand Down

0 comments on commit 8c474f5

Please sign in to comment.