Check for docker locally before registry login

We were checking before `kamal build push`, but not `kamal registry login`.
Since `kamal registry login` is called first by a deploy we don't
get the nice error message.
This commit is contained in:
Donal McBreen
2025-01-17 14:58:27 +00:00
parent 0174b872bf
commit dc9a95db2c
8 changed files with 43 additions and 36 deletions

View File

@@ -155,7 +155,7 @@ class CliBuildTest < CliTestCase
.raises(SSHKit::Command::Failed.new("no buildx"))
Kamal::Commands::Builder.any_instance.stubs(:native_and_local?).returns(false)
assert_raises(Kamal::Cli::Build::BuildError) { run_command("push") }
assert_raises(Kamal::Cli::DependencyError) { run_command("push") }
end
test "push pre-build hook failure" do

View File

@@ -43,6 +43,16 @@ class CliRegistryTest < CliTestCase
end
end
test "login with no docker" do
stub_setup
SSHKit::Backend::Abstract.any_instance.stubs(:execute)
.with(:docker, "--version", "&&", :docker, :buildx, "version")
.raises(SSHKit::Command::Failed.new("command not found"))
assert_raises(Kamal::Cli::DependencyError) { run_command("login") }
end
private
def run_command(*command)
stdouted { Kamal::Cli::Registry.start([ *command, "-c", "test/fixtures/deploy_with_accessories.yml" ]) }