diff options
author | elijah <elijah@riseup.net> | 2014-04-05 13:58:37 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2014-04-05 13:58:37 -0700 |
commit | cdc037ed47e6d2a2816601e55e3966c4240e432a (patch) | |
tree | d5a3999ccee5107a5bd927e62765003c5928f2fd /lib/leap_cli/config | |
parent | f3b405f62b06551bb0e62e5594259bb6be8516f9 (diff) |
more graceful handling of error for `leap node add` (closes https://leap.se/code/issues/3725)
Diffstat (limited to 'lib/leap_cli/config')
-rw-r--r-- | lib/leap_cli/config/manager.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/leap_cli/config/manager.rb b/lib/leap_cli/config/manager.rb index 5076b63..7969d40 100644 --- a/lib/leap_cli/config/manager.rb +++ b/lib/leap_cli/config/manager.rb @@ -226,8 +226,8 @@ module LeapCli nodes.each_node &block end - def reload_node(node) - @nodes[node.name] = apply_inheritance(node) + def reload_node!(node) + @nodes[node.name] = apply_inheritance!(node) end private @@ -307,7 +307,7 @@ module LeapCli # # makes a node inherit options from appropriate the common, service, and tag json files. # - def apply_inheritance(node) + def apply_inheritance(node, throw_exceptions=false) new_node = Config::Node.new(self) name = node.name @@ -319,7 +319,9 @@ module LeapCli node['services'].to_a.each do |node_service| service = @services[node_service] if service.nil? - log 0, :error, 'in node "%s": the service "%s" does not exist.' % [node['name'], node_service] + msg = 'in node "%s": the service "%s" does not exist.' % [node['name'], node_service] + log 0, :error, msg + raise LeapCli::ConfigError.new(node, "error " + msg) if throw_exceptions else new_node.deep_merge!(service) service.node_list.add(name, new_node) @@ -335,7 +337,9 @@ module LeapCli node['tags'].to_a.each do |node_tag| tag = @tags[node_tag] if tag.nil? - log 0, :error, 'in node "%s": the tag "%s" does not exist.' % [node['name'], node_tag] + msg = 'in node "%s": the tag "%s" does not exist.' % [node['name'], node_tag] + log 0, :error, msg + raise LeapCli::ConfigError.new(node, "error " + msg) if throw_exceptions else new_node.deep_merge!(tag) tag.node_list.add(name, new_node) @@ -348,6 +352,10 @@ module LeapCli return new_node end + def apply_inheritance!(node) + apply_inheritance(node, true) + end + def remove_disabled_nodes @disabled_nodes = Config::ObjectList.new @nodes.each do |name, node| |