Complete project pivot (#55)

Complete project pivot
This commit is contained in:
2022-01-12 08:57:21 +01:00
committed by GitHub
parent 70aa5332a9
commit bd581db472
46 changed files with 2638 additions and 1396 deletions

28
pkg/portal/command.go Normal file
View File

@@ -0,0 +1,28 @@
package portal
import (
"context"
"os/exec"
"strings"
"github.com/apex/log"
"github.com/speedrunsh/speedrun/proto/portal"
)
func (s *Server) RunCommand(ctx context.Context, in *portal.CommandRequest) (*portal.CommandResponse, error) {
fields := log.Fields{
"context": "command",
}
log := log.WithFields(fields)
log.Debugf("Received command: %s %s", in.GetName(), in.GetArgs())
cmd := exec.Command(in.GetName(), in.GetArgs()...)
stdout, err := cmd.CombinedOutput()
if err != nil {
log.Error(err.Error())
return nil, err
}
return &portal.CommandResponse{Message: strings.TrimSpace(string(stdout))}, nil
}