Require an arch to be set, and default to amd64 in the template
This commit is contained in:
@@ -8,6 +8,7 @@ class ConfigurationAccessoryTest < ActiveSupport::TestCase
|
||||
"web" => [ "1.1.1.1", "1.1.1.2" ],
|
||||
"workers" => [ "1.1.1.3", "1.1.1.4" ]
|
||||
},
|
||||
builder: { "arch" => "amd64" },
|
||||
env: { "REDIS_URL" => "redis://x/y" },
|
||||
accessories: {
|
||||
"mysql" => {
|
||||
|
||||
@@ -4,13 +4,7 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@deploy = {
|
||||
service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" },
|
||||
servers: [ "1.1.1.1" ]
|
||||
}
|
||||
|
||||
@deploy_with_builder_option = {
|
||||
service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" },
|
||||
servers: [ "1.1.1.1" ],
|
||||
builder: {}
|
||||
builder: { "arch" => "amd64" }, servers: [ "1.1.1.1" ]
|
||||
}
|
||||
end
|
||||
|
||||
@@ -27,16 +21,16 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "setting both local and remote configs" do
|
||||
@deploy_with_builder_option[:builder] = {
|
||||
@deploy[:builder] = {
|
||||
"arch" => [ "amd64", "arm64" ],
|
||||
"remote" => "ssh://root@192.168.0.1"
|
||||
}
|
||||
|
||||
assert_equal true, config_with_builder_option.builder.local?
|
||||
assert_equal true, config_with_builder_option.builder.remote?
|
||||
assert_equal true, config.builder.local?
|
||||
assert_equal true, config.builder.remote?
|
||||
|
||||
assert_equal [ "amd64", "arm64" ], config_with_builder_option.builder.arches
|
||||
assert_equal "ssh://root@192.168.0.1", config_with_builder_option.builder.remote
|
||||
assert_equal [ "amd64", "arm64" ], config.builder.arches
|
||||
assert_equal "ssh://root@192.168.0.1", config.builder.remote
|
||||
end
|
||||
|
||||
test "cached?" do
|
||||
@@ -44,10 +38,10 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "invalid cache type specified" do
|
||||
@deploy_with_builder_option[:builder] = { "cache" => { "type" => "invalid" } }
|
||||
@deploy[:builder]["cache"] = { "type" => "invalid" }
|
||||
|
||||
assert_raises(Kamal::ConfigurationError) do
|
||||
config_with_builder_option.builder
|
||||
config.builder
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,32 +54,32 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "setting gha cache" do
|
||||
@deploy_with_builder_option[:builder] = { "cache" => { "type" => "gha", "options" => "mode=max" } }
|
||||
@deploy[:builder] = { "arch" => "amd64", "cache" => { "type" => "gha", "options" => "mode=max" } }
|
||||
|
||||
assert_equal "type=gha", config_with_builder_option.builder.cache_from
|
||||
assert_equal "type=gha,mode=max", config_with_builder_option.builder.cache_to
|
||||
assert_equal "type=gha", config.builder.cache_from
|
||||
assert_equal "type=gha,mode=max", config.builder.cache_to
|
||||
end
|
||||
|
||||
test "setting registry cache" do
|
||||
@deploy_with_builder_option[:builder] = { "cache" => { "type" => "registry", "options" => "mode=max,image-manifest=true,oci-mediatypes=true" } }
|
||||
@deploy[:builder] = { "arch" => "amd64", "cache" => { "type" => "registry", "options" => "mode=max,image-manifest=true,oci-mediatypes=true" } }
|
||||
|
||||
assert_equal "type=registry,ref=dhh/app-build-cache", config_with_builder_option.builder.cache_from
|
||||
assert_equal "type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=dhh/app-build-cache", config_with_builder_option.builder.cache_to
|
||||
assert_equal "type=registry,ref=dhh/app-build-cache", config.builder.cache_from
|
||||
assert_equal "type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=dhh/app-build-cache", config.builder.cache_to
|
||||
end
|
||||
|
||||
test "setting registry cache when using a custom registry" do
|
||||
@deploy_with_builder_option[:registry]["server"] = "registry.example.com"
|
||||
@deploy_with_builder_option[:builder] = { "cache" => { "type" => "registry", "options" => "mode=max,image-manifest=true,oci-mediatypes=true" } }
|
||||
@deploy[:registry]["server"] = "registry.example.com"
|
||||
@deploy[:builder] = { "arch" => "amd64", "cache" => { "type" => "registry", "options" => "mode=max,image-manifest=true,oci-mediatypes=true" } }
|
||||
|
||||
assert_equal "type=registry,ref=registry.example.com/dhh/app-build-cache", config_with_builder_option.builder.cache_from
|
||||
assert_equal "type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=registry.example.com/dhh/app-build-cache", config_with_builder_option.builder.cache_to
|
||||
assert_equal "type=registry,ref=registry.example.com/dhh/app-build-cache", config.builder.cache_from
|
||||
assert_equal "type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=registry.example.com/dhh/app-build-cache", config.builder.cache_to
|
||||
end
|
||||
|
||||
test "setting registry cache with image" do
|
||||
@deploy_with_builder_option[:builder] = { "cache" => { "type" => "registry", "image" => "kamal", "options" => "mode=max" } }
|
||||
@deploy[:builder] = { "arch" => "amd64", "cache" => { "type" => "registry", "image" => "kamal", "options" => "mode=max" } }
|
||||
|
||||
assert_equal "type=registry,ref=kamal", config_with_builder_option.builder.cache_from
|
||||
assert_equal "type=registry,mode=max,ref=kamal", config_with_builder_option.builder.cache_to
|
||||
assert_equal "type=registry,ref=kamal", config.builder.cache_from
|
||||
assert_equal "type=registry,mode=max,ref=kamal", config.builder.cache_to
|
||||
end
|
||||
|
||||
test "args" do
|
||||
@@ -93,9 +87,9 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "setting args" do
|
||||
@deploy_with_builder_option[:builder] = { "args" => { "key" => "value" } }
|
||||
@deploy[:builder]["args"] = { "key" => "value" }
|
||||
|
||||
assert_equal({ "key" => "value" }, config_with_builder_option.builder.args)
|
||||
assert_equal({ "key" => "value" }, config.builder.args)
|
||||
end
|
||||
|
||||
test "secrets" do
|
||||
@@ -103,9 +97,9 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "setting secrets" do
|
||||
@deploy_with_builder_option[:builder] = { "secrets" => [ "GITHUB_TOKEN" ] }
|
||||
@deploy[:builder]["secrets"] = [ "GITHUB_TOKEN" ]
|
||||
|
||||
assert_equal [ "GITHUB_TOKEN" ], config_with_builder_option.builder.secrets
|
||||
assert_equal [ "GITHUB_TOKEN" ], config.builder.secrets
|
||||
end
|
||||
|
||||
test "dockerfile" do
|
||||
@@ -113,9 +107,9 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "setting dockerfile" do
|
||||
@deploy_with_builder_option[:builder] = { "dockerfile" => "Dockerfile.dev" }
|
||||
@deploy[:builder]["dockerfile"] = "Dockerfile.dev"
|
||||
|
||||
assert_equal "Dockerfile.dev", config_with_builder_option.builder.dockerfile
|
||||
assert_equal "Dockerfile.dev", config.builder.dockerfile
|
||||
end
|
||||
|
||||
test "context" do
|
||||
@@ -123,9 +117,9 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "setting context" do
|
||||
@deploy_with_builder_option[:builder] = { "context" => ".." }
|
||||
@deploy[:builder]["context"] = ".."
|
||||
|
||||
assert_equal "..", config_with_builder_option.builder.context
|
||||
assert_equal "..", config.builder.context
|
||||
end
|
||||
|
||||
test "ssh" do
|
||||
@@ -133,17 +127,13 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "setting ssh params" do
|
||||
@deploy_with_builder_option[:builder] = { "ssh" => "default=$SSH_AUTH_SOCK" }
|
||||
@deploy[:builder]["ssh"] = "default=$SSH_AUTH_SOCK"
|
||||
|
||||
assert_equal "default=$SSH_AUTH_SOCK", config_with_builder_option.builder.ssh
|
||||
assert_equal "default=$SSH_AUTH_SOCK", config.builder.ssh
|
||||
end
|
||||
|
||||
private
|
||||
def config
|
||||
Kamal::Configuration.new(@deploy)
|
||||
end
|
||||
|
||||
def config_with_builder_option
|
||||
Kamal::Configuration.new(@deploy_with_builder_option)
|
||||
end
|
||||
end
|
||||
|
||||
4
test/configuration/env/tags_test.rb
vendored
4
test/configuration/env/tags_test.rb
vendored
@@ -5,6 +5,7 @@ class ConfigurationEnvTagsTest < ActiveSupport::TestCase
|
||||
@deploy = {
|
||||
service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" },
|
||||
servers: [ { "1.1.1.1" => "odd" }, { "1.1.1.2" => "even" }, { "1.1.1.3" => [ "odd", "three" ] } ],
|
||||
builder: { "arch" => "amd64" },
|
||||
env: {
|
||||
"clear" => { "REDIS_URL" => "redis://x/y", "THREE" => "false" },
|
||||
"tags" => {
|
||||
@@ -64,6 +65,7 @@ class ConfigurationEnvTagsTest < ActiveSupport::TestCase
|
||||
deploy = {
|
||||
service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" },
|
||||
servers: [ { "1.1.1.1" => [ "first", "second" ] } ],
|
||||
builder: { "arch" => "amd64" },
|
||||
env: {
|
||||
"tags" => {
|
||||
"first" => { "TYPE" => "first" },
|
||||
@@ -82,6 +84,7 @@ class ConfigurationEnvTagsTest < ActiveSupport::TestCase
|
||||
deploy = {
|
||||
service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" },
|
||||
servers: [ { "1.1.1.1" => "secrets" } ],
|
||||
builder: { "arch" => "amd64" },
|
||||
env: {
|
||||
"tags" => {
|
||||
"secrets" => { "secret" => [ "PASSWORD" ] }
|
||||
@@ -99,6 +102,7 @@ class ConfigurationEnvTagsTest < ActiveSupport::TestCase
|
||||
deploy = {
|
||||
service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" },
|
||||
servers: [ { "1.1.1.1" => "clearly" } ],
|
||||
builder: { "arch" => "amd64" },
|
||||
env: {
|
||||
"tags" => {
|
||||
"clearly" => { "clear" => { "FOO" => "bar" } }
|
||||
|
||||
@@ -5,6 +5,7 @@ class ConfigurationRoleTest < ActiveSupport::TestCase
|
||||
@deploy = {
|
||||
service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" },
|
||||
servers: [ "1.1.1.1", "1.1.1.2" ],
|
||||
builder: { "arch" => "amd64" },
|
||||
env: { "REDIS_URL" => "redis://x/y" }
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ class ConfigurationSshTest < ActiveSupport::TestCase
|
||||
@deploy = {
|
||||
service: "app", image: "dhh/app",
|
||||
registry: { "username" => "dhh", "password" => "secret" },
|
||||
builder: { "arch" => "amd64" },
|
||||
env: { "REDIS_URL" => "redis://x/y" },
|
||||
servers: [ "1.1.1.1", "1.1.1.2" ],
|
||||
volumes: [ "/local/path:/container/path" ]
|
||||
|
||||
@@ -6,6 +6,7 @@ class ConfigurationSshkitTest < ActiveSupport::TestCase
|
||||
service: "app", image: "dhh/app",
|
||||
registry: { "username" => "dhh", "password" => "secret" },
|
||||
env: { "REDIS_URL" => "redis://x/y" },
|
||||
builder: { "arch" => "amd64" },
|
||||
servers: [ "1.1.1.1", "1.1.1.2" ],
|
||||
volumes: [ "/local/path:/container/path" ]
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ class ConfigurationValidationTest < ActiveSupport::TestCase
|
||||
valid_config = {
|
||||
service: "app",
|
||||
image: "app",
|
||||
builder: { "arch" => "amd64" },
|
||||
registry: { "username" => "user", "password" => "secret" },
|
||||
servers: [ "1.1.1.1" ]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user