-
Feature Request
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
Working on CLI scripts for the OpenShift images, I have found numerous limitations in the CLI control flow functionality. I am opening one issue just to record this, if work ever happens on this I think doing whatever as possible as separate (groups of) RFEs is reasonable.
The limitations in order of preference
Support if/else-if
At the moment it seems you can only do if/else. On its own this is not very useful, it would also need implementing of 'Combine expressions being tested for' or 'Support nested control structures'
Combine expressions being tested for
E.g I can do if (outcome == success && result=in-memory) of /subsystem=batch-jberet:read-attribute(name=default-job-repository). It would be good to be able to combine more than one of these along the lines of
if ((outcome == success) of /subsystem=batch-jberet:read-attribute(name=default-job-repository)) && ((result == 123) of /other=resource:read-attribute(name=some-attr))
*Support nested control structures
At the moment you can only have one level of each of if/for/try. For example the following is allowed:
for child in /some=resource:read-children-names(child-type=type) if (result == []) of /some=resource/type=\$child:read-children-names(child-type=some-type) try #do something end-try end-if done
But I cannot do:
if (outcome == success) of /some=resource:read-resource if (outcome == success) of /some=resource/child=thing:read-resource # do something end-if end-if
The same goes for for and try.
Variables
CLI allows you to use `set` to assign a variable. However, apart from substitution into paths and attribute values they are not very useful. It would be nice to be able to use them in if/for statements. It would also be nice to store the results of reads. Something along the lines of
set (myvar=result && outcome==success) of /some=resource:read-attribute(name=attr-name) if ($myvar==https) # do something else if ($myvar==http) # do something else else # another thing to do end-if
Array support
I have
for serverName in /subsystem=undertow:read-children-names(child-type=server) if (result == []) of /subsystem=undertow/server=\$serverName:read-children-names(child-type=https-listener)
But I am only able to check if the result is empty. I can't check if it for example contains the string 'https' as one of the entry. Also, apart from being empty we don't really have a way to know the length.