upcmd / up

UP - Ultimate Provisioner CLI
https://upcmd.netlify.app/
MIT License
50 stars 4 forks source link

Expand variables in description #16

Closed ppiccolo closed 4 years ago

ppiccolo commented 4 years ago

1° Very nice tool !!!

I think that will be useful if variables can be expanded in description blocks too.

stephencheng commented 4 years ago

@ppiccolo This is now implemented:

Please follow this: (sorry doc site not updated yet) to run example of the case

https://github.com/upcmd/updocs/blob/master/content-src/quick-start/run_examples.md

Ξ /up-project/up git:(master) ▶ run_example c0177    
syntax: run_example case_file_name verbose_level
example:
  run_example c0033 v
  run_example c0033 vvv

loading [Config]:  ./tests/functests/upconfig.yml
Main config:
             Version -> 1.0.0
              RefDir -> ./tests/functests
             WorkDir -> cwd
          AbsWorkDir -> /up-project/up
            TaskFile -> c0177
             Verbose -> v
          ModuleName -> self
           ShellType -> /bin/sh
       MaxCallLayers -> 8
             Timeout -> 3600000
 MaxModuelCallLayers -> 256
work dir: /up-project/up
-exec task: task
loading [Task]:  ./tests/functests/c0177
module: [self], instance id: [nonamed], exec profile: []
Task1: [task ==> task: this is a story about tom
 ]
-Step1: [: tom is male
 ]
~SubStep1: [print: his age is 18
he is in school: sydney grammar
 ]
what gender is tom

The example source is located: https://github.com/upcmd/up/blob/master/tests/functests/c0177.yml

Please use the latest release or rolling release and let me know if it works for your case

ppiccolo commented 4 years ago

I'll give it a try on Tuesday, and let You know.

Tnx

ppiccolo commented 4 years ago

@stephencheng it' works on task description, but fail in yml validation if used in dvar description

ex:

  - name: CoreDestroy
    desc: Run terraform destroy core VM(s)
    task:
      - func: call
        dvars:
          - name: args
            value: "-var-file={{.terraform_common}} -auto-approve"
          - name: continue
            value: "N"
            desc: "Are you sure ? all items in {{.env}} infrastructure will be destroyed ! (yes/N)"
            flags: [prompt]
        do: essential.destroy
        if: '{{(eq .continue "yes")}}'
        else:
          - abort
stephencheng commented 4 years ago

@ppiccolo

Now the var rendering support for dvar desc is added, just use the latest or rolling release

Also, made the default value to be the one you configured, eg. "N" is used if there is no input value

You can run the case: https://github.com/upcmd/up/blob/master/tests/functests/c0177.yml

stephencheng commented 4 years ago

@ppiccolo FYI I just added a feature to make it optionally silent of the shell execution step/sub step

example is here:

https://github.com/upcmd/up/blob/master/tests/functests/c0180.yml

I think it would be much nicer to suppress some of the lengthy terraform output