bard-api 0.6.3 → 0.7.0

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: e51131122902484d133bcaaf0ca3f01abea607acf01b6b89a7459ad99a5afe45
4
- data.tar.gz: 713e9aac75181d545f6807259a8031c96064b58fc6c02d32e1bdea5f870cc154
3
+ metadata.gz: 8d3a962a491b792f640982845bad5d5b46aa8706c42c90fa535e4fb9bc2368d3
4
+ data.tar.gz: 67d6ef64e755766f4303f404736735bcccbd1fdcdb9260ca9f7204e55dba74c0
5
5
  SHA512:
6
- metadata.gz: 8294f16c4750b0e560ecb26477a24527dbb29a229cec6e200fd6494d2d31b88bccbd3f0041516aeb1db87d36c1361e7bae678a0d66035aead9d92e86983f2716
7
- data.tar.gz: 445de7f208e078a97efe9ec981556d585540003828c60d07de236ea736edae2433e6f9bc0afee3949a1c56267c407761822186328f427fb157cb05ee4780c75d
6
+ metadata.gz: 03e502b74a416d3d2fc309b5925e3ce708d97e272990ba72f0ae59ff26ce285cfaf7ed1b3b627f9fa19d2beda59ed75d90c6777ab3dc7b02ef8625bb0785a85c
7
+ data.tar.gz: e761c08bf627e729bbaa25658c82e54fab2367fb4f9a330d8859dedc62ec929a7a07f26ad53b637e53bac5087a420637a5950d662107d66f35a276e2471ad120
data/lib/bard/api/app.rb CHANGED
@@ -26,22 +26,32 @@ module Bard
26
26
  @deploy_runner ||= method(:spawn_detached_deploy)
27
27
  end
28
28
 
29
- # with_unbundled_env is essential: this worker runs under the app's bundle
29
+ # The deploy must start from a clean env: this worker runs under the app's bundle
30
30
  # (RUBYOPT=-rbundler/setup, BUNDLE_GEMFILE). Inherited into the deploy, that makes every
31
- # ruby command — bundle install included — crash at startup the moment git pull lands a
32
- # lockfile with not-yet-installed gems. The deploy must start from a clean env.
31
+ # ruby command — bin/setup and bundle install included — crash at startup the moment
32
+ # git pull lands a lockfile with not-yet-installed gems.
33
33
  def spawn_detached_deploy(command)
34
34
  Bundler.with_unbundled_env do
35
- # A Passenger web worker is spawned without a login session, so it has no XDG_RUNTIME_DIR;
36
- # systemd-run --user needs it to find the (linger-backed) user bus at $XDG_RUNTIME_DIR/bus.
37
35
  pid = Process.spawn(
38
- { "XDG_RUNTIME_DIR" => "/run/user/#{Process.uid}" },
36
+ deploy_env,
39
37
  "systemd-run", "--user", "--scope", "--collect", "--quiet", "bash", "-lc", command,
40
38
  :in => "/dev/null", %i[out err] => ["log/bard-deploy.log", "a"],
41
39
  )
42
40
  Process.detach(pid)
43
41
  end
44
42
  end
43
+
44
+ # with_unbundled_env alone isn't enough: it restores Bundler::ORIGINAL_ENV, and under
45
+ # Passenger RUBYOPT=-rbundler/setup is injected before the app boots, so it's part of
46
+ # ORIGINAL_ENV and survives the scrub (took brianporter.com down on 2026-07-15). Strip
47
+ # the bundler vars explicitly — nil values remove them from the spawned env.
48
+ # XDG_RUNTIME_DIR: a Passenger web worker is spawned without a login session, so it's
49
+ # unset; systemd-run --user needs it to find the (linger-backed) user bus.
50
+ def deploy_env
51
+ bundler_vars = ENV.keys.grep(/\A(BUNDLE_|BUNDLER_)/) + %w[RUBYOPT RUBYLIB]
52
+ bundler_vars.to_h { |key| [key, nil] }
53
+ .merge("XDG_RUNTIME_DIR" => "/run/user/#{Process.uid}")
54
+ end
45
55
  end
46
56
 
47
57
  DEPLOY_LOCK = "tmp/bard-deploy.lock"
@@ -56,11 +66,15 @@ module Bard
56
66
  # HEAD before the bundle/migrate/restart run, so HEAD alone would read as "done" too early.
57
67
  # On any failure, stamp the attempted sha so we don't re-spawn (and restart Puma) on every
58
68
  # poll; the marker is written inside the flock, so it's on disk before the lock releases.
69
+ # Then roll the tree back to the pre-pull sha: code sitting ahead of its installed gems is
70
+ # a time bomb — the next app-process respawn (e.g. an nginx reload) can't boot and the
71
+ # site 500s until someone intervenes. Better to keep running the old code.
59
72
  DEPLOY_COMMAND =
60
73
  "flock -n #{DEPLOY_LOCK} -c '" \
61
74
  "rm -f #{FAILED_SHA}; " \
75
+ "before=$(git rev-parse HEAD); " \
62
76
  "git pull --ff-only origin master && bin/setup && git rev-parse HEAD > #{DEPLOYED_SHA} " \
63
- "|| git rev-parse origin/master > #{FAILED_SHA}'"
77
+ "|| { git rev-parse origin/master > #{FAILED_SHA}; git reset --hard \"$before\"; }'"
64
78
 
65
79
  def call(env)
66
80
  request = Rack::Request.new(env)
@@ -206,7 +220,7 @@ module Bard
206
220
  enabled: backup.enabled?,
207
221
  bard_managed: backup.bard?,
208
222
  self_managed: backup.self_managed?,
209
- encryption_enabled: !!backup.encrypt,
223
+ encryption_enabled: Bard::Backup::Destination.resolve(backup.destinations).any?(&:encryption_key),
210
224
  destinations: backup.destinations.map { |d| { name: d[:name], type: d[:type] } },
211
225
  },
212
226
  servers: production ? { production: { pings: production.ping } } : {},
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bard
4
4
  module Api
5
- VERSION = "0.6.3"
5
+ VERSION = "0.7.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-07-10 00:00:00.000000000 Z
10
+ date: 2026-08-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: jwt
@@ -51,34 +51,20 @@ dependencies:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
- - !ruby/object:Gem::Dependency
55
- name: bard
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '2.0'
61
- type: :runtime
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '2.0'
68
54
  - !ruby/object:Gem::Dependency
69
55
  name: bard-backup
70
56
  requirement: !ruby/object:Gem::Requirement
71
57
  requirements:
72
58
  - - ">="
73
59
  - !ruby/object:Gem::Version
74
- version: '0.11'
60
+ version: '0.15'
75
61
  type: :runtime
76
62
  prerelease: false
77
63
  version_requirements: !ruby/object:Gem::Requirement
78
64
  requirements:
79
65
  - - ">="
80
66
  - !ruby/object:Gem::Version
81
- version: '0.11'
67
+ version: '0.15'
82
68
  - !ruby/object:Gem::Dependency
83
69
  name: rack-test
84
70
  requirement: !ruby/object:Gem::Requirement