[jboss-jira] [JBoss JIRA] (WFCORE-1469) Support match-comparison operation for if-command

Thomas Darimont (JIRA) issues at jboss.org
Tue Apr 12 18:07:00 EDT 2016


     [ https://issues.jboss.org/browse/WFCORE-1469?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Darimont updated WFCORE-1469:
------------------------------------
    Description: 
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:

{code}
-Dfeatures="activemq jgroups"
{code}

{code}
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
{code}

Example:
{code}
-Dfeatures="feature1 feature2"

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

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

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

  was:
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:

{code}
-Dfeatures="activemq jgroups"
{code}

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

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

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

Example:
{code}
-Dfeatures="feature1 feature2"

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

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

[default at local:9990 /] if (features ~= ".*feature3.*") of /:resolve-expression(expression=${features})
[default at local:9990 /] echo configuring feature3
[default at local:9990 /] end-if
[default at local:9990 /]
{code}



> Support match-comparison operation for if-command
> -------------------------------------------------
>
>                 Key: WFCORE-1469
>                 URL: https://issues.jboss.org/browse/WFCORE-1469
>             Project: WildFly Core
>          Issue Type: Feature Request
>          Components: CLI
>            Reporter: Thomas Darimont
>            Assignee: Alexey Loubyansky
>            Priority: Minor
>
> 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:
> {code}
> -Dfeatures="activemq jgroups"
> {code}
> {code}
> 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
> {code}
> Example:
> {code}
> -Dfeatures="feature1 feature2"
> [default at local:9990 /] if (result ~= ".*feature1.*") of /:resolve-expression(expression=${features})
> [default at local:9990 /] echo configuring feature1
> [default at local:9990 /] end-if
> configuring feature1
> [default at local:9990 /] if (result ~= ".*feature2.*") of /:resolve-expression(expression=${features})
> [default at local:9990 /] echo configuring feature2
> [default at local:9990 /] end-if
> configuring feature2
> [default at local:9990 /] if (result ~= ".*feature3.*") of /:resolve-expression(expression=${features})
> [default at local:9990 /] echo configuring feature3
> [default at local:9990 /] end-if
> [default at local:9990 /]
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list