Skip to content

Commit

Permalink
experimental: allow choosing a lp instance
Browse files Browse the repository at this point in the history
  • Loading branch information
lengau committed Apr 2, 2024
1 parent 3b97045 commit c4bed49
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions snapcraft/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
)

SNAPCRAFT_BASE_TO_PROVIDER_BASE = {
"core": bases.BuilddBaseAlias.XENIAL,
"core18": bases.BuilddBaseAlias.BIONIC,
"core20": bases.BuilddBaseAlias.FOCAL,
"core22": bases.BuilddBaseAlias.JAMMY,
Expand Down
3 changes: 2 additions & 1 deletion snapcraft/remote/launchpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import gzip
import logging
import os
import shutil
import time
from datetime import datetime, timedelta, timezone
Expand Down Expand Up @@ -266,7 +267,7 @@ def _login(self) -> Launchpad:
try:
return Launchpad.login_with(
f"{self._app_name} remote-build",
"production",
os.getenv("CRAFT_LAUNCHPAD_INSTANCE", "production"),
self._cache_dir,
credentials_file=str(self._credentials),
version="devel",
Expand Down
1 change: 1 addition & 0 deletions snapcraft_legacy/cli/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def remote_build(
snapcraft remote-build --status
snapcraft remote-build --status --build-id snapcraft-my-snap-b98a6bd3
"""
echo.warning("legacy")
project = get_project()

if build_for:
Expand Down
7 changes: 4 additions & 3 deletions snapcraft_legacy/internal/remote_build/_launchpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def login(self) -> Launchpad:
try:
return Launchpad.login_with(
"snapcraft remote-build {}".format(snapcraft_legacy.__version__),
"production",
os.getenv("CRAFT_LAUNCHPAD_INSTANCE", "production"),
self._cache_dir,
credentials_file=self._credentials,
version="devel",
Expand All @@ -266,10 +266,11 @@ def get_git_repo_path(self) -> str:
return f"~{self._lp_user}/+git/{self._lp_name}"

def get_git_https_url(self, token: Optional[str] = None) -> str:
lp_domain = self._lp._root_uri.host[4:]
if token:
return f"https://{self._lp_user}:{token}@git.launchpad.net/~{self._lp_user}/+git/{self._lp_name}/"
return f"https://{self._lp_user}:{token}@git.{lp_domain}/~{self._lp_user}/+git/{self._lp_name}/"
else:
return f"https://{self._lp_user}@git.launchpad.net/~{self._lp_user}/+git/{self._lp_name}/"
return f"https://{self._lp_user}@git.{lp_domain}/~{self._lp_user}/+git/{self._lp_name}/"

def _create_git_repository(self, force=False) -> Entry:
"""Create git repository."""
Expand Down

0 comments on commit c4bed49

Please sign in to comment.