Skip to content

Commit

Permalink
Don't fail if first element of is not an hash before flattening
Browse files Browse the repository at this point in the history
The template is using [@rewrites].flatten.compact which maps to Puppet's delete_undef_values(flatten([]))
  • Loading branch information
sathieu committed Nov 22, 2016
1 parent 2d70ca8 commit 4222c50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion manifests/vhost.pp
Expand Up @@ -192,7 +192,8 @@
if $rewrites {
validate_array($rewrites)
unless empty($rewrites) {
validate_hash($rewrites[0])
$rewrites_flattened = delete_undef_values(flatten([$rewrites]))
validate_hash($rewrites_flattened[0])
}
}

Expand Down
2 changes: 1 addition & 1 deletion templates/vhost/_rewrite.erb
Expand Up @@ -5,7 +5,7 @@
RewriteBase <%= @rewrite_base %>
<%- end -%>
<%- [@rewrites].flatten.compact.each do |rewrite_details| -%>
<%- @rewrites_flattened.each do |rewrite_details| -%>
<%- if rewrite_details['comment'] -%>
#<%= rewrite_details['comment'] %>
<%- end -%>
Expand Down

0 comments on commit 4222c50

Please sign in to comment.