Skip to content

Commit a443072

Browse files
authored
Merge pull request #1668 from nickhammond/pack-dirty-tags-cache-support
Pack builder updates for no cache and dirty tags
2 parents 785d89a + 1ac2442 commit a443072

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/kamal/commands/builder/pack.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Kamal::Commands::Builder::Pack < Kamal::Commands::Builder::Base
2-
def push(export_action = "registry")
2+
def push(export_action = "registry", tag_as_dirty: false, no_cache: false)
33
combine \
4-
build,
4+
build(tag_as_dirty: tag_as_dirty, no_cache: no_cache),
55
export(export_action)
66
end
77

@@ -13,15 +13,15 @@ def info
1313
alias_method :inspect_builder, :info
1414

1515
private
16-
def build
16+
def build(tag_as_dirty: false, no_cache: false)
1717
pack(:build,
1818
config.repository,
1919
"--platform", platform,
2020
"--creation-time", "now",
2121
"--builder", pack_builder,
2222
buildpacks,
23-
"-t", config.absolute_image,
24-
"-t", config.latest_image,
23+
*build_tag_options(tag_as_dirty: tag_as_dirty),
24+
*([ "--clear-cache" ] if no_cache),
2525
"--env", "BP_IMAGE_LABELS=service=#{config.service}",
2626
*argumentize("--env", args),
2727
*argumentize("--env", secrets, sensitive: true),

test/commands/builder_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ class CommandsBuilderTest < ActiveSupport::TestCase
7777
builder.push.join(" ")
7878
end
7979

80+
test "pack build with no cache" do
81+
builder = new_builder_command(image: "dhh/app", builder: { "args" => { "a" => 1, "b" => 2 }, "arch" => "amd64", "pack" => { "builder" => "heroku/builder:24", "buildpacks" => [ "heroku/ruby", "heroku/procfile" ] } })
82+
83+
assert_equal \
84+
"pack build dhh/app --platform linux/amd64 --creation-time now --builder heroku/builder:24 --buildpack heroku/ruby --buildpack heroku/procfile --buildpack paketo-buildpacks/image-labels -t dhh/app:123 -t dhh/app:latest --clear-cache --env BP_IMAGE_LABELS=service=app --env a=\"1\" --env b=\"2\" --path . && docker push dhh/app:123 && docker push dhh/app:latest",
85+
builder.push("registry", no_cache: true).join(" ")
86+
end
87+
8088
test "pack build secrets as env" do
8189
with_test_secrets("secrets" => "token_a=foo\ntoken_b=bar") do
8290
builder = new_builder_command(image: "dhh/app", builder: { "secrets" => [ "token_a", "token_b" ], "arch" => "amd64", "pack" => { "builder" => "heroku/builder:24", "buildpacks" => [ "heroku/ruby", "heroku/procfile" ] } })

0 commit comments

Comments
 (0)