Merge pull request #570 from alixander/update-exec-hydrateopts

update exec hydrate opts
This commit is contained in:
Alexander Wang 2022-12-30 15:17:33 -08:00 committed by GitHub
commit 1531641a2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
} }