diff --git a/src/cmlxc/container.py b/src/cmlxc/container.py index a5817e7..9301d18 100644 --- a/src/cmlxc/container.py +++ b/src/cmlxc/container.py @@ -538,7 +538,7 @@ def setup_repo(self, dest, out, source): name = dest.rsplit("/", 1)[-1] self.bash(f"rm -rf {dest}") out.print(f" Initial clone of {name} ...") - self.bash(f"git clone {source.url} {dest}") + self.bash(f"git clone --branch {source.ref} {source.url} {dest}") def get_repo_status(self, repo_path): """Return a one-line string describing the git repo at repo_path.""" diff --git a/src/cmlxc/driver_base.py b/src/cmlxc/driver_base.py index 914fb29..c6f7ea2 100644 --- a/src/cmlxc/driver_base.py +++ b/src/cmlxc/driver_base.py @@ -89,6 +89,7 @@ class Driver: DEFAULT_SOURCE_URL: str REPO_NAME: str REQUIRED_SOURCE_PATHS: list[str] = [] + DEFAULT_REF: str = "main" type: str = "dns" def __init__(self, ct, out): @@ -143,9 +144,9 @@ def add_cli_options(cls, parser, completer=None): """Register ``deploy-*`` CLI options on *parser*.""" parser.add_argument( "--source", - default="@main", + default=f"@{cls.DEFAULT_REF}", metavar="SOURCE", - help="Driver source: @ref, /path, ./path, or URL@ref (default: @main).", + help=f"Driver source: @ref, /path, ./path, or URL@ref (default: @{cls.DEFAULT_REF}).", ) action = parser.add_argument( "name", @@ -220,7 +221,7 @@ def prep_builder(cls, ix, out, bld_ct): tmp_dest = f"/root/{cls.REPO_NAME}-git-main" if bld_ct.bash(f"test -d {tmp_dest}", check=False) is None: - source = parse_source("@main", cls.DEFAULT_SOURCE_URL) + source = parse_source(f"@{cls.DEFAULT_REF}", cls.DEFAULT_SOURCE_URL) bld_ct.setup_repo(tmp_dest, out, source) else: out.print(f" Fetching {cls.REPO_NAME}-git-main from upstream ...") diff --git a/src/cmlxc/driver_madmail.py b/src/cmlxc/driver_madmail.py index e46f76b..6327f5b 100644 --- a/src/cmlxc/driver_madmail.py +++ b/src/cmlxc/driver_madmail.py @@ -22,6 +22,7 @@ class MadmailDriver(Driver): DEFAULT_SOURCE_URL = "https://github.com/themadorg/madmail.git" REPO_NAME = MADMAIL REQUIRED_SOURCE_PATHS = ["go.mod", "Makefile"] + DEFAULT_REF = "v0.47.1" type = "ipv4" @classmethod diff --git a/tests/fullrun.py b/tests/fullrun.py index 62e4116..9a4f6c6 100644 --- a/tests/fullrun.py +++ b/tests/fullrun.py @@ -126,7 +126,7 @@ def test_cm_ipv4_test(): def test_mad_deploy(): - cmlxc("deploy-madmail", "--source", "@main", CT_MAD) + cmlxc("deploy-madmail", CT_MAD) def test_mad_deploy_type():