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

Wrong behavior with selector in a `undef` case #130

Closed PierreR closed 9 years ago

PierreR commented 9 years ago

In this puppetlabs postgresql PR there is a specific request for this construct:

class application::role::pgserver {

  $postgis_version = undef
  $default_postgis_version = '2.1'
  $globals_postgis_version = $postgis_version ? {
    undef   => $default_postgis_version,
    default => $postgis_version,
  }
  notify {"global_postgis_version is ${globals_postgis_version} ":}
}

In this case, puppetresources will assign undef to $globals_postgis_version instead of the expected 2.1:

WARNING: pgserver_testing: Resolving the keyword `undef` to the string "undef" at ./modules/application/manifests/role/pgserver.pp
WARNING: pgserver_testing: Resolving the keyword `undef` to the string "undef" at ./modules/application/manifests/role/pgserver.pp
WARNING: pgserver_testing: Resolving the keyword `undef` to the string "undef" at ./modules/application/manifests/role/pgserver.pp
WARNING: pgserver_testing: Resolving the keyword `undef` to the string "undef" at ./modules/application/manifests/role/pgserver.pp
class {
  application::role::pgserver: # "./manifests/site.pp" (line 12, column 5) pgserver_testing [Scope []]
    ;
}
notify {
  global_postgis_version is undef : # "./modules/application/manifests/role/pgserver.pp" (line 9, column 11) pgserver_testing [Scope [class application::role::pgserver]]
}
bartavelle commented 9 years ago

should be fixed

PierreR commented 9 years ago

Looks good. Thanks for the quick fix.