From b4426ed36f9037b6213973e1c19e308eb6fab6df Mon Sep 17 00:00:00 2001 From: kinosita Date: Sat, 19 Sep 2015 16:42:10 +0900 Subject: [PATCH 1/3] fix consul_config:recursor --- libraries/consul_config.rb | 2 +- test/spec/libraries/consul_config_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/consul_config.rb b/libraries/consul_config.rb index 882b133e..580499aa 100644 --- a/libraries/consul_config.rb +++ b/libraries/consul_config.rb @@ -88,7 +88,7 @@ class ConsulConfig < Chef::Resource # Transforms the resource into a JSON format which matches the # Consul service's configuration format. def to_json - for_keeps = %i{acl_datacenter acl_default_policy acl_down_policy acl_master_token acl_token acl_ttl addresses advertise_addr advertise_addr_wan bind_addr bootstrap bootstrap_expect check_update_interval client_addr data_dir datacenter disable_anonymous_signature disable_remote_exec disable_update_check dns_config domain enable_debug enable_syslog encrypt leave_on_terminate log_level node_name ports protocol recurser retry_interval server server_name skip_leave_on_interrupt start_join statsd_addr statsite_addr syslog_facility ui_dir verify_incoming verify_outgoing verify_server_hostname watches} + for_keeps = %i{acl_datacenter acl_default_policy acl_down_policy acl_master_token acl_token acl_ttl addresses advertise_addr advertise_addr_wan bind_addr bootstrap bootstrap_expect check_update_interval client_addr data_dir datacenter disable_anonymous_signature disable_remote_exec disable_update_check dns_config domain enable_debug enable_syslog encrypt leave_on_terminate log_level node_name ports protocol recursor retry_interval server server_name skip_leave_on_interrupt start_join statsd_addr statsite_addr syslog_facility ui_dir verify_incoming verify_outgoing verify_server_hostname watches} for_keeps << %i{ca_file cert_file key_file} if tls? config = to_hash.keep_if do |k, _| for_keeps.include?(k.to_sym) diff --git a/test/spec/libraries/consul_config_spec.rb b/test/spec/libraries/consul_config_spec.rb index bb9cf771..a5454f83 100644 --- a/test/spec/libraries/consul_config_spec.rb +++ b/test/spec/libraries/consul_config_spec.rb @@ -15,16 +15,16 @@ recipe do consul_config '/etc/consul/default.json' do options do - recurser 'foo' + recursor 'foo' end end end it { is_expected.to render_file('/etc/consul/default.json').with_content(<<-EOH.chomp) } { + "recursor": "foo", "verify_incoming": false, - "verify_outgoing": false, - "recurser": "foo" + "verify_outgoing": false } EOH end From 49877e93d74057c69fc3ff518930b0f984371628 Mon Sep 17 00:00:00 2001 From: kinosita Date: Sat, 19 Sep 2015 16:46:00 +0900 Subject: [PATCH 2/3] support consul_config:recursors --- libraries/consul_config.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/consul_config.rb b/libraries/consul_config.rb index 580499aa..065212be 100644 --- a/libraries/consul_config.rb +++ b/libraries/consul_config.rb @@ -71,6 +71,7 @@ class ConsulConfig < Chef::Resource attribute(:ports, kind_of: [Hash, Mash]) attribute(:protocol, kind_of: String) attribute(:recursor, kind_of: String) + attribute(:recursors, kind_of: Array) attribute(:retry_interval, kind_of: Integer) attribute(:server, equal_to: [true, false], default: true) attribute(:server_name, kind_of: String) @@ -88,7 +89,7 @@ class ConsulConfig < Chef::Resource # Transforms the resource into a JSON format which matches the # Consul service's configuration format. def to_json - for_keeps = %i{acl_datacenter acl_default_policy acl_down_policy acl_master_token acl_token acl_ttl addresses advertise_addr advertise_addr_wan bind_addr bootstrap bootstrap_expect check_update_interval client_addr data_dir datacenter disable_anonymous_signature disable_remote_exec disable_update_check dns_config domain enable_debug enable_syslog encrypt leave_on_terminate log_level node_name ports protocol recursor retry_interval server server_name skip_leave_on_interrupt start_join statsd_addr statsite_addr syslog_facility ui_dir verify_incoming verify_outgoing verify_server_hostname watches} + for_keeps = %i{acl_datacenter acl_default_policy acl_down_policy acl_master_token acl_token acl_ttl addresses advertise_addr advertise_addr_wan bind_addr bootstrap bootstrap_expect check_update_interval client_addr data_dir datacenter disable_anonymous_signature disable_remote_exec disable_update_check dns_config domain enable_debug enable_syslog encrypt leave_on_terminate log_level node_name ports protocol recursor recursors retry_interval server server_name skip_leave_on_interrupt start_join statsd_addr statsite_addr syslog_facility ui_dir verify_incoming verify_outgoing verify_server_hostname watches} for_keeps << %i{ca_file cert_file key_file} if tls? config = to_hash.keep_if do |k, _| for_keeps.include?(k.to_sym) From efbcb1e616be52513fe876737028f50d202c5e20 Mon Sep 17 00:00:00 2001 From: kinosita Date: Sat, 19 Sep 2015 19:42:48 +0900 Subject: [PATCH 3/3] consul.config.to_json result sort --- libraries/consul_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/consul_config.rb b/libraries/consul_config.rb index 065212be..41043d71 100644 --- a/libraries/consul_config.rb +++ b/libraries/consul_config.rb @@ -94,7 +94,7 @@ def to_json config = to_hash.keep_if do |k, _| for_keeps.include?(k.to_sym) end.merge(options) - JSON.pretty_generate(config, quirks_mode: true) + JSON.pretty_generate(Hash[config.sort], quirks_mode: true) end def tls?