Merge pull request #417 from manastyretskyi/main
Fix builder registry cache when using default registry
This commit is contained in:
@@ -92,12 +92,16 @@ class Mrsk::Configuration::Builder
|
|||||||
@options["cache"]&.fetch("image", nil) || "#{@image}-build-cache"
|
@options["cache"]&.fetch("image", nil) || "#{@image}-build-cache"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cache_image_ref
|
||||||
|
[ @server, cache_image ].compact.join("/")
|
||||||
|
end
|
||||||
|
|
||||||
def cache_from_config_for_gha
|
def cache_from_config_for_gha
|
||||||
"type=gha"
|
"type=gha"
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_from_config_for_registry
|
def cache_from_config_for_registry
|
||||||
[ "type=registry", "ref=#{@server}/#{cache_image}" ].compact.join(",")
|
[ "type=registry", "ref=#{cache_image_ref}" ].compact.join(",")
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_to_config_for_gha
|
def cache_to_config_for_gha
|
||||||
@@ -105,6 +109,6 @@ class Mrsk::Configuration::Builder
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cache_to_config_for_registry
|
def cache_to_config_for_registry
|
||||||
[ "type=registry", @options["cache"]&.fetch("options", nil), "ref=#{@server}/#{cache_image}" ].compact.join(",")
|
[ "type=registry", @options["cache"]&.fetch("options", nil), "ref=#{cache_image_ref}" ].compact.join(",")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -90,15 +90,23 @@ class ConfigurationBuilderTest < ActiveSupport::TestCase
|
|||||||
test "setting registry cache" do
|
test "setting registry cache" do
|
||||||
@deploy_with_builder_option[:builder] = { "cache" => { "type" => "registry", "options" => "mode=max,image-manifest=true,oci-mediatypes=true" } }
|
@deploy_with_builder_option[:builder] = { "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,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,mode=max,image-manifest=true,oci-mediatypes=true,ref=dhh/app-build-cache", @config_with_builder_option.builder.cache_to
|
||||||
|
end
|
||||||
|
|
||||||
|
test "setting registry cache when using a custom registry" do
|
||||||
|
@config_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" } }
|
||||||
|
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
test "setting registry cache with image" do
|
test "setting registry cache with image" do
|
||||||
@deploy_with_builder_option[:builder] = { "cache" => { "type" => "registry", "image" => "mrsk", "options" => "mode=max" } }
|
@deploy_with_builder_option[:builder] = { "cache" => { "type" => "registry", "image" => "mrsk", "options" => "mode=max" } }
|
||||||
|
|
||||||
assert_equal "type=registry,ref=/mrsk", @config_with_builder_option.builder.cache_from
|
assert_equal "type=registry,ref=mrsk", @config_with_builder_option.builder.cache_from
|
||||||
assert_equal "type=registry,mode=max,ref=/mrsk", @config_with_builder_option.builder.cache_to
|
assert_equal "type=registry,mode=max,ref=mrsk", @config_with_builder_option.builder.cache_to
|
||||||
end
|
end
|
||||||
|
|
||||||
test "args" do
|
test "args" do
|
||||||
|
|||||||
Reference in New Issue
Block a user