fix(cli): preflight Docker for --push-to builds and keep the push token out of verbose output

This commit is contained in:
Hugo Durand
2026-09-18 15:07:03 -04:00
parent 4c412e4c94
commit d590afbc3b
7 changed files with 63 additions and 11 deletions
@@ -514,8 +514,9 @@ def test_push_to_builds_pushes_then_creates_an_external_deployment(
def test_push_to_builds_directly_with_the_push_reference(
deploy_project: DeployProject,
) -> None:
deploy_project.run("--push-to", PUSH_REPOSITORY)
result = deploy_project.run("--push-to", PUSH_REPOSITORY)
assert result.exit_code == 0, result.output
assert deploy_project.docker.builds[0]["tag"] == EXTERNAL_IMAGE
assert deploy_project.docker.command("push").args == (
"docker",
@@ -525,11 +526,30 @@ def test_push_to_builds_directly_with_the_push_reference(
def test_push_to_composes_with_the_tag_flag(deploy_project: DeployProject) -> None:
deploy_project.run("--push-to", PUSH_REPOSITORY, "--tag", "v1")
result = deploy_project.run("--push-to", PUSH_REPOSITORY, "--tag", "v1")
assert result.exit_code == 0, result.output
assert deploy_project.docker.command("push").args[-1] == f"{PUSH_REPOSITORY}:v1"
def test_push_to_with_a_failing_push_creates_no_deployment(
deploy_project: DeployProject,
) -> None:
deploy_project.docker.failing_pushes = 3
result = deploy_project.run("--push-to", PUSH_REPOSITORY)
assert result.exit_code != 0
assert CREATE_DEPLOYMENT not in deploy_project.timeline
def test_verbose_never_echoes_the_push_token(deploy_project: DeployProject) -> None:
result = deploy_project.run("--no-remote", "--verbose")
assert result.exit_code == 0, result.output
assert deploy_project.docker.command("login").kwargs["verbose"] is False
def test_push_to_retags_a_prebuilt_image_instead_of_building(
deploy_project: DeployProject,
) -> None:
@@ -692,6 +692,14 @@ class TestSelectSource:
assert _select_source(**{**self.OPTIONS, **flags}) == expected
def test_push_to_build_requires_local_docker(self, monkeypatch):
monkeypatch.setattr(
deploy_mod, "can_build_locally", lambda: (False, "Docker is required")
)
with pytest.raises(click.UsageError, match="Docker is required"):
_select_source(**{**self.OPTIONS, "push_to": self.REPOSITORY})
@pytest.mark.parametrize(
("flags", "message"),
[
@@ -717,7 +725,9 @@ class TestSelectSource:
),
],
)
def test_conflicting_flags_are_rejected(self, flags, message):
def test_conflicting_flags_are_rejected(self, monkeypatch, flags, message):
monkeypatch.setattr(deploy_mod, "can_build_locally", lambda: (True, None))
with pytest.raises(click.UsageError, match=message):
_select_source(**{**self.OPTIONS, **flags})
@@ -493,6 +493,12 @@ CLOUD = ("https://api.host.langchain.com", "https://smith.langchain.com")
pytest.param(
None, "https://api.langchain.com", CLOUD, id="cloud_langchain_api_alias"
),
pytest.param(
None,
"https://xapi.smith.langchain.com",
CLOUD,
id="lookalike_cloud_host_is_not_rewritten_into_a_control_plane",
),
pytest.param(
None,
"https://eu.api.smith.langchain.com",
@@ -64,3 +64,8 @@ def test_matches_digest_only_for_the_same_repository(repo_digest, expected):
assert ImageReference("localhost:5000/app", "v1").matches_digest(repo_digest) is (
expected
)
def test_parse_rejects_a_digest_reference():
with pytest.raises(ValueError, match="digest"):
ImageReference.parse("registry.example.com/app@sha256:abc")