Add absolute_image to account for custom registry

This commit is contained in:
David Heinemeier Hansson
2023-01-07 21:50:41 +01:00
parent dcaa1e6b71
commit efca6aebb7
2 changed files with 20 additions and 0 deletions

View File

@@ -24,6 +24,10 @@ class Mrsk::Configuration
@version ||= ENV["VERSION"] || `git rev-parse HEAD`.strip
end
def absolute_image
[ config.registry["server"], image ].compact.join("/")
end
def image_with_version
"#{image}:#{version}"
end

View File

@@ -0,0 +1,16 @@
require "test_helper"
require "mrsk/configuration"
class ConfigurationTest < ActiveSupport::TestCase
setup do
@config = { service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" } }
end
test "absolute image" do
configuration = Mrsk::Configuration.new(@config)
assert_equal "dhh/app", configuration.absolute_image
configuration = Mrsk::Configuration.new(@config.tap { |c| c[:registry].merge!({ "server" => "ghcr.io" }) })
assert_equal "ghcr.io/dhh/app", configuration.absolute_image
end
end