Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/kamal/cli/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def details
def exec(*cmd)
cmd = Kamal::Utils.join_commands(cmd)
env = options[:env]
unless options[:reuse]
say "Log into image registry...", :magenta
invoke "kamal:cli:registry:login", [], {skip_local: true}
end
case
when options[:interactive] && options[:reuse]
say "Get current version of running container...", :magenta unless options[:version]
Expand Down
11 changes: 11 additions & 0 deletions test/cli/app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,17 @@ class CliAppTest < CliTestCase
end
end

test "exec logs into the container registry remotely for new containers" do
run_command("exec", "ruby -v").tap do |output|
assert_no_match /docker login -u \[REDACTED\] -p \[REDACTED\] as .*@localhost/, output
assert_match /docker login -u \[REDACTED\] -p \[REDACTED\] on 1.1.1.\d/, output
end
# Login is never required if reuse
run_command("exec", "-i", "--reuse", "ruby -v").tap do |output|
assert_no_match /docker login -u \[REDACTED\] -p \[REDACTED\] on 1.1.1.\d/, output
end
end

test "containers" do
run_command("containers").tap do |output|
assert_match "docker container ls --all --filter label=service=app", output
Expand Down