Check that we have valid contexts before building

Load the hosts from the contexts before trying to build.

If there is no context, we'll create one. If there is one but the hosts
don't match we'll re-create.

Where we just have a local context, there won't be any hosts but we
still inspect the builder to check that it exists.
This commit is contained in:
Donal McBreen
2024-06-05 11:52:45 +01:00
parent 6e60ab918a
commit b52e66814a
11 changed files with 122 additions and 16 deletions

View File

@@ -116,6 +116,10 @@ class CliMainTest < CliTestCase
.with(:git, "-C", anything, :status, "--porcelain")
.returns("")
SSHKit::Backend::Abstract.any_instance.expects(:capture_with_info)
.with(:docker, :buildx, :inspect, "kamal-app-multiarch", "> /dev/null")
.returns("")
assert_raises(Kamal::Cli::LockError) do
run_command("deploy")
end
@@ -145,6 +149,10 @@ class CliMainTest < CliTestCase
.with(:git, "-C", anything, :status, "--porcelain")
.returns("")
SSHKit::Backend::Abstract.any_instance.expects(:capture_with_info)
.with(:docker, :buildx, :inspect, "kamal-app-multiarch", "> /dev/null")
.returns("")
assert_raises(SSHKit::Runner::ExecuteError) do
run_command("deploy")
end