Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13287,7 +13287,7 @@ Name of the statsd exporter service (default 'statsd_exporter')

##### <a name="-prometheus--statsd_exporter--mappings"></a>`mappings`

Data type: `Array[Hash]`
Data type: `Optional[Array[Hash]]`

The hiera array for mappings:
- map: 'test.dispatcher.*.*.*'
Expand All @@ -13296,6 +13296,8 @@ The hiera array for mappings:
processor: '$2'
action: '$1'

Default value: `undef`

##### <a name="-prometheus--statsd_exporter--user"></a>`user`

Data type: `String[1]`
Expand Down
18 changes: 10 additions & 8 deletions manifests/statsd_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
String[1] $package_ensure,
String[1] $package_name,
String[1] $service_name,
Array[Hash] $mappings,
String[1] $user,
String[1] $version,
Optional[Array[Hash]] $mappings = undef,
String[1] $arch = $prometheus::real_arch,
Stdlib::Absolutepath $bin_dir = $prometheus::bin_dir,
String[1] $config_mode = $prometheus::config_mode,
Expand Down Expand Up @@ -105,13 +105,15 @@
default => undef,
}

file { $mapping_config_path:
ensure => 'file',
mode => $config_mode,
owner => 'root',
group => $group,
content => stdlib::to_yaml({ mappings => $mappings }),
notify => $notify_service,
if $mappings {
file { $mapping_config_path:
ensure => 'file',
mode => $config_mode,
owner => 'root',
group => $group,
content => stdlib::to_yaml({ mappings => $mappings }),
notify => $notify_service,
}
}

# Switched to POSIX like flags in version 0.7.0
Expand Down
16 changes: 16 additions & 0 deletions spec/classes/statsd_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@
end
end

context 'with no mappings' do
let(:params) do
{
version: '0.8.0',
arch: 'amd64',
os: 'linux',
bin_dir: '/usr/local/bin',
install_method: 'url',
}
end

describe 'compile manifest' do
it { is_expected.to compile.with_all_deps }
end
end

context 'with older version that does not support posix like option flags specified' do
let(:params) do
{
Expand Down