/
commands.go
60 lines (50 loc) · 1.56 KB
/
commands.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
package main
import (
"fmt"
"github.com/apcera/termtables"
)
func CallGetAllProjects(username, password, bamboo_url string) {
cred := new(credentials)
cred.baseurl = bamboo_url
cred.username = username
cred.password = password
allProjects := getAllProjects(*cred)
table := termtables.CreateTable()
table.AddHeaders("Name", "Key", "Link")
if len(allProjects) != 0 {
for _, proj := range allProjects {
table.AddRow(proj.Name, proj.Key, proj.Link.Href)
}
}
fmt.Println(table.Render())
}
func CallGetAllPlansInProject(username, password, bamboo_url, project_name string) {
cred := new(credentials)
cred.baseurl = bamboo_url
cred.username = username
cred.password = password
allPlans := getAllPlansInProject(*cred, project_name)
table := termtables.CreateTable()
table.AddHeaders("Name", "Key", "Active", "Building", "Stages", "Branches", "Link")
if len(allPlans.Plans) != 0 {
for _, pl := range allPlans.Plans {
table.AddRow(pl.BuildName, pl.Key, pl.IsActive, pl.IsBuilding, pl.Stages.Size, pl.Branches.Size, pl.Link.Href)
}
}
fmt.Println(table.Render())
}
func CallGetAllBranches(username, password, bamboo_url, plan_key string) {
cred := new(credentials)
cred.baseurl = bamboo_url
cred.username = username
cred.password = password
allBranches := getAllBranches(*cred, plan_key)
table := termtables.CreateTable()
table.AddHeaders("Name", "Enabled", "Key", "Link")
if len(allBranches.AllBranch) != 0 {
for _, br := range allBranches.AllBranch {
table.AddRow(br.Shortname, br.Enabled, br.Key, br.Link.Href)
}
}
fmt.Println(table.Render())
}