Skip to content

Instantly share code, notes, and snippets.

@shaftoe
Created November 21, 2013 15:46
Show Gist options
  • Save shaftoe/7584009 to your computer and use it in GitHub Desktop.
Save shaftoe/7584009 to your computer and use it in GitHub Desktop.
My most hated Puppet code line ever
if($geo_cluster != '' and $stage_name != '' and exist_key($portal_config::config[$geo_cluster][$stage_name], "thomas_tomcat_fix") and $portal_config::config[$geo_cluster][$stage_name]["thomas_tomcat_fix"]) {
@lele85
Copy link

lele85 commented Nov 21, 2013

I'm not a rubyst so the syntax is plain wrong, but you can leverage "falsey" values and "short circuit evaluations"

$thomas_fix = $portal_config::config[$geo_cluster]
    && $portal_config::config[$geo_cluster][$stage_name]
    && $portal_config::config[$geo_cluster][$stage_name]["thomas_tomcat_fix"]

if ($thomas_fix){

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment