Skip to content

Commit 597c887

Browse files
authored
Multiple fixes to Kafka, Consul, stdlib deprecations (#404)
* [kafka] adding Agent6 support * [consul][spec] adding more extensive tests * [functions] remove legacy validations * [manifest] more stdlib 4.24.0 deprecation fixes * [agent6] fix tagging. * [legacy] fix tests for older rubies * [apt][metadata] dropping lower bound to 2.4.0 for increased compatibility * [functions] fix typo in tag6, use variable in recursion
1 parent 3c008cb commit 597c887

34 files changed

Lines changed: 346 additions & 282 deletions

functions/tag6.pp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,27 @@ function datadog_agent::tag6(
66
Variant[Array, String] $tag_names,
77
Variant[String, Boolean] $lookup_fact = false,
88
) {
9-
if validate_legacy('Optional[Array]', 'is_array', $tag_names) {
9+
if $tag_names =~ Array {
1010
$tags = $tag_names.reduce([]) |$_tags , $tag| {
11-
concat($_tags, datadog_agent::tag6($tag, lookup_fact))
11+
concat($_tags, datadog_agent::tag6($tag, $lookup_fact))
12+
}
13+
} else {
14+
if $lookup_fact =~ String {
15+
$lookup = str2bool($lookup_fact)
16+
} else {
17+
$lookup = $lookup_fact
1218
}
13-
} elsif str2bool($lookup_fact) {
14-
$value = getvar($tag_names)
1519

16-
if validate_legacy('Optional[Array]', 'is_array', $value){
17-
$tags = prefix($value, "${tag_names}:")
20+
if $lookup {
21+
$value = getvar($tag_names)
22+
if $value =~ Array {
23+
$tags = prefix($value, "${tag_names}:")
24+
} else {
25+
$tags = [$tag_names]
26+
}
1827
} else {
1928
$tags = [$tag_names]
2029
}
21-
} else {
22-
$tags = [$tag_names]
2330
}
2431

2532
$tags

manifests/init.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@
525525
'dogstatsd_non_local_traffic' => $non_local_traffic,
526526
'log_file' => $agent6_log_file,
527527
'log_level' => $log_level,
528-
'tags' => union($_local_tags, $_facts_tags),
528+
'tags' => unique(flatten(union($_local_tags, $_facts_tags))),
529529
}
530530

531531
$agent_config = deep_merge($_agent_config, $extra_config)

manifests/integration.pp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66

77
include datadog_agent
88

9-
validate_array($instances)
10-
if $init_config != undef {
11-
validate_hash($init_config)
12-
}
13-
validate_string($integration)
9+
validate_legacy(Array, 'validate_array', $instances)
10+
validate_legacy(Optional[Hash], 'validate_hash', $init_config)
11+
validate_legacy(String, 'validate_string', $integration)
1412

1513
if !$::datadog_agent::agent5_enable {
1614
$dst = "${datadog_agent::conf6_dir}/${integration}.yaml"

manifests/integrations/apache.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
) inherits datadog_agent::params {
3636
include datadog_agent
3737

38-
validate_string($url)
39-
validate_array($tags)
40-
validate_bool($disable_ssl_validation)
38+
validate_legacy('String', 'validate_string', $url)
39+
validate_legacy('Array', 'validate_array', $tags)
40+
validate_legacy('Boolean', 'validate_bool', $disable_ssl_validation)
4141

4242
if !$::datadog_agent::agent5_enable {
4343
$dst = "${datadog_agent::conf6_dir}/apache.yaml"

manifests/integrations/cassandra.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
$tags = {},
3434
) inherits datadog_agent::params {
3535
require ::datadog_agent
36-
validate_hash($tags)
36+
37+
validate_legacy(Optional[Hash], 'validate_hash', $tags)
3738

3839
if !$::datadog_agent::agent5_enable {
3940
$dst = "${datadog_agent::conf6_dir}/cassandra.yaml"

manifests/integrations/ceph.pp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
# }
1515
#
1616
class datadog_agent::integrations::ceph(
17-
$tags = [ 'name:ceph_cluster' ],
18-
$ceph_cmd = '/usr/bin/ceph',
17+
Array $tags = [ 'name:ceph_cluster' ],
18+
String $ceph_cmd = '/usr/bin/ceph',
1919
) inherits datadog_agent::params {
2020
include datadog_agent
2121

22-
validate_array($tags)
22+
validate_legacy('Array', 'validate_array', $tags)
23+
validate_legacy('String', 'validate_string', $ceph_cmd)
2324

2425
file { '/etc/sudoers.d/datadog_ceph':
2526
content => "# This file is required for dd ceph \ndd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph\n"

manifests/integrations/consul.pp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
# }
2828
#
2929
class datadog_agent::integrations::consul(
30-
$url = 'http://localhost:8500',
31-
$catalog_checks = true,
32-
$network_latency_checks = true,
33-
$new_leader_checks = true,
34-
$service_whitelist = []
30+
String $url = 'http://localhost:8500',
31+
Boolean $catalog_checks = true,
32+
Boolean $network_latency_checks = true,
33+
Boolean $new_leader_checks = true,
34+
Optional[Array] $service_whitelist = []
3535
) inherits datadog_agent::params {
3636
include datadog_agent
3737

38-
validate_string($url)
39-
validate_bool($catalog_checks)
40-
validate_bool($new_leader_checks)
41-
validate_array($service_whitelist)
38+
validate_legacy('String', 'validate_string', $url)
39+
validate_legacy('Boolean', 'validate_bool', $catalog_checks)
40+
validate_legacy('Boolean', 'validate_bool', $new_leader_checks)
41+
validate_legacy('Optional[Array]', 'validate_array', $service_whitelist)
4242

4343
if !$::datadog_agent::agent5_enable {
4444
$dst = "${datadog_agent::conf6_dir}/consul.yaml"

manifests/integrations/directory.pp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@
5555
# }
5656

5757
class datadog_agent::integrations::directory (
58-
$directory = '',
59-
$filegauges = false,
60-
$recursive = true,
61-
$countonly = false,
62-
$nametag = '',
63-
$dirtagname = '',
64-
$filetagname = '',
65-
$pattern = '',
66-
$instances = undef,
58+
String $directory = '',
59+
Boolean $filegauges = false,
60+
Boolean $recursive = true,
61+
Boolean $countonly = false,
62+
String $nametag = '',
63+
String $dirtagname = '',
64+
String $filetagname = '',
65+
String $pattern = '',
66+
Optional[Array] $instances = undef,
6767
) inherits datadog_agent::params {
6868
include datadog_agent
6969

70-
validate_string($directory)
71-
validate_bool($filegauges)
72-
validate_bool($recursive)
73-
validate_bool($countonly)
70+
validate_legacy(String, 'validate_string', $directory)
71+
validate_legacy(Boolean, 'validate_bool', $filegauges)
72+
validate_legacy(Boolean, 'validate_bool', $recursive)
73+
validate_legacy(Boolean, 'validate_bool', $countonly)
7474

7575
if !$instances and $directory == '' {
7676
fail('bad directory argument and no instances hash provided')

manifests/integrations/disk.pp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# excluded_disk_re => '/dev/sd[e-z]*'
3333
# }
3434
class datadog_agent::integrations::disk (
35-
$use_mount = 'no',
35+
String $use_mount = 'no',
3636
$excluded_filesystems = undef,
3737
$excluded_disks = undef,
3838
$excluded_disk_re = undef,
@@ -42,9 +42,10 @@
4242
) inherits datadog_agent::params {
4343
include datadog_agent
4444

45-
validate_re($use_mount, '^(no|yes)$', "use_mount should be either 'yes' or 'no'")
46-
if $all_partitions {
47-
validate_re($all_partitions, '^(no|yes)$', "all_partitions should be either 'yes' or 'no'")
45+
validate_legacy('Optional[String]', 'validate_re', $all_partitions, '^(no|yes)$')
46+
47+
if $use_mount !~ '^(no|yes)$' {
48+
fail('error during compilation')
4849
}
4950

5051
if !$::datadog_agent::agent5_enable {

manifests/integrations/dns_check.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# }
2626
#
2727
class datadog_agent::integrations::dns_check (
28-
$checks = [
28+
Array $checks = [
2929
{
3030
'hostname' => 'google.com',
3131
'nameserver' => '8.8.8.8',
@@ -35,7 +35,7 @@
3535
) inherits datadog_agent::params {
3636
include datadog_agent
3737

38-
validate_array($checks)
38+
validate_legacy('Array', 'validate_array', $checks)
3939

4040
if !$::datadog_agent::agent5_enable {
4141
$dst = "${datadog_agent::conf6_dir}/dns_check.yaml"

0 commit comments

Comments
 (0)