In a systemFilter, I'd like to search across multiple fabrics with a pattern for the mountPoint. For instance, I have dozens of mountPoints, tagged as "webserver", some are tagged with "production" and and some tagged with "staging" also. Inside this set, I only want to target mountPoints that are /server/w*
Is it possible to do something like this:
Or something like:
Is this possible to do? If its not currently possible, how could I go about doing something like this?
Unfortunately at this time, regular expression is not supported in the filter syntax. Besides changing the code to support it I would suggest tagging your entries with what you want to filter on. In your last example it seems that you have some "test" mountPoints, so you could add "test" tag...
I didn't realize you could inject your own groovy filter code. I'm not very familiar with groovy at all, but looking at some of the documentation, there's a "matches()" method which supports "patterns" (these are standard regexps I believe?)
So, this actually appears to do what I want (from my limited testing).
The regexps are pretty ugly, but such is the live of a regexp :)
It appears to take all sorts of valid regexps. It looks as though I can put the c() functions in any "and" "or" or "not" block. This appears to be exactly what I need, do you see any "gotchas" with this approach? Or anything that I'm missing?
I am glad that it works. I think the only huge gotcha I can think of is that the closure is executed for every single entry in your model... so the regexps are going to be recompiled for every entry in your model. So it will definitely work but it might be slow if your models are big. Unfortunately there is no way around it at this stage as the filter syntax does not let you define a variable for example (which sounds like a cool feature to add :). At this stage I would suggest testing it on your typical model and see how it behaves.