-
Notifications
You must be signed in to change notification settings - Fork 115
/
agent.go
50 lines (42 loc) · 1005 Bytes
/
agent.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package utils
import (
"os"
"os/exec"
"time"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
const (
agentID = "123-456-789"
)
type Agent struct {
ID string
tail *gexec.Session
}
func BuildAgent() error {
command := exec.Command("./build_agent.bash")
session, err := gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter)
if err != nil {
return err
}
gomega.Eventually(session, 40*time.Minute).Should(gexec.Exit(0))
return nil
}
func StartVagrant(provider string, osVersion string) (Agent, error) {
if len(provider) == 0 {
provider = "virtualbox"
}
command := exec.Command("./setup_vagrant.bash", provider)
command.Env = append(os.Environ(), "WINDOWS_OS_VERSION="+osVersion)
session, err := gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter)
if err != nil {
return Agent{}, err
}
gomega.Eventually(session, 40*time.Minute).Should(gexec.Exit(0))
return Agent{
ID: agentID,
}, nil
}
func (a Agent) Stop() {
}