Skip to content

Commit

Permalink
adding support for service tag override
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Liles committed May 28, 2016
1 parent 4cd8e44 commit c67e1e1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
35 changes: 20 additions & 15 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,33 @@
# [*token*]
# ACL token for interacting with the catalog (must be 'management' type)
#
# [*enable_tag_override*]
# enableTagOverride support for service. Defaults to False.
#
define consul::service(
$ensure = present,
$service_name = $title,
$id = $title,
$tags = [],
$address = undef,
$port = undef,
$checks = [],
$token = undef,
$ensure = present,
$service_name = $title,
$id = $title,
$tags = [],
$address = undef,
$port = undef,
$checks = [],
$token = undef,
$enable_tag_override = false,
) {
include consul

consul_validate_checks($checks)

$basic_hash = {
'id' => $id,
'name' => $service_name,
'address' => $address,
'port' => $port,
'tags' => $tags,
'checks' => $checks,
'token' => $token,
'id' => $id,
'name' => $service_name,
'address' => $address,
'port' => $port,
'tags' => $tags,
'checks' => $checks,
'token' => $token,
'enableTagOverride' => $enable_tag_override,
}

$service_hash = {
Expand Down
16 changes: 15 additions & 1 deletion spec/defines/consul_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
should contain_file("/etc/consul/service_my_service.json") \
.with_content(/"service" *: *\{/) \
.with_content(/"id" *: *"my_service"/) \
.with_content(/"name" *: *"my_service"/)
.with_content(/"name" *: *"my_service"/) \
.with_content(/"enableTagOverride" *: *"false"/)
}
end
describe 'with different ensure' do
Expand Down Expand Up @@ -41,6 +42,19 @@
.with_content(/"name" *: *"different_name"/)
}
end
describe 'with enable_tag_override' do
let(:params) {{
'enable_tag_override' => 'true',
}}

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(/"enableTagOverride" *: *"true"/)
}
end
describe 'with service name and address' do
let(:params) {{
'service_name' => 'different_name',
Expand Down

0 comments on commit c67e1e1

Please sign in to comment.