kamal 1.3.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kamal/cli/accessory.rb +38 -29
- data/lib/kamal/cli/app/boot.rb +67 -0
- data/lib/kamal/cli/app/prepare_assets.rb +24 -0
- data/lib/kamal/cli/app.rb +25 -67
- data/lib/kamal/cli/base.rb +23 -8
- data/lib/kamal/cli/env.rb +3 -5
- data/lib/kamal/cli/main.rb +7 -4
- data/lib/kamal/cli/prune.rb +6 -2
- data/lib/kamal/cli/server.rb +3 -1
- data/lib/kamal/cli/templates/deploy.yml +5 -1
- data/lib/kamal/cli/templates/sample_hooks/docker-setup.sample +7 -0
- data/lib/kamal/cli/traefik.rb +16 -13
- data/lib/kamal/commander/specifics.rb +49 -0
- data/lib/kamal/commander.rb +9 -33
- data/lib/kamal/commands/accessory.rb +2 -2
- data/lib/kamal/commands/app/assets.rb +12 -12
- data/lib/kamal/commands/app/cord.rb +4 -4
- data/lib/kamal/commands/app/execution.rb +10 -8
- data/lib/kamal/commands/app/images.rb +1 -1
- data/lib/kamal/commands/app/logging.rb +2 -2
- data/lib/kamal/commands/app.rb +38 -18
- data/lib/kamal/commands/auditor.rb +1 -1
- data/lib/kamal/commands/base.rb +12 -0
- data/lib/kamal/commands/builder/base.rb +22 -5
- data/lib/kamal/commands/builder/multiarch.rb +17 -9
- data/lib/kamal/commands/builder/native/cached.rb +7 -6
- data/lib/kamal/commands/builder/native/remote.rb +9 -9
- data/lib/kamal/commands/builder/native.rb +8 -7
- data/lib/kamal/commands/docker.rb +10 -1
- data/lib/kamal/commands/healthcheck.rb +0 -1
- data/lib/kamal/commands/hook.rb +1 -1
- data/lib/kamal/commands/lock.rb +19 -9
- data/lib/kamal/commands/prune.rb +4 -4
- data/lib/kamal/commands/registry.rb +4 -1
- data/lib/kamal/commands/server.rb +1 -1
- data/lib/kamal/commands/traefik.rb +10 -16
- data/lib/kamal/configuration/accessory.rb +10 -20
- data/lib/kamal/configuration/boot.rb +1 -1
- data/lib/kamal/configuration/builder.rb +11 -3
- data/lib/kamal/configuration/env.rb +40 -0
- data/lib/kamal/configuration/role.rb +23 -40
- data/lib/kamal/configuration.rb +53 -21
- data/lib/kamal/env_file.rb +12 -15
- data/lib/kamal/sshkit_with_ext.rb +1 -0
- data/lib/kamal/utils.rb +7 -3
- data/lib/kamal/version.rb +1 -1
- data/lib/kamal.rb +1 -1
- metadata +8 -3
data/lib/kamal/env_file.rb
CHANGED
@@ -3,21 +3,11 @@ class Kamal::EnvFile
|
|
3
3
|
def initialize(env)
|
4
4
|
@env = env
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
def to_s
|
8
8
|
env_file = StringIO.new.tap do |contents|
|
9
|
-
|
10
|
-
|
11
|
-
contents << docker_env_file_line(key, ENV.fetch(key))
|
12
|
-
end
|
13
|
-
|
14
|
-
@env["clear"]&.each do |key, value|
|
15
|
-
contents << docker_env_file_line(key, value)
|
16
|
-
end
|
17
|
-
else
|
18
|
-
@env.fetch("clear", @env)&.each do |key, value|
|
19
|
-
contents << docker_env_file_line(key, value)
|
20
|
-
end
|
9
|
+
@env.each do |key, value|
|
10
|
+
contents << docker_env_file_line(key, value)
|
21
11
|
end
|
22
12
|
end.string
|
23
13
|
|
@@ -26,14 +16,21 @@ class Kamal::EnvFile
|
|
26
16
|
end
|
27
17
|
|
28
18
|
alias to_str to_s
|
29
|
-
|
19
|
+
|
30
20
|
private
|
31
21
|
def docker_env_file_line(key, value)
|
32
|
-
"#{key
|
22
|
+
"#{key}=#{escape_docker_env_file_value(value)}\n"
|
33
23
|
end
|
34
24
|
|
35
25
|
# Escape a value to make it safe to dump in a docker file.
|
36
26
|
def escape_docker_env_file_value(value)
|
27
|
+
# keep non-ascii(UTF-8) characters as it is
|
28
|
+
value.to_s.scan(/[\x00-\x7F]+|[^\x00-\x7F]+/).map do |part|
|
29
|
+
part.ascii_only? ? escape_docker_env_file_ascii_value(part) : part
|
30
|
+
end.join
|
31
|
+
end
|
32
|
+
|
33
|
+
def escape_docker_env_file_ascii_value(value)
|
37
34
|
# Doublequotes are treated literally in docker env files
|
38
35
|
# so remove leading and trailing ones and unescape any others
|
39
36
|
value.to_s.dump[1..-2].gsub(/\\"/, "\"")
|
data/lib/kamal/utils.rb
CHANGED
@@ -9,7 +9,7 @@ module Kamal::Utils
|
|
9
9
|
if value.present?
|
10
10
|
attr = "#{key}=#{escape_shell_value(value)}"
|
11
11
|
attr = self.sensitive(attr, redaction: "#{key}=[REDACTED]") if sensitive
|
12
|
-
[ argument, attr]
|
12
|
+
[ argument, attr ]
|
13
13
|
else
|
14
14
|
[ argument, key ]
|
15
15
|
end
|
@@ -29,7 +29,7 @@ module Kamal::Utils
|
|
29
29
|
|
30
30
|
# Flattens a one-to-many structure into an array of two-element arrays each containing a key-value pair
|
31
31
|
def flatten_args(args)
|
32
|
-
args.flat_map { |key, value| value.try(:map) { |entry| [key, entry] } || [ [ key, value ] ] }
|
32
|
+
args.flat_map { |key, value| value.try(:map) { |entry| [ key, entry ] } || [ [ key, value ] ] }
|
33
33
|
end
|
34
34
|
|
35
35
|
# Marks sensitive values for redaction in logs and human-visible output.
|
@@ -66,7 +66,7 @@ module Kamal::Utils
|
|
66
66
|
Array(filters).select do |filter|
|
67
67
|
matches += Array(items).select do |item|
|
68
68
|
# Only allow * for a wildcard
|
69
|
-
pattern = Regexp.escape(filter).gsub('\*',
|
69
|
+
pattern = Regexp.escape(filter).gsub('\*', ".*")
|
70
70
|
# items are roles or hosts
|
71
71
|
(item.respond_to?(:name) ? item.name : item).match(/^#{pattern}$/)
|
72
72
|
end
|
@@ -74,4 +74,8 @@ module Kamal::Utils
|
|
74
74
|
|
75
75
|
matches
|
76
76
|
end
|
77
|
+
|
78
|
+
def stable_sort!(elements, &block)
|
79
|
+
elements.sort_by!.with_index { |element, index| [ block.call(element), index ] }
|
80
|
+
end
|
77
81
|
end
|
data/lib/kamal/version.rb
CHANGED
data/lib/kamal.rb
CHANGED
@@ -5,6 +5,6 @@ require "active_support"
|
|
5
5
|
require "zeitwerk"
|
6
6
|
|
7
7
|
loader = Zeitwerk::Loader.for_gem
|
8
|
-
loader.ignore("
|
8
|
+
loader.ignore(File.join(__dir__, "kamal", "sshkit_with_ext.rb"))
|
9
9
|
loader.setup
|
10
10
|
loader.eager_load # We need all commands loaded.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kamal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -206,6 +206,8 @@ files:
|
|
206
206
|
- lib/kamal/cli.rb
|
207
207
|
- lib/kamal/cli/accessory.rb
|
208
208
|
- lib/kamal/cli/app.rb
|
209
|
+
- lib/kamal/cli/app/boot.rb
|
210
|
+
- lib/kamal/cli/app/prepare_assets.rb
|
209
211
|
- lib/kamal/cli/base.rb
|
210
212
|
- lib/kamal/cli/build.rb
|
211
213
|
- lib/kamal/cli/env.rb
|
@@ -217,6 +219,7 @@ files:
|
|
217
219
|
- lib/kamal/cli/registry.rb
|
218
220
|
- lib/kamal/cli/server.rb
|
219
221
|
- lib/kamal/cli/templates/deploy.yml
|
222
|
+
- lib/kamal/cli/templates/sample_hooks/docker-setup.sample
|
220
223
|
- lib/kamal/cli/templates/sample_hooks/post-deploy.sample
|
221
224
|
- lib/kamal/cli/templates/sample_hooks/post-traefik-reboot.sample
|
222
225
|
- lib/kamal/cli/templates/sample_hooks/pre-build.sample
|
@@ -226,6 +229,7 @@ files:
|
|
226
229
|
- lib/kamal/cli/templates/template.env
|
227
230
|
- lib/kamal/cli/traefik.rb
|
228
231
|
- lib/kamal/commander.rb
|
232
|
+
- lib/kamal/commander/specifics.rb
|
229
233
|
- lib/kamal/commands.rb
|
230
234
|
- lib/kamal/commands/accessory.rb
|
231
235
|
- lib/kamal/commands/app.rb
|
@@ -256,6 +260,7 @@ files:
|
|
256
260
|
- lib/kamal/configuration/accessory.rb
|
257
261
|
- lib/kamal/configuration/boot.rb
|
258
262
|
- lib/kamal/configuration/builder.rb
|
263
|
+
- lib/kamal/configuration/env.rb
|
259
264
|
- lib/kamal/configuration/role.rb
|
260
265
|
- lib/kamal/configuration/ssh.rb
|
261
266
|
- lib/kamal/configuration/sshkit.rb
|
@@ -286,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
286
291
|
- !ruby/object:Gem::Version
|
287
292
|
version: '0'
|
288
293
|
requirements: []
|
289
|
-
rubygems_version: 3.5.
|
294
|
+
rubygems_version: 3.5.6
|
290
295
|
signing_key:
|
291
296
|
specification_version: 4
|
292
297
|
summary: Deploy web apps in containers to servers running Docker with zero downtime.
|