Skip to content
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

Switch from https to ssh when cloning with osc at least for src.suse.de. #31

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions obs_scm_bridge
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pack_directories = False
get_assets = False
shallow_clone = True
create_obsinfo = False
rewrite_url_to_ssh = False

if os.environ.get('DEBUG_SCM_BRIDGE') == "1":
logging.getLogger().setLevel(logging.DEBUG)
Expand All @@ -44,6 +45,7 @@ if os.environ.get('OSC_VERSION'):
get_assets = True
shallow_clone = False
create_obsinfo = False
rewrite_url_to_ssh = True
os.environ['LANG'] = "C"

class ObsGit(object):
Expand Down Expand Up @@ -107,6 +109,21 @@ class ObsGit(object):
scmtoolurl = self.url.copy()
if scmtoolurl[0] and scmtoolurl[0][0:4] == 'git+':
scmtoolurl[0] = scmtoolurl[0][4:]
# we want to switch to ssh as the user is likely providing his
# access via ssh pub key already.
# Unfortunality there is no generic way to rewrite the url as
# it depends on the installation.
# For now we hard code our instances, but this needs to become
# configurable or we need to detect it by asking the server
# somehow.
# Expect this to be moved to a config file
if rewrite_url_to_ssh and scmtoolurl[0] == 'https':
if scmtoolurl[1] == 'src.suse.de':
scmtoolurl[1] = '[email protected]'
scmtoolurl[0] = 'ssh'
elif scmtoolurl[1] == 'src.opensuse.org':
scmtoolurl[1] = '[email protected]'
scmtoolurl[0] = 'ssh'
self.scmtoolurl = urllib.parse.urlunparse(scmtoolurl)

def add_critical_instance(
Expand Down