kamal-backup 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7135af9b16454829f69ed19ca84d58045232e5db583cc54cbc1fe623bf80c4f6
4
- data.tar.gz: 8f70a9143faec5b730e3e9d70a33b4bed4f1f650815f81c97c303766151fd2af
3
+ metadata.gz: 9a38b68b938b1d5d96996c2e0271cdff8e914600b8d134e39a0717aa8290bca7
4
+ data.tar.gz: 0451f17fefb476958074c0c11e37a4c0a020b8b4e6bf3fa352296369326a7925
5
5
  SHA512:
6
- metadata.gz: a919c1e57b6061ce588bd73d00b87eeff13e7b312b3da1bf05d8263116eadc119facc2fedadcba62d21a4d0983835bb52b89486eb13beeeffb3673588ec39845
7
- data.tar.gz: 64739bbaac082b4266d37b2dfbd70d4ad53c7010a825a037126ff4b9cfb828c0968d2dd1045c25cd82fab5371864a2405c10c0edee99152948131f8d8112bf38
6
+ metadata.gz: 9f3e92a83c2ead4ed47136253c730cfd5f47938f490de04b2d48df91a7673a3b4ac08e4eda0d951fa83dab3215b544e8f060d68b4285dd9f042323267a08cd5c
7
+ data.tar.gz: 899dfd47d6cefc53f87a72ca53ddda721bcf9c55ef019236b12a26bd56def82b5665c26958c5e8444a5168023ee49d0a51d17a632ac44e5db3f61861cb9518b7
data/README.md CHANGED
@@ -145,6 +145,8 @@ kamal-backup version
145
145
 
146
146
  Production-side commands shell out through Kamal when you pass `-d` or `-c`. Local commands run on your machine.
147
147
 
148
+ Remote-backed commands require the local gem version and the backup accessory version to match. If they drift, `kamal-backup` fails fast and tells you to reboot the accessory so it pulls the current `latest` image. `version` is the diagnostic exception: it shows both versions and the sync status.
149
+
148
150
  Common examples:
149
151
 
150
152
  ```sh
@@ -54,7 +54,13 @@ module KamalBackup
54
54
  @accessory_name ||= bridge.accessory_name(preferred: local_preferences.accessory_name)
55
55
  end
56
56
 
57
- def exec_remote(argv)
57
+ def remote_version
58
+ @remote_version ||= bridge.remote_version(accessory_name: accessory_name)
59
+ end
60
+
61
+ def exec_remote(argv, require_version_match: true)
62
+ ensure_remote_version_match! if require_version_match
63
+
58
64
  result = bridge.execute_on_accessory(
59
65
  accessory_name: accessory_name,
60
66
  command: Shellwords.join(argv)
@@ -63,6 +69,32 @@ module KamalBackup
63
69
  result
64
70
  end
65
71
 
72
+ def ensure_remote_version_match!
73
+ return if remote_version == VERSION
74
+
75
+ raise ConfigurationError, <<~MESSAGE.strip
76
+ local gem version #{VERSION} does not match remote accessory version #{remote_version}.
77
+ Reboot the backup accessory to pick up the latest image:
78
+ #{accessory_reboot_command}
79
+ MESSAGE
80
+ end
81
+
82
+ def accessory_reboot_command
83
+ argv = ["bin/kamal", "accessory", "reboot", accessory_name]
84
+ argv.concat(["-c", options[:config_file]]) if options[:config_file]
85
+ argv.concat(["-d", options[:destination]]) if options[:destination]
86
+ Shellwords.join(argv)
87
+ end
88
+
89
+ def print_remote_version_status
90
+ status = remote_version == VERSION ? "in sync" : "out of sync"
91
+
92
+ puts("local: #{VERSION}")
93
+ puts("remote: #{remote_version}")
94
+ puts("status: #{status}")
95
+ puts("fix: #{accessory_reboot_command}") if status == "out of sync"
96
+ end
97
+
66
98
  def confirm!(message)
67
99
  return if options[:yes]
68
100
 
@@ -345,7 +377,7 @@ module KamalBackup
345
377
  desc "version", "Print the running kamal-backup version"
346
378
  def version
347
379
  if deployment_mode?
348
- exec_remote(["kamal-backup", "version"])
380
+ print_remote_version_status
349
381
  else
350
382
  puts(VERSION)
351
383
  end
@@ -46,6 +46,17 @@ module KamalBackup
46
46
  capture_kamal(kamal_exec_argv(accessory_name, command))
47
47
  end
48
48
 
49
+ def remote_version(accessory_name:)
50
+ result = execute_on_accessory(accessory_name: accessory_name, command: "kamal-backup version")
51
+ version = result.stdout.to_s.strip
52
+
53
+ if version.empty?
54
+ raise ConfigurationError, "could not determine remote kamal-backup version from accessory #{accessory_name}"
55
+ else
56
+ version
57
+ end
58
+ end
59
+
49
60
  private
50
61
  def config
51
62
  @config ||= begin
@@ -1,3 +1,3 @@
1
1
  module KamalBackup
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kamal-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - crmne