Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

scripted included workflows able to use script from URL #127

Open
calum-github opened this issue Feb 12, 2016 · 3 comments
Open

scripted included workflows able to use script from URL #127

calum-github opened this issue Feb 12, 2016 · 3 comments

Comments

@calum-github
Copy link

If I have Workflow_1 which I want to run a script to determine if the included workflow should be Workflow_2 or Workflow_3

I was looking at scripted included workflows as per:https://github.com/grahamgilbert/imagr/wiki/Workflow-Config#scripted-included-workflows

eg.

<dict>
    <key>type</key>
    <string>included_workflow</string>
    <key>script</key>
    <string>#!/usr/bin/python
model = "{{machine_model}}"
if model.startswith("VMware"):
    print 'ImagrIncludedWorkflow: vmware_tools'
else:
    print 'ImagrIncludedWorkflow: no_vmware_tools'</string>
    </dict>

However, this means I need to embed the script into the XML, which means I need to escape any special characters such as &, this also means my script is now in a different location to my other scripts and version control becomes a bit tricky.

I tried referencing a URL as per regular scripts like this:

<dict>
          <key>type</key>
          <string>included_workflow</string>
          <key>type</key>
          <string>script</string>
          <key>url</key>
          <string>http://192.168.178.135/some_script.sh</string>
</dict>

But this failed, the included workflow was just ignored, likely because of the two type keys in the dict?

Is there any way to use a script at a URL to echo out the correct workflow name to run as an included workflow?

@grahamgilbert
Copy link
Collaborator

Not presently. I do consider this a bug though. The question is how to best handle it? I'm thinking it's best to just check for the presence of a <key>script_url</key>. E.g:

<dict>
          <key>type</key>
          <string>included_workflow</string>
          <key>script_url</key>
          <string>http://192.168.178.135/some_script.sh</string>
</dict>

As just using url implies we're looking for the URL of the workflow itself (and would screw us over if we ever were to include components from plists via a URL in the future).

@clburlison
Copy link
Contributor

At first I was going to recommend using the same format as you're already using for the scripts component however a second glance, that doesn't make complete sense to do so.

I think your proposed script_url key would be the best way to move forward. Leaving url free makes sense as @erikng already wanted that feature but he/I never finished it.

@grahamgilbert
Copy link
Collaborator

Bumping this one as help is still wanted.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants