bugy / script-server

Web UI for your scripts with execution management
Other
1.57k stars 248 forks source link

FEATURE : Dynamic params for the scripts #553

Closed PierreBarreau closed 2 years ago

PierreBarreau commented 2 years ago

Hi,

I don't know if someone as already asked for something similar (if yes I didn't found it). I would appreciate if it were possible to have some dynamism in the params we pass to the scripts.

For exemple, I want to remove some access rights on a device with a list of different protocols. I would have a first parameter as a list of devices and chosing one will display what can be removed from it (from the present one's). The device as the key and the services as a list of values associated to it.

I don't know if it's possible or not but maybe if we use a dict as the source for 2 different params we could have one depending on another.

muzzol commented 2 years ago

you can use the output of a script for your options. I use it a lot for lists.

PierreBarreau commented 2 years ago

Yes, I use it also. But I was looking for more dynamic second parameter.

Exemple: dict_of_vm = { "VM_1":["tom","luc","marc"],"VM_2":["omar","luc"],"VM_3":["françois","patricia"]}

Receiving this data, the keys would be displayed as a list of values and chosing one, for exemple "VM_2" will generate a list in a second parameter entry with the values associated to "VM_2".

bugy commented 2 years ago

Hi @PierreBarreau you can pass parameters to scripts dynamically. E.g. you can have

{
  parameters: [
    {
      "name": "devices",
      "type": "list",
      "values": [ "VM_1", "VM_2", "VM_3"]
    },
    {
      "name": "protocols",
      "type": "list",
      "values": { "script": "./get_protocols_for_device.sh ${devices}" }
    }
]}
PierreBarreau commented 2 years ago

Hi @bugy, thanks !! Maybe that's what you tried to explain me @muzzol but I didn't understood it

muzzol commented 2 years ago

yes, everytime a field changes, all value scripts are executed. @bugy maybe some additional info on the docs could help, because I've seen some repeated questions about scripts in parameters and dynamic values.