Skip to content

Commit

Permalink
module
Browse files Browse the repository at this point in the history
  • Loading branch information
Lack30 committed Mar 14, 2024
1 parent 919001a commit 2b4306e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
env:
- GO111MODULE=on
before:
hooks:
- go mod tidy
#before:
# hooks:
# - go mod tidy
builds:
- binary: tengo
env:
Expand Down
4 changes: 2 additions & 2 deletions bee.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (rt *Runtime) run(ctx context.Context, host, shell string, opts ...RunOptio

if before, after, ok := strings.Cut(mname, "."); ok {
mname = before
args = append(args, after)
args = append([]string{after}, args...)
}
bm, ok := rt.modules.Find(mname)
if !ok {
Expand All @@ -180,7 +180,7 @@ func (rt *Runtime) run(ctx context.Context, host, shell string, opts ...RunOptio

cmd, err := bm.Execute(args...)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "parse command")
}

if !cmd.Runnable() {
Expand Down
6 changes: 3 additions & 3 deletions bee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
)

const hostText = `
host1 bee_host=192.168.2.32 bee_user=root bee_ssh_passwd=xxx
host1 bee_host=192.168.2.141 bee_user=root bee_ssh_passwd=xxx
localhost bee_connect=grpc bee_host=127.0.0.1 bee_port=15250 bee_platform=darwin bee_arch=arm64 bee_home=/tmp/bee
host2 bee_host=192.168.2.164 bee_connect=winrm bee_platform=windows bee_user=Administrator bee_home=C:\\Windows\\Temp\\bee
`
Expand Down Expand Up @@ -113,9 +113,9 @@ func Test_Runtime(t *testing.T) {
ctx := context.TODO()
options := make([]bee.RunOption, 0)
options = append(options, bee.WithRunSync(true))
options = append(options, bee.WithArgs(map[string]string{"hook": "http://127.0.0.1:5100"}))
options = append(options, bee.WithArgs(map[string]string{"hook": "http://127.0.0.1:5100", "a": "bbb"}))
inventory.AddSources(sources...)
data, err := rt.Execute(ctx, "host1", "ping", options...)
data, err := rt.Execute(ctx, "host1", "oracle.test option=sys/oracle@orcl", options...)
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 2 additions & 1 deletion module/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (c *Command) ParseCmd() *cobra.Command {
SilenceErrors: true,
SilenceUsage: true,
}
cmd.FParseErrWhitelist.UnknownFlags = true
flags := cmd.PersistentFlags()
for _, param := range c.Params {
pv := param.InitValue()
Expand Down Expand Up @@ -206,7 +207,7 @@ var DefaultRunCommand RunE = func(ctx *RunContext, opts ...client.ExecOption) ([
options = append(options, client.ExecWithEnv(key, value))
}

shell := fmt.Sprintf("%s %s %s", repl, script, strings.Join(args, " "))
shell := fmt.Sprintf("%s -import %s %s %s", repl, resolve, script, strings.Join(args, " "))
lg.Debug("remote execute", zap.String("command", shell))
cmd, err := conn.Execute(ctx, repl, options...)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ func TestRuntime_PlayWithService(t *testing.T) {
Name: "first task",
Id: "t1",
Action: "ping",
Args: map[string]any{},
Args: map[string]any{
"data": "xxx",
},
Catch: &process.Handler{
Name: "restart service",
Kind: "service",
Expand Down

0 comments on commit 2b4306e

Please sign in to comment.