diff --git a/services/exec/client/utils.go b/services/exec/client/utils.go index 234af91f..6e3cd262 100644 --- a/services/exec/client/utils.go +++ b/services/exec/client/utils.go @@ -44,21 +44,7 @@ func ExecAsUser(user string) ExecRemoteOption { // // Deprecated: Use ExecRemoteCommandWithOpts instead. func ExecRemoteCommand(ctx context.Context, conn *proxy.Conn, binary string, args ...string) (*pb.ExecResponse, error) { - if len(conn.Targets) != 1 { - return nil, errors.New("ExecRemoteCommand only supports single targets") - } - - result, err := ExecRemoteCommandMany(ctx, conn, binary, args...) - if err != nil { - return nil, err - } - if len(result) < 1 { - return nil, fmt.Errorf("ExecRemoteCommand error: received empty response") - } - if result[0].Error != nil { - return nil, fmt.Errorf("ExecRemoteCommand error: %v", result[0].Error) - } - return result[0].Resp, nil + return ExecRemoteCommandWithOpts(ctx, conn, binary, args) } // ExecRemoteCommandWithOpts is a helper function for execing a command on a remote host with provided opts @@ -87,30 +73,16 @@ func ExecRemoteCommandWithOpts(ctx context.Context, conn *proxy.Conn, binary str // // // Deprecated: Use ExecRemoteCommandManyWithOpts instead. func ExecRemoteCommandMany(ctx context.Context, conn *proxy.Conn, binary string, args ...string) ([]*pb.RunManyResponse, error) { - c := pb.NewExecClientProxy(conn) - req := &pb.ExecRequest{ - Command: binary, - Args: args, - } - respChan, err := c.RunOneMany(ctx, req) - if err != nil { - return nil, err - } - result := make([]*pb.RunManyResponse, len(conn.Targets)) - for r := range respChan { - result[r.Index] = r - } - - return result, nil + return ExecRemoteCommandManyWithOpts(ctx, conn, binary, args) } // ExecRemoteCommandManyWithOpts is a helper function for execing a command on one or remote hosts with provided opts // using a proxy.Conn. // `binary` refers to the absolute path of the binary file on the remote host. func ExecRemoteCommandManyWithOpts(ctx context.Context, conn *proxy.Conn, binary string, args []string, opts ...ExecRemoteOption) ([]*pb.RunManyResponse, error) { - execOptions := execRemoteOptions{} + execOptions := &execRemoteOptions{} for _, opt := range opts { - opt(&execOptions) + opt(execOptions) } c := pb.NewExecClientProxy(conn)