Skip to content

Commit

Permalink
builder/cache/options: fix order of build args when using registry
Browse files Browse the repository at this point in the history
  • Loading branch information
admtnnr committed Oct 1, 2024
1 parent 3ec4ad2 commit 256933f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/kamal/configuration/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def cache_to_config_for_gha
end

def cache_to_config_for_registry
[ "type=registry", builder_config["cache"]&.fetch("options", nil), "ref=#{cache_image_ref}" ].compact.join(",")
[ "type=registry", "ref=#{cache_image_ref}", builder_config["cache"]&.fetch("options", nil) ].compact.join(",")
end

def repo_basename
Expand Down
6 changes: 3 additions & 3 deletions test/configuration/builder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,22 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase
@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.builder.cache_from
assert_equal "type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=dhh/app-build-cache", config.builder.cache_to
assert_equal "type=registry,ref=dhh/app-build-cache,mode=max,image-manifest=true,oci-mediatypes=true", config.builder.cache_to
end

test "setting registry cache when using a custom registry" do
@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.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
assert_equal "type=registry,ref=registry.example.com/dhh/app-build-cache,mode=max,image-manifest=true,oci-mediatypes=true", config.builder.cache_to
end

test "setting registry cache with image" do
@deploy[:builder] = { "arch" => "amd64", "cache" => { "type" => "registry", "image" => "kamal", "options" => "mode=max" } }

assert_equal "type=registry,ref=kamal", config.builder.cache_from
assert_equal "type=registry,mode=max,ref=kamal", config.builder.cache_to
assert_equal "type=registry,ref=kamal,mode=max", config.builder.cache_to
end

test "args" do
Expand Down

0 comments on commit 256933f

Please sign in to comment.