CloudSlang / cloud-slang

CloudSlang Language, CLI and Builder
http://cloudslang.io
Apache License 2.0
236 stars 82 forks source link

Advanced navigation #569

Open levice14 opened 8 years ago

levice14 commented 8 years ago

we want to be able to define custom navigation logic on task level

e.g. we had this problem when ssh op became flow and we wanted to define custom results for ssh_flow based on outputs, will be handy with switch construct

levice14 commented 8 years ago
navigate:
- rule1
- rule2
- SUCCESS: success_step
or
- SUCCESS:
    condition: ${ boolean_expression }
    target: task_name

Open questions:

notes:

levice14 commented 8 years ago

sample files - consider nav_op operation with results SUCCESS / FAILURE and nav_flow flow:

flow:
  name: nav_flow

  workflow:
    - task_legacy: # current syntax
        do:
          nav_op: []
        navigate:
          SUCCESS: success_step
          FAILURE: failure_step

    # equivalent with new syntax:

    - task_results_legacy_in_new_format:
        do:
          nav_op: []
        navigate:
          - SUCCESS: success_step
          - FAILURE: failure_step

    # custom rules
    - task_custom_rules:
        do:
          nav_op: []
        navigate:
          - SUCCESS_RESULT:
              condition: ${ boolean_expression }
              target: task_name
          - SUCCESS: task_name # operation ended with SUCCESS
          # note FAILURE result from operation does not need to be declared here
          - CUSTOM_1:
              condition: ${ subflow_output == 'expected output' and flow_input == 'expected input' }
              target: FLOW_RESULT
          - DEFAULT:
              condition: true # boolean value
              target: task_name
levice14 commented 8 years ago

@CloudSlang/slang-functional-reviewers please give feedback

meshipeer commented 8 years ago

i think we might need here special syntax to get the result name, for cases i want a condition like: result[SUCCESS] && output(output1) == '400'

levice14 commented 8 years ago

I think the solution for that is to reserve a word that will hold the subflow result - e.g. ${ result == 'SUCCESS' && output(output1) == '400' }