Skip to content

Commit

Permalink
Merge pull request voxpupuli#418 from hfm/consul110
Browse files Browse the repository at this point in the history
Change enableTagOverride to enable_tag_override in Consul 1.1.0 and later
  • Loading branch information
solarkennedy committed May 14, 2018
2 parents 56f6afc + fbf157d commit 7e3fcda
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 8 additions & 2 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# If provided an array of checks that will be added to this service
#
# [*enable_tag_override*]
# enableTagOverride support for service. Defaults to False.
# enable_tag_override support for service. Defaults to False.
#
# [*ensure*]
# Define availability of service. Use 'absent' to remove existing services.
Expand Down Expand Up @@ -48,6 +48,12 @@

consul_validate_checks($checks)

if versioncmp(getvar('::consul_version'), '1.1.0') >= 0 {
$override_key = 'enable_tag_override'
} else {
$override_key = 'enableTagOverride'
}

$basic_hash = {
'id' => $id,
'name' => $service_name,
Expand All @@ -56,7 +62,7 @@
'tags' => $tags,
'checks' => $checks,
'token' => $token,
'enableTagOverride' => $enable_tag_override,
$override_key => $enable_tag_override,
}

$service_hash = {
Expand Down
13 changes: 12 additions & 1 deletion spec/defines/consul_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@

describe 'with no args' do
let(:params) {{}}
it {
should contain_file("/etc/consul/service_my_service.json") \
.with_content(/"service" *: *\{/) \
.with_content(/"id" *: *"my_service"/) \
.with_content(/"name" *: *"my_service"/) \
.with_content(/"enable_tag_override" *: *false/)
}
end
describe 'with no args ( consul version less than 1.1.0 )' do
let(:params) {{}}
let(:facts) {{ :consul_version => '1.0.1' }}

it {
should contain_file("/etc/consul/service_my_service.json") \
Expand Down Expand Up @@ -52,7 +63,7 @@
.with_content(/"service" *: *\{/) \
.with_content(/"id" *: *"my_service"/) \
.with_content(/"name" *: *"my_service"/) \
.with_content(/"enableTagOverride" *: *true/)
.with_content(/"enable_tag_override" *: *true/)
}
end
describe 'with service name and address' do
Expand Down

0 comments on commit 7e3fcda

Please sign in to comment.