Skip to content

Commit

Permalink
support https links to playbook git repos (#240)
Browse files Browse the repository at this point in the history
* add https git support

* https support

* fix comment

* added https git playbook documentation

* added more documentation info

Co-authored-by: avi robusta <[email protected]>
  • Loading branch information
kotlickya and Avi-Robusta authored Feb 24, 2022
1 parent eae5a7f commit a603812
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
17 changes: 15 additions & 2 deletions docs/user-guide/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,20 @@ Playbook actions are loaded into Robusta using the ``playbookRepos`` Helm value.

Robusta has a set of builtin playbooks.

You can load extra playbook actions from git repositories:
You can load extra playbook actions in two different ways from git repositories, via HTTPS or via SSH.
For public repos load the playbook via HTTPS, for private repos you will need to use SSH.

1) Loading a git playbook by HTTPS:

.. code-block:: yaml
playbookRepos:
# we're adding the robusta chaos-engineering playbooks here from https://github.com/robusta-dev/robusta-chaos
my_extra_playbooks:
url: "https://github.com/robusta-dev/robusta-chaos.git"
2) Loading a git playbook by SSH:

.. code-block:: yaml
Expand All @@ -248,7 +261,7 @@ You can load extra playbook actions from git repositories:
-----END OPENSSH PRIVATE KEY-----
The ``key`` should contain a deployment key, with ``read`` access. It isn't necessary for public repositories.
The ``key`` should contain a deployment key, with ``read`` access. The ``key`` is required when accessing a git repo via ssh, even for public repositories.

.. note::

Expand Down
3 changes: 2 additions & 1 deletion src/robusta/integrations/git/git_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
)
SSH_ROOT_DIR = os.environ.get("SSH_ROOT_DIR", "/root/.ssh")

GIT_URL_PREFIX = "git@"
GIT_SSH_PREFIX = "git@"
GIT_HTTPS_PREFIX = "https://git"
LOCAL_PATH_URL_PREFIX = "file://"


Expand Down
7 changes: 4 additions & 3 deletions src/robusta/runner/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
from ..integrations.git.git_repo import (
GitRepoManager,
GitRepo,
GIT_URL_PREFIX,
GIT_SSH_PREFIX,
GIT_HTTPS_PREFIX,
LOCAL_PATH_URL_PREFIX,
)
from ..utils.file_system_watcher import FileSystemWatcher
Expand Down Expand Up @@ -119,7 +120,7 @@ def __load_playbooks_repos(
if (
playbooks_repo.pip_install
): # skip playbooks that are already in site-packages
if playbooks_repo.url.startswith(GIT_URL_PREFIX):
if playbooks_repo.url.startswith(GIT_SSH_PREFIX) or playbooks_repo.url.startswith(GIT_HTTPS_PREFIX):
repo = GitRepo(
playbooks_repo.url,
playbooks_repo.key.get_secret_value(),
Expand All @@ -132,7 +133,7 @@ def __load_playbooks_repos(
else:
raise Exception(
f"Illegal playbook repo url {playbooks_repo.url}. "
f"Must start with '{GIT_URL_PREFIX}' or '{LOCAL_PATH_URL_PREFIX}'"
f"Must start with '{GIT_SSH_PREFIX}', '{GIT_HTTPS_PREFIX}' or '{LOCAL_PATH_URL_PREFIX}'"
)

if not os.path.exists(
Expand Down

0 comments on commit a603812

Please sign in to comment.