kamal-backup 0.3.0.beta7 → 0.3.0.beta8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kamal_backup/cli.rb +10 -5
- data/lib/kamal_backup/command.rb +8 -0
- data/lib/kamal_backup/kamal_bridge.rb +16 -2
- data/lib/kamal_backup/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d920c58d8ff83794df465f0549d8599ea6a5e815b800221fa850ce024241abfa
|
|
4
|
+
data.tar.gz: feb8374a19862349d1fb0b3d55e3e697b45df66d58fc0c0f63ddba4767ed01f9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9e36489f2557dca0695be87b779a9b20f96148b141e67a9422bc8933c925ea68a17a73d221c56f4a51585258194752f0db4f0b6fed4a4845783334e6dc0d8e0e
|
|
7
|
+
data.tar.gz: f8bb63eb69f7da8bdfcc001e07c95495ac60fa6996eb4b4188cfb2a8bc453979176985703f897c8e5ac4a9b02faec5cf3d76aad15862b0c964d6c961c2910556
|
data/lib/kamal_backup/cli.rb
CHANGED
|
@@ -129,11 +129,13 @@ module KamalBackup
|
|
|
129
129
|
|
|
130
130
|
def print_remote_version_status
|
|
131
131
|
status = remote_version == VERSION ? "in sync" : "out of sync"
|
|
132
|
+
status_color = status == "in sync" ? :green : :red
|
|
133
|
+
status_output = CommandOutput.new(io: $stdout, env: command_env)
|
|
132
134
|
|
|
133
135
|
puts("local: #{VERSION}")
|
|
134
136
|
puts("remote: #{remote_version}")
|
|
135
|
-
puts("status: #{status}")
|
|
136
|
-
puts("fix: #{accessory_reboot_command}") if status == "out of sync"
|
|
137
|
+
puts("status: #{status_output.decorate(status, status_color, :bold)}")
|
|
138
|
+
puts("fix: #{status_output.decorate(accessory_reboot_command, :yellow, :bold)}") if status == "out of sync"
|
|
137
139
|
end
|
|
138
140
|
|
|
139
141
|
def validate_deploy_config
|
|
@@ -399,14 +401,17 @@ module KamalBackup
|
|
|
399
401
|
|
|
400
402
|
def self.start(argv = ARGV, env: ENV)
|
|
401
403
|
self.command_env = env
|
|
402
|
-
|
|
404
|
+
output = CommandOutput.new(io: $stderr, env: env)
|
|
405
|
+
Command.with_output(output) do
|
|
403
406
|
super(normalize_global_options(argv))
|
|
404
407
|
end
|
|
405
408
|
rescue Error => e
|
|
406
|
-
|
|
409
|
+
output ||= CommandOutput.new(io: $stderr, env: env)
|
|
410
|
+
output.error("(#{e.class}): #{e.message}", redactor: Redactor.new(env: env))
|
|
407
411
|
exit(1)
|
|
408
412
|
rescue Interrupt
|
|
409
|
-
|
|
413
|
+
output ||= CommandOutput.new(io: $stderr, env: env)
|
|
414
|
+
output.error("(Interrupt): interrupted", redactor: Redactor.new(env: env))
|
|
410
415
|
exit(130)
|
|
411
416
|
ensure
|
|
412
417
|
self.command_env = nil
|
data/lib/kamal_backup/command.rb
CHANGED
|
@@ -72,6 +72,14 @@ module KamalBackup
|
|
|
72
72
|
write_message("INFO", redactor.redact_string(message))
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
+
def error(message, redactor:)
|
|
76
|
+
write_message("ERROR", colorize(redactor.redact_string(message), :red, :bold))
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def decorate(value, color, mode = nil)
|
|
80
|
+
colorize(value, color, mode)
|
|
81
|
+
end
|
|
82
|
+
|
|
75
83
|
def command_start(spec, redactor:)
|
|
76
84
|
id = SecureRandom.hex(4)
|
|
77
85
|
started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
@@ -215,10 +215,10 @@ module KamalBackup
|
|
|
215
215
|
end
|
|
216
216
|
|
|
217
217
|
def capture_kamal(argv, stream: false)
|
|
218
|
-
spec = CommandSpec.new(argv: argv)
|
|
218
|
+
spec = CommandSpec.new(argv: argv, env: kamal_stream_env(stream))
|
|
219
219
|
options = {
|
|
220
220
|
redactor: @redactor,
|
|
221
|
-
log:
|
|
221
|
+
log: !stream,
|
|
222
222
|
log_output: false,
|
|
223
223
|
tee_stdout: stream ? @stdout : nil,
|
|
224
224
|
tee_stderr: stream ? @stderr : nil
|
|
@@ -231,6 +231,20 @@ module KamalBackup
|
|
|
231
231
|
end
|
|
232
232
|
end
|
|
233
233
|
|
|
234
|
+
def kamal_stream_env(stream)
|
|
235
|
+
return {} unless stream
|
|
236
|
+
|
|
237
|
+
if @env["SSHKIT_COLOR"].to_s.empty?
|
|
238
|
+
stream_color? ? { "SSHKIT_COLOR" => "1" } : {}
|
|
239
|
+
else
|
|
240
|
+
{ "SSHKIT_COLOR" => @env["SSHKIT_COLOR"] }
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def stream_color?
|
|
245
|
+
[@stdout, @stderr].any? { |io| io.respond_to?(:tty?) && io.tty? }
|
|
246
|
+
end
|
|
247
|
+
|
|
234
248
|
def parse_version_line(output)
|
|
235
249
|
output.to_s.lines.map(&:strip).reverse.find { |line| line.match?(VERSION_LINE_PATTERN) }.to_s
|
|
236
250
|
end
|
data/lib/kamal_backup/version.rb
CHANGED