bartavelle / language-puppet

A library to work with Puppet manifests, test them and eventually replace everything ruby.
BSD 3-Clause "New" or "Revised" License
51 stars 8 forks source link

Accessing a nonexistent key from a hash throws a warning #160

Closed jfroche closed 8 years ago

jfroche commented 8 years ago

example here (gpgkey does not exists in the hash):

$gpgkey = $this_repository["gpgkey"]

we get the following warning:

WARNING: q_docker: Look up for an hash with the unknown key 'gpgkey' for {  baseurl => http://download.draios.com/stable/rpm/$basearch,
descr   => Draios repository containing sysdig} at ./modules/profile/manifests/repositories/hiera.pp

which forces us to write to avoid the warning:

if has_key($this_repository, 'gpgkey') {
  $gpgkey = $this_repository['gpgkey']
} else {
  $gpgkey = undef
}

even with strict: false

bartavelle commented 8 years ago

This is the intended behavior! With strict you get an error.

jfroche commented 8 years ago

Ok fair enough. Thank you for your fast answer