Uploaded image for project: 'WildFly Core'
  1. WildFly Core
  2. WFCORE-1469

Support match-comparison operation for if-command

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Minor Minor
    • 2.2.0.CR1, 3.0.0.Alpha1
    • None
    • CLI
    • None

      Conditional expressions are great help for creating generic wildfly configurations with the CLI.
      Currently the comparison-operations for the if-expression are limited to

      • equal (==)
      • not equal (!=)
      • lesser than (<)
      • not lesser than (>=)
      • greater than (>)
      • not greater than (<=)

      I'd propose an additional comparison operation: a regex based match operation with the symbol ~=
      wheras the left operand is a string to match against the right operand which is a regex string.

      This would enable a simple way to do feature flag detection via partial regex matches.

      The following sequence demonstrates this use case:

      -Dfeatures="activemq jgroups"
      
      if (result ~= ".*activemq.*") of /:resolve-expression(expression=${features})
      echo configuring activemq
      end-if
      
      if (result ~= ".*jgroups.*") of /:resolve-expression(expression=${features})
      echo configuring jgroups
      end-if
      
      if (result ~= ".*postgres.*") of /:resolve-expression(expression=${features})
      echo configuring postgres
      end-if
      

      Example:

      -Dfeatures="feature1 feature2"
      
      [default@local:9990 /] if (result ~= ".*feature1.*") of /:resolve-expression(expression=${features})
      [default@local:9990 /] echo configuring feature1
      [default@local:9990 /] end-if
      configuring feature1
      
      [default@local:9990 /] if (result ~= ".*feature2.*") of /:resolve-expression(expression=${features})
      [default@local:9990 /] echo configuring feature2
      [default@local:9990 /] end-if
      configuring feature2
      
      [default@local:9990 /] if (result ~= ".*feature3.*") of /:resolve-expression(expression=${features})
      [default@local:9990 /] echo configuring feature3
      [default@local:9990 /] end-if
      [default@local:9990 /]
      

              olubyans@redhat.com Alexey Loubyansky
              thomas.darimont@googlemail.com Thomas Darimont (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: