forked from vmware-archive/cf-sli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
64 lines (51 loc) · 1.48 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"encoding/json"
"flag"
"fmt"
"os"
uuid "github.com/nu7hatch/gouuid"
"github.com/pivotal-cloudops/cf-sli/cf_wrapper"
"github.com/pivotal-cloudops/cf-sli/config"
"github.com/pivotal-cloudops/cf-sli/logger"
"github.com/pivotal-cloudops/cf-sli/sli_executor"
)
type Output struct {
Route string `json:"app_route"`
StartTime float64 `json:"app_start_time_in_sec"`
StopTime float64 `json:"app_stop_time_in_sec"`
StartStatus int `json:"app_start_status"`
StopStatus int `json:"app_stop_status"`
}
func main() {
var config config.Config
var cf_cli cf_wrapper.CfWrapper
app_bits_path := flag.String("app-bits", "./assets/ruby_simple", "App bits path")
flag.Parse()
err := config.LoadConfig("./.config")
if err != nil {
fmt.Fprint(os.Stderr, "Failed to load .config :\n")
fmt.Fprint(os.Stderr, err)
fmt.Fprint(os.Stderr, "\n")
os.Exit(1)
}
guid, err := uuid.NewV4()
if err != nil {
panic(err)
}
app_name := "cf-sli-app-" + guid.String()[0:18]
sli_executor := sli_executor.NewSliExecutor(cf_cli, logger.NewLogger())
result, err := sli_executor.RunTest(app_name, *app_bits_path, config)
output := &Output{
Route: app_name + "." + config.Domain,
StartTime: result.StartTime.Seconds(),
StopTime: result.StopTime.Seconds(),
StartStatus: result.StartStatus,
StopStatus: result.StopStatus,
}
json_output, err := json.Marshal(output)
if err != nil {
panic(err)
}
fmt.Fprintf(os.Stdout, string(json_output))
}