Skip to content

Commit c42d8ee

Browse files
chouetzcocker-cc
andauthored
Fix Deprecation (#788)
Co-authored-by: cocker-cc <[email protected]>
1 parent d20fde9 commit c42d8ee

File tree

6 files changed

+36
-57
lines changed

6 files changed

+36
-57
lines changed

.fixtures.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ fixtures:
22
repositories:
33
stdlib:
44
repo: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
5-
ref: "4.24.0"
5+
ref: "4.25.0"
66
concat:
77
repo: "git://github.com/puppetlabs/puppetlabs-concat.git"
88
ref: "4.1.1"

environments/etc/Puppetfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mod 'puppetlabs-apt', '2.4.0'
44
mod 'puppetlabs-concat', '4.0.0'
55
mod 'puppetlabs-puppetserver_gem', '1.0.0'
66
mod 'puppetlabs-ruby', '1.0.0'
7-
mod 'puppetlabs-stdlib', '4.24.0'
7+
mod 'puppetlabs-stdlib', '4.25.0'
88
mod 'puppetlabs-powershell', '2.3.0'
99
mod 'puppetlabs-yumrepo_core', '1.0.3'
1010
mod 'puppet-zypprepo', '3.1.0'

manifests/init.pp

+20-41
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,13 @@
6969
# $log_to_syslog
7070
# Set value of 'log_to_syslog' variable. Default is true -> yes as in dd-agent.
7171
# Valid values here are: true or false.
72-
# $dogstatsd_port
73-
# Set value of the 'dogstatsd_port' variable. Defaultis 8125.
7472
# $report_fact_tags
7573
# Sets tags for report events sent to Datadog from specified facts
7674
# $report_trusted_fact_tags
7775
# Sets tags for report events sent to Datadog from specified trusted facts
7876
# $statsd_forward_host
7977
# Set the value of the statsd_forward_host varable. Used to forward all
8078
# statsd metrics to another host.
81-
# $statsd_forward_port
82-
# Set the value of the statsd_forward_port varable. Used to forward all
83-
# statsd metrics to another host.
8479
# $manage_repo
8580
# Deprecated. Only works for RPM. Install datadog-agent manually and then set
8681
# manage_install=false to achieve the same behaviour as setting this to false.
@@ -131,7 +126,7 @@
131126
# String. Default: empty
132127
# $dogstatsd_port
133128
# Specifies the port to be used by dogstatsd. Must have use_dogstatsd set
134-
# String. Default: empty
129+
# String. Default: 8125
135130
# $dogstatsd_target
136131
# Change the target to be used by dogstatsd. Must have use_dogstatsd set
137132
# set
@@ -146,8 +141,9 @@
146141
# Enables forwarding of statsd packetsto host. Must have use_dogstatsd set
147142
# String. Default: empty
148143
# $statsd_forward_port
149-
# Specifis port for $statsd_forward_host. Must have use_dogstatsd set
150-
# String. Default: empty
144+
# Specifies port for $statsd_forward_host. Must have use_dogstatsd set String.
145+
# Used to forward all statsd metrics to another host.
146+
# Default: empty
151147
# $device_blacklist_re
152148
# Specifies pattern for device blacklisting.
153149
# String. Default: empty
@@ -288,30 +284,30 @@
288284
Boolean $manage_install = true,
289285
$hostname_extraction_regex = undef,
290286
Boolean $hostname_fqdn = false,
291-
$dogstatsd_port = 8125,
287+
Variant[Stdlib::Port, Pattern[/^\d*$/]] $dogstatsd_port = 8125,
292288
$dogstatsd_socket = '',
293289
Array $report_fact_tags = [],
294290
Array $report_trusted_fact_tags = [],
295291
String $statsd_forward_host = '',
296-
$statsd_forward_port = '',
292+
Variant[Stdlib::Port, Pattern[/^\d*$/]] $statsd_forward_port = '',
297293
String $statsd_histogram_percentiles = '0.95',
298294
Optional[String] $proxy_host = undef,
299295
Optional[Variant[Integer, Pattern[/^\d*$/]]] $proxy_port = undef,
300296
Optional[String] $proxy_user = undef,
301297
Optional[String] $proxy_password = undef,
302-
$graphite_listen_port = '',
298+
Variant[Stdlib::Port, Pattern[/^\d*$/]] $graphite_listen_port = '',
303299
String $extra_template = '',
304300
String $ganglia_host = '',
305301
$ganglia_port = 8651,
306302
Boolean $skip_ssl_validation = false,
307303
Boolean $skip_apt_key_trusting = false,
308304
Boolean $use_curl_http_client = false,
309305
String $recent_point_threshold = '',
310-
$listen_port = '',
306+
Variant[Stdlib::Port, Pattern[/^\d*$/]] $listen_port = '',
311307
Optional[String] $additional_checksd = undef,
312308
String $bind_host = '',
313309
Boolean $use_pup = false,
314-
$pup_port = '',
310+
Variant[Stdlib::Port, Pattern[/^\d*$/]] $pup_port = '',
315311
String $pup_interface = '',
316312
String $pup_url = '',
317313
Boolean $use_dogstatsd = true,
@@ -326,7 +322,7 @@
326322
String $dogstatsd_log_file = '',
327323
String $pup_log_file = '',
328324
String $syslog_host = '',
329-
$syslog_port = '',
325+
Variant[Stdlib::Port, Pattern[/^\d*$/]] $syslog_port = '',
330326
String $service_discovery_backend = '',
331327
String $sd_config_backend = '',
332328
String $sd_backend_host = '',
@@ -391,23 +387,6 @@
391387
$dd_user = $datadog_agent::params::dd_user
392388
}
393389

394-
# Allow ports to be passed as integers or strings.
395-
# lint:ignore:only_variable_string
396-
$_dogstatsd_port = "${dogstatsd_port}"
397-
$_statsd_forward_port = "${statsd_forward_port}"
398-
$_graphite_listen_port = "${graphite_listen_port}"
399-
$_listen_port = "${listen_port}"
400-
$_pup_port = "${pup_port}"
401-
$_syslog_port = "${syslog_port}"
402-
# lint:endignore
403-
404-
validate_legacy(String, 'validate_re', $_dogstatsd_port, '^\d*$')
405-
validate_legacy(String, 'validate_re', $_statsd_forward_port, '^\d*$')
406-
validate_legacy(String, 'validate_re', $_graphite_listen_port, '^\d*$')
407-
validate_legacy(String, 'validate_re', $_listen_port, '^\d*$')
408-
validate_legacy(String, 'validate_re', $_pup_port, '^\d*$')
409-
validate_legacy(String, 'validate_re', $_syslog_port, '^\d*$')
410-
411390
if $conf_dir == undef {
412391
if $_agent_major_version == 5 {
413392
$_conf_dir = $datadog_agent::params::legacy_conf_dir
@@ -571,7 +550,7 @@
571550
require => File['/etc/dd-agent'],
572551
}
573552

574-
if ($dd_url == '') {
553+
if $dd_url.empty {
575554
$_dd_url = 'https://app.datadoghq.com'
576555
} else {
577556
$_dd_url = $dd_url
@@ -599,7 +578,7 @@
599578
order => '05',
600579
}
601580

602-
if ($extra_template != '') {
581+
unless $extra_template.empty {
603582
concat::fragment{ 'datadog extra_template footer':
604583
target => '/etc/dd-agent/datadog.conf',
605584
content => template($extra_template),
@@ -677,12 +656,12 @@
677656
},
678657
}
679658
}
680-
if $host != '' {
659+
if $host.empty {
660+
$host_config = {}
661+
} else {
681662
$host_config = {
682663
'hostname' => $host,
683664
}
684-
} else {
685-
$host_config = {}
686665
}
687666

688667
if $apm_analyzed_spans {
@@ -705,19 +684,19 @@
705684
$apm_obfuscation_config = {}
706685
}
707686

708-
if $statsd_forward_host != '' {
709-
if $_statsd_forward_port != '' {
687+
if $statsd_forward_host.empty {
688+
$statsd_forward_config = {}
689+
} else {
690+
if String($statsd_forward_port).empty {
710691
$statsd_forward_config = {
711692
'statsd_forward_host' => $statsd_forward_host,
712-
'statsd_forward_port' => $statsd_forward_port,
713693
}
714694
} else {
715695
$statsd_forward_config = {
716696
'statsd_forward_host' => $statsd_forward_host,
697+
'statsd_forward_port' => $statsd_forward_port,
717698
}
718699
}
719-
} else {
720-
$statsd_forward_config = {}
721700
}
722701

723702
if $additional_checksd {

metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dependencies": [
1111
{
1212
"name": "puppetlabs/stdlib",
13-
"version_requirement": ">=4.24.0 <9.0.0"
13+
"version_requirement": ">=4.25.0 <9.0.0"
1414
},
1515
{
1616
"name": "puppetlabs/ruby",

templates/datadog_footer.conf.erb

+12-12
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ recent_point_threshold: <%= @recent_point_threshold %>
2121
<% end -%>
2222

2323
# Change port the Agent is listening to
24-
<% if @_listen_port.empty? -%>
24+
<% if @listen_port.to_s.empty? -%>
2525
# listen_port: 17123
2626
<% else -%>
27-
listen_port: <%= @_listen_port %>
27+
listen_port: <%= @listen_port %>
2828
<% end -%>
2929

3030
# Start a graphite listener on this port
31-
<% if @_graphite_listen_port.empty? -%>
31+
<% if @graphite_listen_port.to_s.empty? -%>
3232
# graphite_listen_port: 17124
3333
<% else -%>
34-
graphite_listen_port: <%= @_graphite_listen_port %>
34+
graphite_listen_port: <%= @graphite_listen_port %>
3535
<% end -%>
3636

3737
# Additional directory to look for Datadog checks
@@ -71,10 +71,10 @@ bind_host: <%= @bind_host %>
7171

7272
use_pup: <%= @use_pup ? "yes" : "no" %>
7373

74-
<% if @_pup_port.empty? -%>
74+
<% if @pup_port.to_s.empty? -%>
7575
# pup_port: 17125
7676
<% else -%>
77-
pup_port: <%= @_pup_port %>
77+
pup_port: <%= @pup_port %>
7878
<% end -%>
7979

8080
<% if @pup_interface.empty? -%>
@@ -100,10 +100,10 @@ use_dogstatsd: <%= @use_dogstatsd ? "yes" : "no" %>
100100
# usage information, check out http://api.datadoghq.com
101101

102102
# Make sure your client is sending to the same port.
103-
<% if @_dogstatsd_port.empty? -%>
103+
<% if @dogstatsd_port.to_s.empty? -%>
104104
# dogstatsd_port: 8125
105105
<% else -%>
106-
dogstatsd_port: <%= @_dogstatsd_port %>
106+
dogstatsd_port: <%= @dogstatsd_port %>
107107
<% end -%>
108108

109109
# By default dogstatsd will post aggregate metrics to the Agent (which handles
@@ -137,10 +137,10 @@ histogram_percentiles: <%= @statsd_histogram_percentiles %>
137137
<% else -%>
138138
statsd_forward_host: <%= @statsd_forward_host %>
139139
<% end -%>
140-
<% if @_statsd_forward_port.empty? -%>
140+
<% if @statsd_forward_port.to_s.empty? -%>
141141
# statsd_forward_port: 8125
142142
<% else -%>
143-
statsd_forward_port: <%= @_statsd_forward_port %>
143+
statsd_forward_port: <%= @statsd_forward_port %>
144144
<% end -%>
145145

146146
# ========================================================================== #
@@ -277,10 +277,10 @@ log_to_syslog: <%= @log_to_syslog ? "yes" : "no" %>
277277
syslog_host: <%= @syslog_host %>
278278
<% end -%>
279279

280-
<% if @_syslog_port.empty? -%>
280+
<% if @syslog_port.to_s.empty? -%>
281281
# syslog_port:
282282
<% else -%>
283-
syslog_port: <%= @_syslog_port %>
283+
syslog_port: <%= @syslog_port %>
284284
<% end -%>
285285

286286

templates/datadog_header.conf.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dd_url: <%= @_dd_url %>
1111
<% else -%>
1212
proxy_host: <%= @proxy_host %>
1313
<% end -%>
14-
<% if !defined?(@proxy_port) || "#{@proxy_port}".empty? -%>
14+
<% if !defined?(@proxy_port) || @proxy_port.to_s.empty? -%>
1515
# proxy_port:
1616
<% else -%>
1717
proxy_port: <%= @proxy_port %>

0 commit comments

Comments
 (0)