Skip to content

Commit

Permalink
Merge pull request #38 from robusta-dev/cli-spinner
Browse files Browse the repository at this point in the history
add spinner icons to cli
  • Loading branch information
arikalon1 authored Aug 17, 2021
2 parents e65e2c5 + 106bffd commit e32164e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
22 changes: 21 additions & 1 deletion src/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ slack-sdk = "^3.7.0"
python-dotenv = "^0.18.0"
supabase-py = "^0.0.2"
datadog-api-client = "^1.2.0"
click-spinner = "^0.1.10"

[tool.poetry.dev-dependencies]
pre-commit = "^2.13.0"
Expand Down
3 changes: 2 additions & 1 deletion src/robusta/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import random
import subprocess
import time
import click_spinner
from zipfile import ZipFile
from kubernetes import config

Expand Down Expand Up @@ -80,7 +81,7 @@ def install(
if not upgrade: # download and deploy playbooks
examples_download(slack_api_key=slack_api_key)

with fetch_runner_logs(all_logs=True):
with fetch_runner_logs(all_logs=True), click_spinner.spinner():
log_title("Installing")
subprocess.check_call(["kubectl", "apply", "-f", filename])
log_title("Waiting for resources to be ready")
Expand Down
9 changes: 6 additions & 3 deletions src/robusta/cli/playbooks_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import subprocess
import time
import traceback
import click_spinner
from typing import List, Optional

import yaml
Expand Down Expand Up @@ -82,8 +83,8 @@ def print_yaml_if_not_none(key: str, json_dict: dict):
def list_(): # not named list as that would shadow the builtin list function
"""list current active playbooks"""
typer.echo(f"Getting deployed playbooks list...")

playbooks_config = get_runner_configmap()
with click_spinner.spinner():
playbooks_config = get_runner_configmap()

active_playbooks_file = playbooks_config["data"]["active_playbooks.yaml"]
active_playbooks_yaml = yaml.safe_load(active_playbooks_file)
Expand All @@ -98,7 +99,9 @@ def list_(): # not named list as that would shadow the builtin list function
@app.command()
def show_config():
"""fetch and show active_playbooks.yaml from cluster"""
playbooks_config = get_runner_configmap()
typer.echo("connecting to cluster...")
with click_spinner.spinner():
playbooks_config = get_runner_configmap()
active_playbooks_file = playbooks_config["data"]["active_playbooks.yaml"]
log_title("Contents of active_playbooks.yaml:")
typer.echo(active_playbooks_file)
Expand Down
10 changes: 6 additions & 4 deletions src/robusta/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import time
from contextlib import contextmanager

import click_spinner
import typer
import requests

from robusta._version import __version__

PLAYBOOKS_DIR = "playbooks/"


def exec_in_robusta_runner(
cmd, tries=1, time_between_attempts=10, error_msg="error running cmd"
):
Expand All @@ -34,8 +36,10 @@ def exec_in_robusta_runner(


def download_file(url, local_path):
response = requests.get(url)
response.raise_for_status()
typer.echo(f"downloading {url}")
with click_spinner.spinner():
response = requests.get(url)
response.raise_for_status()
with open(local_path, "wb") as f:
f.write(response.content)

Expand Down Expand Up @@ -80,5 +84,3 @@ def get_examples_url(examples_version=None):
if examples_version is None:
examples_version = __version__
return f"https://storage.googleapis.com/robusta-public/{examples_version}/example-playbooks.zip"


0 comments on commit e32164e

Please sign in to comment.