localvault 1.15.0 → 1.15.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: 0cfbfdee976a274c577ccb8e782e21f3d64bd1b71ba30e37a5bb583fc1ca54c4
4
- data.tar.gz: 9dd3b6663bd7e0eb15d2a6e00fd4d04afb6c0de3962ed76f219418fc4c01207a
3
+ metadata.gz: 2d660d85bd6e34e1baccfa259c29a482383d155168837f825e2e49f810aa268c
4
+ data.tar.gz: 2c2dccb8a903752fca44862866f19f03243178aa36285903dab953185918988f
5
5
  SHA512:
6
- metadata.gz: c2849e50bf55078b747403fdc65bde8ae1cabb4c304fd22a422c92f4dd12e2a482ddab6d731b6c18d9cba077e86b93eefdb54dffd2724d28ae087a543efcadbc
7
- data.tar.gz: 7d42cfe5bc6c237e6d9b4d9aeefef4e223ff965471c6b417fbf15e7841e1d05a74edfed09221b89b300902ed88ec67afe2e565bd03c46729a2cc5f90debb573c
6
+ metadata.gz: e9b3b12dc5601a7526290c740a5e7f31bd57a635eb0f49c776700a2d0c0cdb0e03bc9e824eae7e0bad2129c1261529ad1d36e24aa84dc5833c212f8954f3b4ec
7
+ data.tar.gz: 2f5c0defb02a78bbd9ba303e94c549b647bf74102beead3b7e61a2ed42e4259470a70460403a70a93a12c601d645baceb0368394193bc5fb383511ee6c0c32fe
@@ -0,0 +1,34 @@
1
+ module LocalVault
2
+ # The Homebrew and install.sh wrappers point GEM_HOME/GEM_PATH at
3
+ # localvault's private gem dir so localvault loads its own gems. Before
4
+ # doing that they set LOCALVAULT_WRAPPED=1 and save the caller's values as
5
+ # LOCALVAULT_ORIG_<VAR> (left unset when the caller had none).
6
+ #
7
+ # Children started by `localvault exec` must see the caller's Ruby
8
+ # environment, not localvault's, or Bundler in the child resolves the app's
9
+ # gems against localvault's libexec. `overrides` returns the env-hash
10
+ # entries for Kernel.exec that hand those values back (nil unsets).
11
+ module ChildEnv
12
+ MARKER = "LOCALVAULT_WRAPPED".freeze
13
+ WRAPPER_VARS = %w[GEM_HOME GEM_PATH].freeze
14
+ BOOKKEEPING_VARS = [MARKER, *WRAPPER_VARS.map { |var| "LOCALVAULT_ORIG_#{var}" }].freeze
15
+
16
+ # The full env hash for Kernel.exec: caller's gem vars restored, vault
17
+ # values on top, and the wrapper's bookkeeping vars always unset — a vault
18
+ # key must not be able to plant them for a nested localvault.
19
+ def self.for_exec(vault_env, env = ENV, on_skip: nil)
20
+ (vault_env.keys & BOOKKEEPING_VARS).each { |var| on_skip&.call(var) }
21
+ overrides(env).merge(vault_env).merge(BOOKKEEPING_VARS.to_h { |var| [var, nil] })
22
+ end
23
+
24
+ def self.overrides(env = ENV)
25
+ return {} unless env[MARKER]
26
+
27
+ WRAPPER_VARS.each_with_object(MARKER => nil) do |var, result|
28
+ saved = "LOCALVAULT_ORIG_#{var}"
29
+ result[var] = env[saved]
30
+ result[saved] = nil
31
+ end
32
+ end
33
+ end
34
+ end
@@ -467,7 +467,7 @@ module LocalVault
467
467
  vault = open_vault!
468
468
  skip_warn = ->(k) { $stderr.puts "Warning: skipping unsafe key '#{k}'" }
469
469
  env_vars = vault.env_hash(**env_projection_options(on_skip: skip_warn))
470
- Kernel.exec(env_vars, *cmd)
470
+ Kernel.exec(ChildEnv.for_exec(env_vars, on_skip: skip_warn), *cmd)
471
471
  rescue EnvProjection::InvalidMapping, EnvProjection::UnknownProfile => e
472
472
  abort_with e.message
473
473
  end
@@ -1,3 +1,3 @@
1
1
  module LocalVault
2
- VERSION = "1.15.0"
2
+ VERSION = "1.15.1"
3
3
  end
data/lib/localvault.rb CHANGED
@@ -16,6 +16,7 @@ require_relative "localvault/api_client"
16
16
  require_relative "localvault/sync_bundle"
17
17
  require_relative "localvault/sync_state"
18
18
  require_relative "localvault/sync_merge"
19
+ require_relative "localvault/child_env"
19
20
 
20
21
  module LocalVault
21
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localvault
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.0
4
+ version: 1.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nauman Tariq
@@ -109,6 +109,7 @@ files:
109
109
  - bin/lv
110
110
  - lib/localvault.rb
111
111
  - lib/localvault/api_client.rb
112
+ - lib/localvault/child_env.rb
112
113
  - lib/localvault/cli.rb
113
114
  - lib/localvault/cli/error_presenter.rb
114
115
  - lib/localvault/cli/guard.rb