Issue #2033 has been updated by Brice Figureau.

Status changed from Accepted to Ready for Testing
% Done changed from 0 to 100
Complexity changed from Unknown to Medium


----------------------------------------
Feature #2033: Regex matching in 'if' statements.
http://projects.reductivelabs.com/issues/2033

Author: Trevor Vaughan
Status: Ready for Testing
Priority: Low
Assigned to: Brice Figureau
Category: newfeature
Target version: unplanned
Complexity: Medium
Affected version: 0.24.6
Keywords: if, regex


Now that the if/else constructor has more powerful types (>, <, etc...) it 
would be nice to go one step further and include the "=~" operator for regular 
expression matching.

For example:

if $foo =~ /*.bar\.com$/ {
  notice("I found bar!")
}
else {
  notice("No bars :-(")
}

There is a workaround for doing this now using either custom functions or 
templates, but it's a huge hack and probably shouldn't be used.

Workaround:

if template("parse.erb") == "bar.com\n" {
  notice("I found bar!")
}
else {
  notice("No bars :-(")
}

--- parse.erb ---
<% if foo =~ /*.bar\.com$/ then %>bar.com<% else %>default<% end %>
--- end parse.erb ---


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://reductivelabs.com/redmine/my/account

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to