Skip to content

Commit

Permalink
Merge pull request #1401 from basecamp/avoid-docker-check-with-skippi…
Browse files Browse the repository at this point in the history
…ng-local

Only check for docker when logging in locally
  • Loading branch information
djmb authored Feb 6, 2025
2 parents 45197e4 + fdf7e69 commit 3c2163a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/kamal/cli/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Kamal::Cli::Registry < Kamal::Cli::Base
option :skip_local, aliases: "-L", type: :boolean, default: false, desc: "Skip local login"
option :skip_remote, aliases: "-R", type: :boolean, default: false, desc: "Skip remote login"
def login
ensure_docker_installed
ensure_docker_installed unless options[:skip_local]

run_locally { execute *KAMAL.registry.login } unless options[:skip_local]
on(KAMAL.hosts) { execute *KAMAL.registry.login } unless options[:skip_remote]
Expand Down
12 changes: 12 additions & 0 deletions test/cli/registry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ class CliRegistryTest < CliTestCase
assert_raises(Kamal::Cli::DependencyError) { run_command("login") }
end

test "allow remote 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"))

SSHKit::Backend::Abstract.any_instance.stubs(:execute)
.with { |*args| args[0..1] == [ :docker, :login ] }

assert_nothing_raised { run_command("login", "--skip-local") }
end


private
def run_command(*command)
Expand Down

0 comments on commit 3c2163a

Please sign in to comment.