func GetCommand(hostURL *url.URL) cmd.Cmd { if hostURL.Host != "" { rc := cmd.NewSSH(hostURL.User.Username(), hostURL.Host) if err := rc.UseAgent(); err != nil { log.Fatal("Unable to use SSH agent for host: ", hostURL.String()) } return rc } return cmd.NewLocal() }
func TriggerHook(command string) error { if command == "" { return nil } log.Printf("Running hook: %s\n", command) args := strings.Fields(command) c := cmd.NewLocal() stdout, stderr, err := c.Run(args[0], args[1:]...) log.Println(stdout, stderr) return err }