Merge pull request #570 from alixander/update-exec-hydrateopts
update exec hydrate opts
This commit is contained in:
commit
1531641a2f
1 changed files with 13 additions and 2 deletions
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"oss.terrastruct.com/util-go/xdefer"
|
"oss.terrastruct.com/util-go/xdefer"
|
||||||
|
|
@ -68,13 +69,23 @@ func (p execPlugin) Flags(ctx context.Context) (_ []PluginSpecificFlag, err erro
|
||||||
|
|
||||||
func (p *execPlugin) HydrateOpts(opts []byte) error {
|
func (p *execPlugin) HydrateOpts(opts []byte) error {
|
||||||
if opts != nil {
|
if opts != nil {
|
||||||
var execOpts map[string]string
|
var execOpts map[string]interface{}
|
||||||
err := json.Unmarshal(opts, &execOpts)
|
err := json.Unmarshal(opts, &execOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xmain.UsageErrorf("non-exec layout options given for exec")
|
return xmain.UsageErrorf("non-exec layout options given for exec")
|
||||||
}
|
}
|
||||||
|
|
||||||
p.opts = execOpts
|
allString := make(map[string]string)
|
||||||
|
for k, v := range execOpts {
|
||||||
|
switch vt := v.(type) {
|
||||||
|
case string:
|
||||||
|
allString[k] = vt
|
||||||
|
case int64:
|
||||||
|
allString[k] = strconv.Itoa(int(vt))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p.opts = allString
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue