aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-03-31 14:14:01 -0700
committerelijah <elijah@riseup.net>2013-03-31 14:14:01 -0700
commit9c131c1d84357175448496590e8d4e31e90118aa (patch)
tree156e4a573fd39b4f256a8c6b4eeaa78303834f02 /lib
parent354c455dc6d463d5eed43804d1eb3aaa95c9e471 (diff)
downloadleap_cli-9c131c1d84357175448496590e8d4e31e90118aa.tar.gz
leap_cli-9c131c1d84357175448496590e8d4e31e90118aa.tar.bz2
add ability to search for nodes using nil values.
Diffstat (limited to 'lib')
-rw-r--r--lib/leap_cli/commands/test.rb6
-rw-r--r--lib/leap_cli/config/macros.rb3
-rw-r--r--lib/leap_cli/config/object_list.rb20
3 files changed, 15 insertions, 14 deletions
diff --git a/lib/leap_cli/commands/test.rb b/lib/leap_cli/commands/test.rb
index 3f0feb0..79271be 100644
--- a/lib/leap_cli/commands/test.rb
+++ b/lib/leap_cli/commands/test.rb
@@ -28,17 +28,17 @@ module LeapCli; module Commands
assert_config! 'provider.ca.client_certificates.unlimited_prefix'
assert_config! 'provider.ca.client_certificates.limited_prefix'
template = read_file! Path.find_file(:test_client_openvpn_template)
- ['production', 'testing', 'local', 'development'].each do |env|
+ ['production', 'testing', 'local', 'development', nil].each do |env|
vpn_nodes = manager.nodes[:environment => env][:services => 'openvpn']['openvpn.allow_limited' => true]
if vpn_nodes.any?
generate_test_client_cert(provider.ca.client_certificates.limited_prefix) do |key, cert|
- write_file! [:test_openvpn_config, env+'_limited'], Util.erb_eval(template, binding)
+ write_file! [:test_openvpn_config, [env, 'limited'].compact.join('_')], Util.erb_eval(template, binding)
end
end
vpn_nodes = manager.nodes[:environment => env][:services => 'openvpn']['openvpn.allow_unlimited' => true]
if vpn_nodes.any?
generate_test_client_cert(provider.ca.client_certificates.unlimited_prefix) do |key, cert|
- write_file! [:test_openvpn_config, env+'_unlimited'], Util.erb_eval(template, binding)
+ write_file! [:test_openvpn_config, [env, 'unlimited'].compact.join('_')], Util.erb_eval(template, binding)
end
end
end
diff --git a/lib/leap_cli/config/macros.rb b/lib/leap_cli/config/macros.rb
index 3c59356..5f90894 100644
--- a/lib/leap_cli/config/macros.rb
+++ b/lib/leap_cli/config/macros.rb
@@ -21,6 +21,9 @@ module LeapCli; module Config
#
# returns a list of nodes that match the same environment
#
+ # if @node.environment is not set, we return other nodes
+ # where environment is not set.
+ #
def nodes_like_me
nodes[:environment => @node.environment]
end
diff --git a/lib/leap_cli/config/object_list.rb b/lib/leap_cli/config/object_list.rb
index 0c7711f..0c0da14 100644
--- a/lib/leap_cli/config/object_list.rb
+++ b/lib/leap_cli/config/object_list.rb
@@ -40,17 +40,15 @@ module LeapCli
operator = match_value =~ /^!/ ? :not_equal : :equal
each do |name, config|
value = config[field]
- if !value.nil?
- if value.is_a? Array
- if value.include?(match_value)
- results[name] = config
- end
- else
- if operator == :equal && value == match_value
- results[name] = config
- elsif operator == :not_equal && value != match_value
- results[name] = config
- end
+ if value.is_a? Array
+ if value.include?(match_value)
+ results[name] = config
+ end
+ else
+ if operator == :equal && value == match_value
+ results[name] = config
+ elsif operator == :not_equal && value != match_value
+ results[name] = config
end
end
end