support the "provenance" option in the "builder" config

This commit is contained in:
Kohki Makimoto
2024-09-25 21:35:39 +09:00
parent 4a13803119
commit 13328687d1
3 changed files with 16 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ class Kamal::Commands::Builder::Base < Kamal::Commands::Base
delegate :argumentize, to: Kamal::Utils
delegate \
:args, :secrets, :dockerfile, :target, :arches, :local_arches, :remote_arches, :remote,
:cache_from, :cache_to, :ssh, :driver, :docker_driver?,
:cache_from, :cache_to, :ssh, :provenance, :driver, :docker_driver?,
to: :builder_config
def clean
@@ -37,7 +37,7 @@ class Kamal::Commands::Builder::Base < Kamal::Commands::Base
end
def build_options
[ *build_tags, *build_cache, *build_labels, *build_args, *build_secrets, *build_dockerfile, *build_target, *build_ssh ]
[ *build_tags, *build_cache, *build_labels, *build_args, *build_secrets, *build_dockerfile, *build_target, *build_ssh, *builder_provenance ]
end
def build_context
@@ -97,6 +97,10 @@ class Kamal::Commands::Builder::Base < Kamal::Commands::Base
argumentize "--ssh", ssh if ssh.present?
end
def builder_provenance
argumentize "--provenance", provenance unless provenance.nil?
end
def builder_config
config.builder
end

View File

@@ -111,6 +111,10 @@ class Kamal::Configuration::Builder
builder_config["ssh"]
end
def provenance
builder_config["provenance"]
end
def git_clone?
Kamal::Git.used? && builder_config["context"].nil?
end

View File

@@ -104,3 +104,9 @@ builder:
#
# The build driver to use, defaults to `docker-container`
driver: docker
# Provenance
#
# It is used to configure provenance attestations for the build result.
# The value can also be a boolean to enable or disable provenance attestations.
provenance: mode=max