Class: Kamal::Configuration::Builder
- Inherits:
-
Object
- Object
- Kamal::Configuration::Builder
- Defined in:
- lib/kamal/configuration/builder.rb
Instance Method Summary collapse
- #args ⇒ Object
- #build_directory ⇒ Object
- #cache_from ⇒ Object
- #cache_to ⇒ Object
- #cached? ⇒ Boolean
- #clone_directory ⇒ Object
- #context ⇒ Object
- #dockerfile ⇒ Object
- #git_clone? ⇒ Boolean
-
#initialize(config:) ⇒ Builder
constructor
A new instance of Builder.
- #local? ⇒ Boolean
- #local_arch ⇒ Object
- #local_host ⇒ Object
- #multiarch? ⇒ Boolean
- #remote? ⇒ Boolean
- #remote_arch ⇒ Object
- #remote_host ⇒ Object
- #secrets ⇒ Object
- #ssh ⇒ Object
- #target ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(config:) ⇒ Builder
Returns a new instance of Builder.
2 3 4 5 6 7 8 9 10 |
# File 'lib/kamal/configuration/builder.rb', line 2 def initialize(config:) = config.raw_config.builder || {} @image = config.image @server = config.registry["server"] @service = config.service @destination = config.destination valid? end |
Instance Method Details
#args ⇒ Object
32 33 34 |
# File 'lib/kamal/configuration/builder.rb', line 32 def args ["args"] || {} end |
#build_directory ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'lib/kamal/configuration/builder.rb', line 102 def build_directory @build_directory ||= if git_clone? File.join clone_directory, repo_basename, repo_relative_pwd else "." end end |
#cache_from ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/kamal/configuration/builder.rb', line 68 def cache_from if cached? case ["cache"]["type"] when "gha" cache_from_config_for_gha when "registry" cache_from_config_for_registry end end end |
#cache_to ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/kamal/configuration/builder.rb', line 79 def cache_to if cached? case ["cache"]["type"] when "gha" cache_to_config_for_gha when "registry" cache_to_config_for_registry end end end |
#cached? ⇒ Boolean
28 29 30 |
# File 'lib/kamal/configuration/builder.rb', line 28 def cached? !!["cache"] end |
#clone_directory ⇒ Object
98 99 100 |
# File 'lib/kamal/configuration/builder.rb', line 98 def clone_directory @clone_directory ||= File.join Dir.tmpdir, "kamal-clones", [ @service, pwd_sha ].compact.join("-") end |
#context ⇒ Object
48 49 50 |
# File 'lib/kamal/configuration/builder.rb', line 48 def context ["context"] || "." end |
#dockerfile ⇒ Object
40 41 42 |
# File 'lib/kamal/configuration/builder.rb', line 40 def dockerfile ["dockerfile"] || "Dockerfile" end |
#git_clone? ⇒ Boolean
94 95 96 |
# File 'lib/kamal/configuration/builder.rb', line 94 def git_clone? Kamal::Git.used? && ["context"].nil? end |
#local? ⇒ Boolean
20 21 22 |
# File 'lib/kamal/configuration/builder.rb', line 20 def local? !!["local"] end |
#local_arch ⇒ Object
52 53 54 |
# File 'lib/kamal/configuration/builder.rb', line 52 def local_arch ["local"]["arch"] if local? end |
#local_host ⇒ Object
56 57 58 |
# File 'lib/kamal/configuration/builder.rb', line 56 def local_host ["local"]["host"] if local? end |
#multiarch? ⇒ Boolean
16 17 18 |
# File 'lib/kamal/configuration/builder.rb', line 16 def multiarch? ["multiarch"] != false end |
#remote? ⇒ Boolean
24 25 26 |
# File 'lib/kamal/configuration/builder.rb', line 24 def remote? !!["remote"] end |
#remote_arch ⇒ Object
60 61 62 |
# File 'lib/kamal/configuration/builder.rb', line 60 def remote_arch ["remote"]["arch"] if remote? end |
#remote_host ⇒ Object
64 65 66 |
# File 'lib/kamal/configuration/builder.rb', line 64 def remote_host ["remote"]["host"] if remote? end |
#secrets ⇒ Object
36 37 38 |
# File 'lib/kamal/configuration/builder.rb', line 36 def secrets ["secrets"] || [] end |
#ssh ⇒ Object
90 91 92 |
# File 'lib/kamal/configuration/builder.rb', line 90 def ssh ["ssh"] end |
#target ⇒ Object
44 45 46 |
# File 'lib/kamal/configuration/builder.rb', line 44 def target ["target"] end |
#to_h ⇒ Object
12 13 14 |
# File 'lib/kamal/configuration/builder.rb', line 12 def to_h end |