mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-20 08:37:59 +02:00
fix(cli): preflight Docker for --push-to builds and keep the push token out of verbose output
This commit is contained in:
@@ -1117,7 +1117,7 @@ def _run_local_build(
|
||||
"--password-stdin",
|
||||
registry_host,
|
||||
input=token_input,
|
||||
verbose=verbose,
|
||||
verbose=False,
|
||||
)
|
||||
)
|
||||
step += 1
|
||||
@@ -1440,12 +1440,19 @@ class CustomerRegistrySource:
|
||||
raise
|
||||
|
||||
|
||||
def _require_local_docker() -> None:
|
||||
supported, error = can_build_locally()
|
||||
if not supported:
|
||||
raise click.UsageError(error or "Unable to build locally.")
|
||||
|
||||
|
||||
def _push_reference(push_to: str, tag: str | None) -> ImageReference:
|
||||
if "@" in push_to:
|
||||
try:
|
||||
reference = ImageReference.parse(push_to)
|
||||
except ValueError:
|
||||
raise click.UsageError(
|
||||
"--push-to takes a repository with an optional tag, not a digest."
|
||||
)
|
||||
reference = ImageReference.parse(push_to)
|
||||
) from None
|
||||
if reference.tag is not None and tag is not None:
|
||||
raise click.UsageError(
|
||||
"--push-to already includes a tag; do not combine it with --tag."
|
||||
@@ -1466,9 +1473,10 @@ def _select_source(
|
||||
if push_to is not None:
|
||||
if remote_build_flag is True:
|
||||
raise click.UsageError("--push-to cannot be combined with --remote.")
|
||||
return CustomerRegistrySource(
|
||||
_push_reference(push_to, tag), prebuilt_image=image
|
||||
)
|
||||
reference = _push_reference(push_to, tag)
|
||||
if image is None:
|
||||
_require_local_docker()
|
||||
return CustomerRegistrySource(reference, prebuilt_image=image)
|
||||
if image and remote_build_flag is True:
|
||||
raise click.UsageError("--image cannot be combined with --remote builds.")
|
||||
use_remote_build, local_build_error = _resolve_build_mode(
|
||||
|
||||
@@ -62,7 +62,7 @@ def _is_cloud_host(hostname: str) -> bool:
|
||||
|
||||
|
||||
def _cloud_control_plane_host_for(langsmith_api_host: str) -> str:
|
||||
if langsmith_api_host.endswith(CLOUD_API_HOST):
|
||||
if langsmith_api_host.endswith(f".{CLOUD_API_HOST}"):
|
||||
region = langsmith_api_host[: -len(CLOUD_API_HOST)]
|
||||
return f"{region}{CLOUD_CONTROL_PLANE_HOST}"
|
||||
return CLOUD_CONTROL_PLANE_HOST
|
||||
|
||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass, replace
|
||||
|
||||
DIGEST_SEPARATOR = "@sha256:"
|
||||
DIGEST_MARKER = "@"
|
||||
TAG_SEPARATOR = ":"
|
||||
PATH_SEPARATOR = "/"
|
||||
|
||||
@@ -14,6 +15,8 @@ class ImageReference:
|
||||
|
||||
@classmethod
|
||||
def parse(cls, reference: str) -> ImageReference:
|
||||
if DIGEST_MARKER in reference:
|
||||
raise ValueError(f"{reference!r} carries a digest and cannot be tagged")
|
||||
path_start = reference.rfind(PATH_SEPARATOR) + 1
|
||||
name, separator, tag = reference[path_start:].partition(TAG_SEPARATOR)
|
||||
if not separator:
|
||||
|
||||
Reference in New Issue
Block a user