Netcentric / vault-upgrade-hook

Jackrabbit FileVault Install Hook to perform additional actions during package installation
Eclipse Public License 1.0
19 stars 13 forks source link

Allow to parameterize scripts via bindings #46

Open kwin opened 4 years ago

kwin commented 4 years ago

It would be nice to pass properties from the hook to all contained scripts (e.g. to influence the root node from which to start). Otherwise this information has to be repeated in all contained scripts. For Groovy/Scripting and Sling Pipes one can use bindings for that. I would suggest that nested properties with a specific name are created as bindings automatically

nc-andreashaller commented 4 years ago

EDIT: if you are using GroovyConsole script you can set a property data on the parent node of the scripts. The content is interpreted as Json and added to the script as a binding:

package definition

vtl:definition
  - upgrader
      - your_script_folder
          - properties:
              - handler=groovyconsole
              - data={"myBinding":"custom-value"}
          - script0.groovy

script0.groovy

println data.myBinding

Still we should find a way for the other handlers and document the above properly.

~~very good point, in GroovyConsole scripts there is already a workaround for that: With slingRequest['scriptPath'] you can access the path of the current script and with that information you can read properties of that node or the parent node via normal means~~

But you are totally right, a more elegant solution for that would be awesome.