DRY the use of build options into one call
This commit is contained in:
@@ -5,6 +5,11 @@ class Mrsk::Commands::Builder::Base < Mrsk::Commands::Base
|
||||
docker :pull, config.absolute_image
|
||||
end
|
||||
|
||||
def build_options
|
||||
[ *build_tags, *build_args, *build_secrets ]
|
||||
end
|
||||
|
||||
private
|
||||
def build_args
|
||||
argumentize "--build-arg", args, redacted: true
|
||||
end
|
||||
@@ -17,7 +22,6 @@ class Mrsk::Commands::Builder::Base < Mrsk::Commands::Base
|
||||
[ "-t", config.absolute_image, "-t", config.latest_image ]
|
||||
end
|
||||
|
||||
private
|
||||
def args
|
||||
(config.builder && config.builder["args"]) || {}
|
||||
end
|
||||
|
||||
@@ -12,9 +12,7 @@ class Mrsk::Commands::Builder::Multiarch < Mrsk::Commands::Builder::Base
|
||||
"--push",
|
||||
"--platform", "linux/amd64,linux/arm64",
|
||||
"--builder", builder_name,
|
||||
*build_tags,
|
||||
*build_args,
|
||||
*build_secrets,
|
||||
*build_options,
|
||||
"."
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class Mrsk::Commands::Builder::Native < Mrsk::Commands::Builder::Base
|
||||
|
||||
def push
|
||||
combine \
|
||||
docker(:build, *build_tags, *build_args, *build_secrets, "."),
|
||||
docker(:build, *build_options, "."),
|
||||
docker(:push, config.absolute_image)
|
||||
end
|
||||
|
||||
|
||||
@@ -16,9 +16,7 @@ class Mrsk::Commands::Builder::Native::Remote < Mrsk::Commands::Builder::Native
|
||||
"--push",
|
||||
"--platform", platform,
|
||||
"--builder", builder_name,
|
||||
*build_tags,
|
||||
*build_args,
|
||||
*build_secrets,
|
||||
*build_options,
|
||||
"."
|
||||
end
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@ class CommandsBuilderTest < ActiveSupport::TestCase
|
||||
|
||||
test "build args" do
|
||||
builder = new_builder_command(builder: { "args" => { "a" => 1, "b" => 2 } })
|
||||
assert_equal [ "--build-arg", "a=1", "--build-arg", "b=2" ], builder.target.build_args
|
||||
assert_equal ["-t", "dhh/app:123", "-t", "dhh/app:latest", "--build-arg", "a=1", "--build-arg", "b=2"], builder.target.build_options
|
||||
end
|
||||
|
||||
test "build secrets" do
|
||||
builder = new_builder_command(builder: { "secrets" => ["token_a", "token_b"] })
|
||||
assert_equal [ "--secret", "id=token_a", "--secret", "id=token_b" ], builder.target.build_secrets
|
||||
assert_equal ["-t", "dhh/app:123", "-t", "dhh/app:latest", "--secret", "id=token_a", "--secret", "id=token_b"], builder.target.build_options
|
||||
end
|
||||
|
||||
test "native push with build args" do
|
||||
|
||||
Reference in New Issue
Block a user