/
main.go
46 lines (36 loc) · 1.32 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
package main
import (
"encoding/json"
"fmt"
"log"
"os"
"github.com/voelzmo/bosh-director-client/director"
)
type Arguments struct {
Target string
RootCAPath string
ClientName string
ClientSecret string
}
func main() {
args, err := parseArgs(os.Args)
if err != nil {
log.Fatal(err)
}
director := director.NewDirector(args.Target, args.RootCAPath, args.ClientName, args.ClientSecret)
prettyStatus, _ := json.MarshalIndent(director.Status(), "", " ")
fmt.Printf("The director status: '%s'\n", prettyStatus)
prettyLogin, _ := json.MarshalIndent(director.Login(), "", " ")
fmt.Printf("The director login: '%s'\n", prettyLogin)
prettyDeployments, _ := json.MarshalIndent(director.Deployments(), "", " ")
fmt.Printf("The director deployments: '%s'\n", prettyDeployments)
prettyTasks, _ := json.MarshalIndent(director.Tasks(), "", " ")
fmt.Printf("The director tasks: '%s'\n", prettyTasks)
}
func parseArgs(args []string) (Arguments, error) {
expectedNumberOfArgs := 5
if len(args) != expectedNumberOfArgs {
return Arguments{}, fmt.Errorf("parseArgs: Wrong number of arguments, expected %v, but got %v\nUsage: bosh-director-client <director URL> <root CA path> <oauth client name> <oauth client secret>", expectedNumberOfArgs-1, len(args)-1)
}
return Arguments{args[1], args[2], args[3], args[4]}, nil
}