Skip to content

Commit

Permalink
Support accessing remote registries via ssh
Browse files Browse the repository at this point in the history
The URL has to be given as "ssh://[user@]host.xz[:port]/path/to/repo.git"
rather than the shorter version "[user@]host.xz:path/to/repo.git"
  • Loading branch information
muffato committed Sep 4, 2022
1 parent c035442 commit b7abd36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions shpc/main/registry/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Provider:
"""

def __init__(self, source, *args, **kwargs):
if not (source.startswith("https://") or os.path.exists(source)):
if not (source.startswith("https://") or source.startswith("ssh://") or os.path.exists(source)):
raise ValueError(
"Registry source must exist on the filesystem or be given as https://."
)
Expand All @@ -44,7 +44,7 @@ def exists(self, name):

@property
def is_filesystem_registry(self):
return not self.source.startswith("http") and os.path.exists(self.source)
return not (self.source.startswith("http") or self.source.startswith("ssh")) and os.path.exists(self.source)

@property
def name(self):
Expand Down
4 changes: 3 additions & 1 deletion shpc/main/registry/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(self, *args, **kwargs):

@classmethod
def matches(cls, source):
return cls.provider_name in source and source.startswith("http")
return cls.provider_name in source and (source.startswith("http") or source.startswith("ssh"))

@property
def source_url(self):
Expand Down Expand Up @@ -190,6 +190,8 @@ def _update_cache(self, force=False):
if self._cache and not force:
return

if self.source.startswith("ssh"):
return self._update_clone_cache()
# Check for exposed library API on GitHub or GitLab pages
response = requests.get(self.web_url)
if response.status_code != 200:
Expand Down

0 comments on commit b7abd36

Please sign in to comment.