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 +4 -4
- data/lib/localvault/child_env.rb +34 -0
- data/lib/localvault/cli.rb +1 -1
- data/lib/localvault/version.rb +1 -1
- data/lib/localvault.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d660d85bd6e34e1baccfa259c29a482383d155168837f825e2e49f810aa268c
|
|
4
|
+
data.tar.gz: 2c2dccb8a903752fca44862866f19f03243178aa36285903dab953185918988f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/lib/localvault/cli.rb
CHANGED
|
@@ -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
|
data/lib/localvault/version.rb
CHANGED
data/lib/localvault.rb
CHANGED
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.
|
|
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
|