Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change enableTagOverride to enable_tag_override in Consul 1.1.0 and later #418

Merged
merged 1 commit into from
May 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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