nutanix / calm-dsl

Keep Calm and DSL On!
https://nutanix.github.io/calm-dsl/
Apache License 2.0
33 stars 51 forks source link

Add new interface for Task inside variables #173

Open abhijeetkaurav1st opened 3 years ago

abhijeetkaurav1st commented 3 years ago

Right now, CalmTask is supported inside variables. Even in Runbook, we need to import CalmTask for runbook dynanic variables. Ex:

from calm.dsl.runbooks import runbook, runbook_json
from calm.dsl.runbooks import RunbookTask, RunbookVariable as Variable
from calm.dsl.builtins import CalmTask
@runbook
def DslCommunityRunbook():
    ntnx_calm_object = Variable.WithOptions.FromTask(
        CalmTask.HTTP.get(
            "https://api.github.com/repos/nutanixdev/calm-community/contents/",
            content_type="application/json",
            verify=True,
            status_mapping={200: True},
            response_paths={"ntnx_calm_object": "$[?(@.type == 'dir')].name"},
        ),
        is_mandatory=True,
    )
    RunbookTask.Exec.escript(script="print '0'")

Here both type of Task are used. It is creating confusion. Create a diff interface VariableTask that should be used for task inside variable always.

Also restrict the scope of VariableTask that contain tasks that can be used inside variable i.e. HTTP, escript