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

experimental: allow choosing a lp instance #4711

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
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
16 changes: 6 additions & 10 deletions 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 All @@ -280,16 +281,11 @@ def get_git_repo_path(self) -> str:

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

return (
f"https://{self._lp_user}@git.launchpad.net/"
f"~{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.{lp_domain}/~{self._lp_user}/+git/{self._lp_name}/"

def _create_git_repository(self, force=False) -> Entry:
"""Create git repository."""
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
Loading