summaryrefslogtreecommitdiff
path: root/lib/leap_cli/config/environment.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-04-09 23:45:18 -0700
committerelijah <elijah@riseup.net>2016-04-09 23:45:18 -0700
commit298ae98021443dabe98e6855436f24ad8ad12a99 (patch)
tree14563851357d6a8720d45cc7eb8b2212c242a158 /lib/leap_cli/config/environment.rb
parenta890550aeba848f1e07ec71967463ee4b247c623 (diff)
secrets: fix bug when secrets.json doesn't exist
Diffstat (limited to 'lib/leap_cli/config/environment.rb')
-rw-r--r--lib/leap_cli/config/environment.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/leap_cli/config/environment.rb b/lib/leap_cli/config/environment.rb
index d8f34ea..3f0b3f3 100644
--- a/lib/leap_cli/config/environment.rb
+++ b/lib/leap_cli/config/environment.rb
@@ -32,6 +32,9 @@ module LeapCli; module Config
def secrets; @@secrets; end
def initialize(manager, name, search_dir, parent, options={})
+ @@nodes ||= nil
+ @@secrets ||= nil
+
@manager = manager
@name = name
@@ -89,13 +92,11 @@ module LeapCli; module Config
# shared: currently non-inheritable
# load the first ones we find, and only those.
#
- @@nodes ||= begin
- nodes = load_all_json(Path.named_path([:node_config, '*'], search_dir), Config::Node, options)
- nodes.any? ? nodes : nil
+ if @@nodes.nil? || @@nodes.empty?
+ @@nodes = load_all_json(Path.named_path([:node_config, '*'], search_dir), Config::Node, options)
end
- @@secrets ||= begin
- secrets = load_json(Path.named_path(:secrets_config, search_dir), Config::Secrets, options)
- secrets.any? ? secrets : nil
+ if @@secrets.nil? || @@secrets.empty?
+ @@secrets = load_json(Path.named_path(:secrets_config, search_dir), Config::Secrets, options)
end
end