From 256933f6f31d630367374ac5dd75b0201f5419ac Mon Sep 17 00:00:00 2001 From: Adam Tanner Date: Wed, 18 Sep 2024 14:18:56 -0400 Subject: [PATCH] builder/cache/options: fix order of build args when using registry --- lib/kamal/configuration/builder.rb | 2 +- test/configuration/builder_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/kamal/configuration/builder.rb b/lib/kamal/configuration/builder.rb index a395e2283..b4a01e9b4 100644 --- a/lib/kamal/configuration/builder.rb +++ b/lib/kamal/configuration/builder.rb @@ -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 diff --git a/test/configuration/builder_test.rb b/test/configuration/builder_test.rb index 53740ca84..12580c56e 100644 --- a/test/configuration/builder_test.rb +++ b/test/configuration/builder_test.rb @@ -64,7 +64,7 @@ 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 @@ -72,14 +72,14 @@ 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=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