Open jfryman opened 8 years ago
We can write this out as a jinja pattern in cmd today, right?
cmd: --c {{c}} --d {{d}}
Does the cmd trick work for local-shell-script runner? I don't think the cmd parameter exists
@lakshmi-kannan @manasdk fwiw, I'm not immediately blocked. The "workaround" was to fix the underlying script.
I avoided using the cmd
jinja pattern hack as I think it's certainly an antipattern we need to watch carefully. It is supported (https://docs.stackstorm.com/runners.html?highlight=runner#runner-parameters). It is disjointed to have the ability to modify the kwargs_op
option, but not have one for the delimiter between keyword parameters. If anything, dropping to the cmd
and writing it out manually all but nullifies the need for kwargs_op
, since I could define it in the cmd
for that need as well.
How about we go with kwarg_pattern
whose value could take form --%s %s
, -%s=%s
, -%s %s
or --%s=%s
.
I am in fact suggesting an enum with a fixed list to avoid some weird shell injection.
I got bit by this today. I don't see a fix.
@powellchristoph I'm not certain a patch was added. Can you provide us an example of action parameters you were using and any relevant logs to make sure we're addressing the specific issue you saw.
My current understanding of the issue is this happens when we shell out to action container. If so we might can just take the work done in https://github.com/StackStorm/st2/pull/3976 and just only do parameter input via stdin.
/cc @Kami @lakshmi-kannan for some more context
@powellchristoph What @bigmstone said.
Can you please also share your exact use-case with us, what's the desired input & behavior (ideally a command line string of the arguments you want to pass to your script) and what problems do you have?
I have a simple bash script with named cli arguments that I am trying to use the local-shell-script
with. I was able to change the kwarg_op
seperator, but the runner still uses the =
to separate k/v items.
So alittle script like this below would be called from the command like like:
./script.sh -r foo -w /tmp -s server -c client
or
./script.sh -r foo -w /tmp
I don't want to use positional args, because they aren't all required.
#!/bin/bash
while getopts r:w:c:s:m: option
do
case "${option}" in
r) REGION=${OPTARG//=/};;
w) WORKDIR=${OPTARG//=/};;
s) SERVER="ParameterValue=${OPTARG//=/}";;
c) CLIENT="ParameterValue=${OPTARG//=/}";;
m) MANIFEST=${OPTARG//=/}
;;
esac
done
But using the following meta parameters. It gets passed by Stackstorm as
./script.sh -r=foo -w=/tmp -s=server -c=client
parameters:
w:
type: "string"
required: true
r:
type: "string"
required: true
s:
type: "string"
c:
type: "string"
m:
type: "string"
kwarg_op:
type: "string"
immutable: true
default: "-"
So now my args are passed to my script by getopts
as =value
and I have to use the ${OPTARG//=/}
to strip it off.
While assisting some users today, I ran into a problem with
optparse
. In a nutshell, parsing options is hard in Bash, so there are many tendencies to shortcut. One such example:Today, I can change the
kwargs_op
to any prefix I so desire. But, in all cases, the input is distilled to adict
, and then rendered as key-value pairs. (e.g.:--email=james@fryman.io
). This causes a failure with the above logic.This is not an uncommon pattern, and it would be good to be able to
s/=/ /
in the above parameter.