-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
126 lines (99 loc) · 2.87 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package main
import (
"flag"
"fmt"
"net/http"
uuid "github.com/satori/go.uuid"
"github.com/335is/log"
"github.com/335is/octopus"
"github.com/335is/octoreport/internal/config"
)
const (
// AppName defines the prefix for any configuration environment variables, as in OCTOREPORT_OCTOPUS_ADDRESS
appName = "octoreport"
appVersion = "0.0.5"
)
var (
appInstance string
)
func init() {
appInstance = fmt.Sprintf("%s", uuid.NewV4())
}
func main() {
// command line flags
help := flag.Bool("help", false, "display usage of this program")
info := flag.Bool("info", false, "display information about this program")
cfg := flag.Bool("config", false, "display program configuration that was loaded")
server := flag.Bool("server", false, "display the Octopus server information")
appsec := flag.Bool("appsec", false, "display a CSV format report of users, teams, environments, roles")
report := flag.Bool("report", false, "display a report of all teams and their users/roles/environments/projects/project groups/tenants")
teams := flag.Bool("teams", false, "display all teams")
users := flag.Bool("users", false, "display all users")
roles := flag.Bool("roles", false, "display all user roles")
environments := flag.Bool("environments", false, "display all environments")
projectGroups := flag.Bool("projectgroups", false, "display all project groups")
projects := flag.Bool("projects", false, "display all projects")
tenants := flag.Bool("tenants", false, "display all tenants")
channels := flag.Bool("channels", false, "display all channels")
feeds := flag.Bool("feeds", false, "display all feeds")
lifecycles := flag.Bool("lifecycles", false, "display all lifecycles")
machines := flag.Bool("machines", false, "display all machines")
machineroles := flag.Bool("machineroles", false, "display all machineroles")
flag.Parse()
if *help {
flag.PrintDefaults()
}
if *info {
fmt.Printf("%s %s %s LOG_LEVEL=%s\n", appName, appVersion, appInstance, log.GetLevel().String())
}
c := config.New()
if *cfg {
fmt.Println(c.Dump())
}
client := octopus.New(c.Octopus.Address, c.Octopus.APIKey, &http.Client{})
if *server {
octopus.PrintServerReport(client)
}
if *appsec {
octopus.PrintAppsecReport(client)
}
if *report {
octopus.PrintTeamReport(client)
}
if *teams {
octopus.PrintTeams(client)
}
if *users {
octopus.PrintUsers(client)
}
if *roles {
octopus.PrintUserRoles(client)
}
if *environments {
octopus.PrintEnvironments(client)
}
if *projects {
octopus.PrintProjects(client)
}
if *projectGroups {
octopus.PrintProjectGroups(client)
}
if *tenants {
octopus.PrintTenants(client)
}
if *channels {
octopus.PrintChannels(client)
}
if *feeds {
octopus.PrintFeeds(client)
}
if *lifecycles {
octopus.PrintLifecycles(client)
}
if *machines {
octopus.PrintMachines(client)
}
if *machineroles {
octopus.PrintMachineRoles(client)
}
}