Skip to content

Commit

Permalink
Fix foodcritic violation
Browse files Browse the repository at this point in the history
- Use proper license name
- Use converge_by instead of updated_by_last_action
- Use platform introspection DSL when possible
- Ignore FC028 when DSL is not usable due to poise inversion
  • Loading branch information
Annih committed Jul 17, 2017
1 parent a552ae7 commit a3ed509
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions libraries/consul_acl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,18 @@ class ConsulAcl < Chef::Provider
def action_create
configure_diplomat
unless up_to_date?
Diplomat::Acl.create(new_resource.to_acl)
new_resource.updated_by_last_action(true)
converge_by 'creating ACL' do
Diplomat::Acl.create(new_resource.to_acl)
end
end
end

def action_delete
configure_diplomat
unless Diplomat::Acl.info(new_resource.id).empty?
Diplomat::Acl.destroy(new_resource.id)
new_resource.updated_by_last_action(true)
converge_by 'removing ACL' do
Diplomat::Acl.destroy(new_resource.id)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion libraries/consul_installation_binary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def self.provides_auto?(_node, _resource)
# @return [Hash]
# @api private
def self.default_inversion_options(node, resource)
extract_path = node.platform_family?('windows') ? node.config_prefix_path : '/opt/consul'
extract_path = node.platform_family?('windows') ? node.config_prefix_path : '/opt/consul' # ~FC028
super.merge(extract_to: extract_path,
version: resource.version,
archive_url: 'https://releases.hashicorp.com/consul/%{version}/%{basename}',
Expand Down
2 changes: 1 addition & 1 deletion libraries/consul_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def service_options(service)
service.options(:sysvinit, template: 'consul:sysvinit.service.erb')
service.options(:upstart, template: 'consul:upstart.service.erb', executable: new_resource.program)

if node.platform_family?('rhel') && node['platform_version'].to_i == 6
if node.platform_family?('rhel') && node['platform_version'].to_i == 6 # ~FC028
service.provider(:sysvinit)
end
end
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name 'consul'
maintainer 'John Bellone'
maintainer_email '[email protected]'
license 'Apache 2.0'
license 'Apache-2.0'
description 'Application cookbook which installs and configures Consul.'
long_description 'Application cookbook which installs and configures Consul.'
version '3.0.0'
Expand Down
4 changes: 2 additions & 2 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
poise_service_user node['consul']['service_user'] do
group node['consul']['service_group']
shell node['consul']['service_shell'] unless node['consul']['service_shell'].nil?
not_if { node.platform_family?('windows') }
not_if { platform_family?('windows') }
not_if { node['consul']['service_user'] == 'root' }
not_if { node['consul']['create_service_user'] == false }
end
Expand All @@ -30,7 +30,7 @@
config_file config.path
program install.consul_program

unless node.platform_family?('windows')
unless platform_family?('windows')
user node['consul']['service_user']
group node['consul']['service_group']
end
Expand Down

0 comments on commit a3ed509

Please sign in to comment.