Skip to content

Commit

Permalink
consul_config: Remove default values
Browse files Browse the repository at this point in the history
We don't need to set these defaults values because:
1) These default values are rendered to the `consul.json` config file only if an appropriate argument was called in the `consul_config` resource source code. For example, currently we have `verify_incoming` and `verify_outgoing` always rendered in the config file because they are called there, in #tls? helper.

2) Consul can handle default values by itself.
We just don't need to render them in the config file unless we really need to set them explicitly. It makes a big sense for consul config options which have different default values in different Consul agent versions. For example, `acl_enforce_version_8` defaults to _false_ in versions of Consul prior to 0.8, and defaults to _true_ in Consul 0.8 and later.
  • Loading branch information
legal90 committed May 31, 2017
1 parent eebc129 commit bd294b5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
40 changes: 20 additions & 20 deletions libraries/consul_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ConsulConfig < Chef::Resource
attribute(:acl_datacenter, kind_of: String)
attribute(:acl_default_policy, kind_of: String)
attribute(:acl_down_policy, kind_of: String)
attribute(:acl_enforce_version_8, equal_to: [true, false], default: false)
attribute(:acl_enforce_version_8, equal_to: [true, false])
attribute(:acl_master_token, kind_of: String)
attribute(:acl_replication_token, kind_of: String)
attribute(:acl_token, kind_of: String)
Expand All @@ -50,31 +50,31 @@ class ConsulConfig < Chef::Resource
attribute(:advertise_addr_wan, kind_of: String)
attribute(:atlas_acl_token, kind_of: String)
attribute(:atlas_infrastructure, kind_of: String)
attribute(:atlas_join, equal_to: [true, false], default: false)
attribute(:atlas_join, equal_to: [true, false])
attribute(:atlas_token, kind_of: String)
attribute(:atlas_endpoint, kind_of: String)
attribute(:bind_addr, kind_of: String)
attribute(:bootstrap, equal_to: [true, false], default: false)
attribute(:bootstrap_expect, kind_of: Integer, default: 3)
attribute(:bootstrap, equal_to: [true, false])
attribute(:bootstrap_expect, kind_of: Integer)
attribute(:ca_file, kind_of: String)
attribute(:cert_file, kind_of: String)
attribute(:check_update_interval, kind_of: String)
attribute(:client_addr, kind_of: String)
attribute(:data_dir, kind_of: String)
attribute(:datacenter, kind_of: String)
attribute(:disable_anonymous_signature, equal_to: [true, false], default: false)
attribute(:disable_host_node_id, equal_to: [true, false], default: false)
attribute(:disable_remote_exec, equal_to: [true, false], default: true)
attribute(:disable_update_check, equal_to: [true, false], default: false)
attribute(:disable_anonymous_signature, equal_to: [true, false])
attribute(:disable_host_node_id, equal_to: [true, false])
attribute(:disable_remote_exec, equal_to: [true, false])
attribute(:disable_update_check, equal_to: [true, false])
attribute(:dns_config, kind_of: [Hash, Mash])
attribute(:domain, kind_of: String)
attribute(:enable_debug, equal_to: [true, false], default: false)
attribute(:enable_syslog, equal_to: [true, false], default: false)
attribute(:enable_debug, equal_to: [true, false])
attribute(:enable_syslog, equal_to: [true, false])
attribute(:encrypt, kind_of: String)
attribute(:http_api_response_headers, kind_of: [Hash, Mash])
attribute(:key_file, kind_of: String)
attribute(:leave_on_terminate, equal_to: [true, false], default: false)
attribute(:log_level, equal_to: %w(INFO DEBUG WARN ERR), default: 'INFO')
attribute(:leave_on_terminate, equal_to: [true, false])
attribute(:log_level, equal_to: %w(INFO DEBUG WARN ERR))
attribute(:node_id, kind_of: String)
attribute(:node_name, kind_of: String)
attribute(:performance, kind_of: [Hash, Mash])
Expand All @@ -91,28 +91,28 @@ class ConsulConfig < Chef::Resource
attribute(:retry_join, kind_of: Array)
attribute(:retry_join_ec2, kind_of: [Hash, Mash])
attribute(:retry_join_wan, kind_of: Array)
attribute(:rejoin_after_leave, equal_to: [true, false], default: true)
attribute(:rejoin_after_leave, equal_to: [true, false])
attribute(:serf_lan_bind, kind_of: String)
attribute(:serf_wan_bind, kind_of: String)
attribute(:server, equal_to: [true, false])
attribute(:server_name, kind_of: String)
attribute(:session_ttl_min, kind_of: String)
attribute(:skip_leave_on_interrupt, equal_to: [true, false], default: false)
attribute(:skip_leave_on_interrupt, equal_to: [true, false])
attribute(:start_join, kind_of: Array)
attribute(:start_join_wan, kind_of: Array)
attribute(:statsd_addr, kind_of: String)
attribute(:statsite_addr, kind_of: String)
attribute(:statsite_prefix, kind_of: String)
attribute(:telemetry, kind_of: [Hash, Mash])
attribute(:syslog_facility, kind_of: String)
attribute(:translate_wan_addrs, equal_to: [true, false], default: false)
attribute(:ui, equal_to: [true, false], default: false)
attribute(:translate_wan_addrs, equal_to: [true, false])
attribute(:ui, equal_to: [true, false])
attribute(:ui_dir, kind_of: String)
attribute(:unix_sockets, kind_of: [Hash, Mash])
attribute(:verify_incoming, equal_to: [true, false], default: false)
attribute(:verify_outgoing, equal_to: [true, false], default: false)
attribute(:verify_server_hostname, equal_to: [true, false], default: false)
attribute(:watches, kind_of: [Hash, Mash], default: {})
attribute(:verify_incoming, equal_to: [true, false])
attribute(:verify_outgoing, equal_to: [true, false])
attribute(:verify_server_hostname, equal_to: [true, false])
attribute(:watches, kind_of: [Hash, Mash])

# Transforms the resource into a JSON format which matches the
# Consul service's configuration format.
Expand Down
4 changes: 1 addition & 3 deletions test/spec/libraries/consul_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
.with(content: <<-EOH.chomp.gsub(/^ /, ''))
{
"recursor": "foo",
"translate_wan_addrs": true,
"verify_incoming": false,
"verify_outgoing": false
"translate_wan_addrs": true
}
EOH
end
Expand Down

0 comments on commit bd294b5

Please sign in to comment.