Skip to content

Commit 00da667

Browse files
committed
add more options to dev build
1 parent 79715ae commit 00da667

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v4.5.0
44
hooks:
55
- id: check-added-large-files
66
- id: check-yaml

src/epics_containers_cli/dev/dev_cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ def build(
213213
cache_from: Optional[str] = typer.Option(None, help="buildx cache from folder"),
214214
push: bool = typer.Option(False, help="buildx push to registry"),
215215
rebuild: bool = typer.Option(True, help="rebuild the image even if it exists"),
216+
target: Optional[str] = typer.Option(
217+
None, help="target to build (default: developer and runtime)"
218+
),
219+
suffix: Optional[str] = typer.Option(None, help="suffix for image"),
216220
):
217221
"""
218222
Build a generic IOC container locally from a container project.
@@ -229,4 +233,6 @@ def build(
229233
cache_to=cache_to,
230234
push=push,
231235
rebuild=rebuild,
236+
target=target,
237+
suffix=suffix,
232238
)

src/epics_containers_cli/dev/dev_commands.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ def build(
190190
cache_to: Optional[str],
191191
push: bool,
192192
rebuild: bool,
193+
target: Optional[str],
194+
suffix: Optional[str],
193195
):
194196
"""
195197
build a local image from a Dockerfile
@@ -198,7 +200,7 @@ def build(
198200
args = f"--platform {platform} {'--no-cache' if not cache else ''}"
199201

200202
for target in Targets:
201-
image = get_image_name(repo, arch, target)
203+
image = get_image_name(repo, arch, target, suffix)
202204
image_name = f"{image}:{tag}"
203205

204206
if not rebuild:

src/epics_containers_cli/git.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import re
77
from pathlib import Path
8-
from typing import Tuple
8+
from typing import Optional, Tuple
99

1010
import typer
1111

@@ -19,11 +19,17 @@
1919

2020

2121
def get_image_name(
22-
repo: str, arch: Architecture = Architecture.linux, target: str = "developer"
22+
repo: str,
23+
arch: Architecture = Architecture.linux,
24+
target: str = "developer",
25+
suffix: Optional[str] = None,
2326
) -> str:
27+
if suffix is None:
28+
suffix = "-{arch}-{target}"
2429
registry = repo2registry(repo).lower().removesuffix(".git")
30+
img_suffix = suffix.format(repo=repo, arch=arch, target=target, registry=registry)
2531

26-
image = f"{registry}-{arch}-{target}"
32+
image = f"{registry}{img_suffix}"
2733
log.info("repo = %s image = %s", repo, image)
2834
return image
2935

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class MockRun:
3838
cmd = "cmd"
3939
rsp = "rsp"
4040

41-
def __init__(self):
42-
self.cmd_rsp = {}
41+
def __init__(self) -> None:
42+
self.cmd_rsp: List[Dict] = []
4343
self._runner = CliRunner()
4444
self.log: str = ""
4545
self.params: List[str] = []

0 commit comments

Comments
 (0)