DRY the use of build options into one call
This commit is contained in:
@@ -5,19 +5,23 @@ class Mrsk::Commands::Builder::Base < Mrsk::Commands::Base
|
||||
docker :pull, config.absolute_image
|
||||
end
|
||||
|
||||
def build_args
|
||||
argumentize "--build-arg", args, redacted: true
|
||||
end
|
||||
|
||||
def build_secrets
|
||||
argumentize "--secret", secrets.collect { |secret| [ "id", secret ] }
|
||||
end
|
||||
|
||||
def build_tags
|
||||
[ "-t", config.absolute_image, "-t", config.latest_image ]
|
||||
def build_options
|
||||
[ *build_tags, *build_args, *build_secrets ]
|
||||
end
|
||||
|
||||
private
|
||||
def build_args
|
||||
argumentize "--build-arg", args, redacted: true
|
||||
end
|
||||
|
||||
def build_secrets
|
||||
argumentize "--secret", secrets.collect { |secret| [ "id", secret ] }
|
||||
end
|
||||
|
||||
def build_tags
|
||||
[ "-t", config.absolute_image, "-t", config.latest_image ]
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user