Skip to content

Commit bdb6a23

Browse files
committed
refactor: clean up image tag resolution — no legacy workarounds
- Read LPB_IMAGE_TAG env var at module level, set as default for cfg.image_tag - Remove _resolve_image_tag() function - Replace all cfg.image_tag or _resolve_image_tag() with just cfg.image_tag - Clean separation: env var → default, --tag → override
1 parent 967869f commit bdb6a23

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

scripts/lpb.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ def _load_stack_env() -> dict[str, str]:
134134
CLI_IMAGE = _stack_cfg.get("LPB_IMAGE_CLI", "ghcr.io/localpibox/devstack:cli")
135135
WEB_IMAGE = _stack_cfg.get("LPB_IMAGE_WEB", "ghcr.io/localpibox/devstack:web")
136136

137+
# ─── Default image tag from env var ──────────────────────────────────
138+
# Users can set LPB_IMAGE_TAG=dev in their environment for persistent override.
139+
cfg_image_tag = os.environ.get("LPB_IMAGE_TAG", "")
140+
137141

138142
# ─── Version resolution (dev/main pipeline) ───────────────────────────
139143
# The image is built with version tags (e.g. 0.0.9-lpb-dev-cli).
@@ -166,11 +170,6 @@ def _resolve_version_image(version: str, mode: str) -> str:
166170
return f"ghcr.io/localpibox/devstack:{version}-{mode}"
167171

168172

169-
def _resolve_image_tag() -> str:
170-
"""Return the image tag suffix from env var (legacy compatibility)."""
171-
return os.environ.get("LPB_IMAGE_TAG", "")
172-
173-
174173
def resolve_cli_image(tag: str) -> str:
175174
"""Resolve the final CLI image name from stack config + tag override.
176175
@@ -228,7 +227,7 @@ def _load_conf_env() -> dict[str, str]:
228227

229228
class Config:
230229
image_name = CLI_IMAGE
231-
image_tag = "" # dev, main, latest, or custom tag suffix
230+
image_tag = cfg_image_tag # dev, main, latest, or custom tag suffix
232231
container_name = _stack_cfg.get("LPB_CONTAINER_NAME", "localpibox")
233232
container_cmd = ""
234233
port = int(os.environ.get("ED_PORT", os.environ.get("LPB_ED_PORT", _conf_cfg.get("LPB_ED_PORT", "8000"))))
@@ -879,7 +878,7 @@ def cmd_update():
879878
self_update()
880879

881880
# Resolve current tag
882-
tag = cfg.image_tag or _resolve_image_tag()
881+
tag = cfg.image_tag
883882
cli_img = resolve_cli_image(tag)
884883
web_img = resolve_web_image(tag)
885884

@@ -1022,7 +1021,7 @@ def cmd_run():
10221021
mount_path = f"/home/lpb/workspace/{cfg.project_name}"
10231022

10241023
# ── 4. Determine image and mode ──────────────────────────────────────
1025-
tag = cfg.image_tag or _resolve_image_tag()
1024+
tag = cfg.image_tag
10261025
if cfg.web_mode:
10271026
cfg.image_name = resolve_web_image(tag)
10281027
mode_label = "web (VSCodium)"

0 commit comments

Comments
 (0)