Skip to content

Commit

Permalink
kamal -> .kamal
Browse files Browse the repository at this point in the history
  • Loading branch information
djmb committed Aug 28, 2023
1 parent bcfa1d8 commit 787688e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/kamal/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def abbreviated_version
end

def run_directory
raw_config.run_directory || "kamal"
raw_config.run_directory || ".kamal"
end


Expand Down
6 changes: 3 additions & 3 deletions test/cli/cli_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def fail_hook(hook)

def stub_setup
SSHKit::Backend::Abstract.any_instance.stubs(:execute)
.with { |*args| args == [ :mkdir, "-p", "kamal" ] }
.with { |*args| args == [ :mkdir, "-p", ".kamal" ] }
SSHKit::Backend::Abstract.any_instance.stubs(:execute)
.with { |arg1, arg2| arg1 == :mkdir && arg2 == "kamal/lock-app" }
.with { |arg1, arg2| arg1 == :mkdir && arg2 == ".kamal/lock-app" }
SSHKit::Backend::Abstract.any_instance.stubs(:execute)
.with { |arg1, arg2| arg1 == :rm && arg2 == "kamal/lock-app/details" }
.with { |arg1, arg2| arg1 == :rm && arg2 == ".kamal/lock-app/details" }
end

def assert_hook_ran(hook, output, version:, service_version:, hosts:, command:, subcommand: nil, runtime: nil)
Expand Down
12 changes: 6 additions & 6 deletions test/cli/main_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ class CliMainTest < CliTestCase
Thread.report_on_exception = false

SSHKit::Backend::Abstract.any_instance.stubs(:execute)
.with { |*args| args == [ :mkdir, "-p", "kamal" ] }
.with { |*args| args == [ :mkdir, "-p", ".kamal" ] }

SSHKit::Backend::Abstract.any_instance.stubs(:execute)
.with { |*arg| arg[0..1] == [:mkdir, 'kamal/lock-app'] }
.with { |*arg| arg[0..1] == [:mkdir, ".kamal/lock-app"] }
.raises(RuntimeError, "mkdir: cannot create directory ‘kamal_lock-app’: File exists")

SSHKit::Backend::Abstract.any_instance.expects(:capture_with_debug)
.with(:stat, 'kamal/lock-app', ">", "/dev/null", "&&", :cat, "kamal/lock-app/details", "|", :base64, "-d")
.with(:stat, ".kamal/lock-app", ">", "/dev/null", "&&", :cat, ".kamal/lock-app/details", "|", :base64, "-d")

assert_raises(Kamal::Cli::LockError) do
run_command("deploy")
Expand All @@ -81,10 +81,10 @@ class CliMainTest < CliTestCase
Thread.report_on_exception = false

SSHKit::Backend::Abstract.any_instance.stubs(:execute)
.with { |*args| args == [ :mkdir, "-p", "kamal" ] }
.with { |*args| args == [ :mkdir, "-p", ".kamal" ] }

SSHKit::Backend::Abstract.any_instance.stubs(:execute)
.with { |*arg| arg[0..1] == [:mkdir, 'kamal/lock-app'] }
.with { |*arg| arg[0..1] == [:mkdir, ".kamal/lock-app"] }
.raises(SocketError, "getaddrinfo: nodename nor servname provided, or not known")

assert_raises(SSHKit::Runner::ExecuteError) do
Expand Down Expand Up @@ -236,7 +236,7 @@ class CliMainTest < CliTestCase

test "audit" do
run_command("audit").tap do |output|
assert_match %r{tail -n 50 kamal/app-audit.log on 1.1.1.1}, output
assert_match %r{tail -n 50 \.kamal/app-audit.log on 1.1.1.1}, output
assert_match /App Host: 1.1.1.1/, output
end
end
Expand Down
6 changes: 3 additions & 3 deletions test/cli/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
class CliServerTest < CliTestCase
test "bootstrap already installed" do
SSHKit::Backend::Abstract.any_instance.expects(:execute).with(:docker, "-v", raise_on_non_zero_exit: false).returns(true).at_least_once
SSHKit::Backend::Abstract.any_instance.expects(:execute).with(:mkdir, "-p", "kamal").returns("").at_least_once
SSHKit::Backend::Abstract.any_instance.expects(:execute).with(:mkdir, "-p", ".kamal").returns("").at_least_once

assert_equal "", run_command("bootstrap")
end

test "bootstrap install as non-root user" do
SSHKit::Backend::Abstract.any_instance.expects(:execute).with(:docker, "-v", raise_on_non_zero_exit: false).returns(false).at_least_once
SSHKit::Backend::Abstract.any_instance.expects(:execute).with('[ "${EUID:-$(id -u)}" -eq 0 ]', raise_on_non_zero_exit: false).returns(false).at_least_once
SSHKit::Backend::Abstract.any_instance.expects(:execute).with(:mkdir, "-p", "kamal").returns("").at_least_once
SSHKit::Backend::Abstract.any_instance.expects(:execute).with(:mkdir, "-p", ".kamal").returns("").at_least_once

assert_raise RuntimeError, "Docker is not installed on 1.1.1.1, 1.1.1.3, 1.1.1.4, 1.1.1.2 and can't be automatically installed without having root access and the `curl` command available. Install Docker manually: https://docs.docker.com/engine/install/" do
run_command("bootstrap")
Expand All @@ -22,7 +22,7 @@ class CliServerTest < CliTestCase
SSHKit::Backend::Abstract.any_instance.expects(:execute).with(:docker, "-v", raise_on_non_zero_exit: false).returns(false).at_least_once
SSHKit::Backend::Abstract.any_instance.expects(:execute).with('[ "${EUID:-$(id -u)}" -eq 0 ]', raise_on_non_zero_exit: false).returns(true).at_least_once
SSHKit::Backend::Abstract.any_instance.expects(:execute).with(:curl, "-fsSL", "https://get.docker.com", "|", :sh).at_least_once
SSHKit::Backend::Abstract.any_instance.expects(:execute).with(:mkdir, "-p", "kamal").returns("").at_least_once
SSHKit::Backend::Abstract.any_instance.expects(:execute).with(:mkdir, "-p", ".kamal").returns("").at_least_once

run_command("bootstrap").tap do |output|
("1.1.1.1".."1.1.1.4").map do |host|
Expand Down
8 changes: 4 additions & 4 deletions test/commands/auditor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CommandsAuditorTest < ActiveSupport::TestCase
:echo,
"[#{@recorded_at}] [#{@performer}]",
"app removed container",
">>", "kamal/app-audit.log"
">>", ".kamal/app-audit.log"
], @auditor.record("app removed container")
end

Expand All @@ -31,7 +31,7 @@ class CommandsAuditorTest < ActiveSupport::TestCase
:echo,
"[#{@recorded_at}] [#{@performer}] [staging]",
"app removed container",
">>", "kamal/app-staging-audit.log"
">>", ".kamal/app-staging-audit.log"
], auditor.record("app removed container")
end
end
Expand All @@ -42,7 +42,7 @@ class CommandsAuditorTest < ActiveSupport::TestCase
:echo,
"[#{@recorded_at}] [#{@performer}] [web]",
"app removed container",
">>", "kamal/app-audit.log"
">>", ".kamal/app-audit.log"
], auditor.record("app removed container")
end
end
Expand All @@ -52,7 +52,7 @@ class CommandsAuditorTest < ActiveSupport::TestCase
:echo,
"[#{@recorded_at}] [#{@performer}] [value]",
"app removed container",
">>", "kamal/app-audit.log"
">>", ".kamal/app-audit.log"
], @auditor.record("app removed container", detail: "value")
end

Expand Down
6 changes: 3 additions & 3 deletions test/commands/lock_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ class CommandsLockTest < ActiveSupport::TestCase

test "status" do
assert_equal \
"stat kamal/lock-app > /dev/null && cat kamal/lock-app/details | base64 -d",
"stat .kamal/lock-app > /dev/null && cat .kamal/lock-app/details | base64 -d",
new_command.status.join(" ")
end

test "acquire" do
assert_match \
%r{mkdir kamal/lock-app && echo ".*" > kamal/lock-app/details}m,
%r{mkdir \.kamal/lock-app && echo ".*" > \.kamal/lock-app/details}m,
new_command.acquire("Hello", "123").join(" ")
end

test "release" do
assert_match \
"rm kamal/lock-app/details && rm -r kamal/lock-app",
"rm .kamal/lock-app/details && rm -r .kamal/lock-app",
new_command.release.join(" ")
end

Expand Down
2 changes: 1 addition & 1 deletion test/commands/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CommandsServerTest < ActiveSupport::TestCase
end

test "ensure run directory" do
assert_equal "mkdir -p kamal", new_command.ensure_run_directory.join(" ")
assert_equal "mkdir -p .kamal", new_command.ensure_run_directory.join(" ")
end

test "ensure non default run directory" do
Expand Down
2 changes: 1 addition & 1 deletion test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class ConfigurationTest < ActiveSupport::TestCase

test "run directory" do
config = Kamal::Configuration.new(@deploy)
assert_equal "kamal", config.run_directory
assert_equal ".kamal", config.run_directory

config = Kamal::Configuration.new(@deploy.merge!(run_directory: "/root/kamal"))
assert_equal "/root/kamal", config.run_directory
Expand Down

0 comments on commit 787688e

Please sign in to comment.