Skip to content

Commit a57e338

Browse files
committed
Guard against undef $puppet_agent::collection
If `$puppet_agent::collection` was undef, then the regex match would result in an error: $ bundle exec puppet apply -e '$foo = undef if $foo =~ /core/ { }' Error: Evaluation Error: Left match operand must result in a String value. Got an Undef Value.
1 parent 7b7c991 commit a57e338

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

Diff for: manifests/osfamily/debian.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
ensure => absent,
6767
priority => '90',
6868
}
69-
} elsif $puppet_agent::collection =~ /core/ {
69+
} elsif $puppet_agent::collection and $puppet_agent::collection =~ /core/ {
7070
$source = 'https://apt-puppetcore.puppet.com'
7171
} else {
7272
$source = $puppet_agent::apt_source

Diff for: manifests/osfamily/redhat.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
} else {
6161
if $puppet_agent::collection == 'PC1' {
6262
$source = "${puppet_agent::yum_source}/${platform_and_version}/${puppet_agent::collection}/${puppet_agent::arch}"
63-
} elsif $puppet_agent::collection =~ /core/ {
63+
} elsif $puppet_agent::collection and $puppet_agent::collection =~ /core/ {
6464
$_collection = regsubst($puppet_agent::collection, /core/, '')
6565
$source = "https://yum-puppetcore.puppet.com/${_collection}/${platform_and_version}/${puppet_agent::arch}"
6666
} else {

Diff for: manifests/osfamily/suse.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
} else {
5151
if $puppet_agent::collection == 'PC1' {
5252
$source = "${puppet_agent::yum_source}/sles/${facts['os']['release']['major']}/${puppet_agent::collection}/${puppet_agent::arch}"
53-
} elsif $puppet_agent::collection =~ /core/ {
53+
} elsif $puppet_agent::collection and $puppet_agent::collection =~ /core/ {
5454
$_collection = regsubst($puppet_agent::collection, /core/, '')
5555
$source = "https://yum-puppetcore.puppet.com/${_collection}/sles/${facts['os']['release']['major']}/${puppet_agent::arch}"
5656
} else {

Diff for: manifests/osfamily/windows.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
} else {
2626
if $puppet_agent::collection == 'PC1' {
2727
$source = "${puppet_agent::windows_source}/windows/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-${puppet_agent::arch}.msi"
28-
} elsif $puppet_agent::collection =~ /core/ {
28+
} elsif $puppet_agent::collection and $puppet_agent::collection =~ /core/ {
2929
$source = 'https://artifacts-puppetcore.puppet.com/v1/download'
3030
$destination_name = "${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-${puppet_agent::arch}.msi"
3131
} else {

Diff for: manifests/prepare/package.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
$mode = '0644'
3939
}
4040

41-
if $puppet_agent::collection =~ /core/ and $facts['os']['family'] =~ /windows/ {
41+
if $puppet_agent::collection and $puppet_agent::collection =~ /core/ and $facts['os']['family'] =~ /windows/ {
4242
$download_username = getvar('puppet_agent::username', 'forge-key')
4343
$download_password = unwrap(getvar('puppet_agent::password'))
4444

0 commit comments

Comments
 (0)