This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
main.go
121 lines (107 loc) · 2.76 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
package main
import (
"fmt"
"os"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
"github.com/flanksource/karina/cmd"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
var root = &cobra.Command{
Use: "karina",
PersistentPreRun: cmd.GlobalPreRun,
}
root.AddCommand(
cmd.Access,
cmd.APIDocs,
cmd.Apply,
cmd.Backup,
cmd.BurninController,
cmd.CA,
cmd.Terminate,
cmd.Cleanup,
cmd.Config,
cmd.Conformance,
cmd.Consul,
cmd.Dashboard,
cmd.DB,
cmd.Deploy,
cmd.DNS,
cmd.Exec,
cmd.ExecNode,
cmd.Harbor,
cmd.Images,
cmd.Logs,
cmd.MachineImages,
cmd.Namespace,
cmd.Node,
cmd.NSX,
cmd.Operator,
cmd.Orphan,
cmd.Provision,
cmd.Render,
cmd.Report,
cmd.Rolling,
cmd.Seal,
cmd.Snapshot,
cmd.Status,
cmd.Test,
cmd.TerminateNodes,
cmd.TerminateOrphans,
cmd.Undelete,
cmd.Unseal,
cmd.Upgrade,
cmd.Vault,
)
if len(commit) > 8 {
version = fmt.Sprintf("%v, commit %v, built at %v", version, commit[0:8], date)
}
root.AddCommand(&cobra.Command{
Use: "version",
Short: "Print the version of karina",
Args: cobra.MinimumNArgs(0),
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version)
},
})
docs := &cobra.Command{
Use: "docs",
Short: "generate documentation",
}
docs.AddCommand(&cobra.Command{
Use: "cli [PATH]",
Short: "generate CLI documentation",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
err := doc.GenMarkdownTree(root, args[0])
if err != nil {
log.Fatal(err)
}
},
})
docs.AddCommand(cmd.APIDocs)
root.AddCommand(docs)
config := "karina.yml"
if env := os.Getenv("PLATFORM_CONFIG"); env != "" {
config = env
}
root.PersistentFlags().StringArrayP("config", "c", []string{config}, "Path to config file")
root.PersistentFlags().StringArrayP("extra", "e", nil, "Extra arguments to apply e.g. -e ldap.domain=example.com")
root.PersistentFlags().StringP("kubeconfig", "", "", "Specify a kubeconfig to use, if empty a new kubeconfig is generated from master CA's at runtime")
root.PersistentFlags().CountP("loglevel", "v", "Increase logging level")
root.PersistentFlags().Bool("prune", true, "Delete previously enabled resources")
root.PersistentFlags().Bool("skip-decrypt", false, "Skip any phases requiring decryption")
root.PersistentFlags().Bool("dry-run", false, "Don't apply any changes, print what would have been done")
root.PersistentFlags().Bool("trace", false, "Print out generated specs and configs")
root.PersistentFlags().Bool("in-cluster", false, "Use in cluster kubernetes config")
root.SetUsageTemplate(root.UsageTemplate() + fmt.Sprintf("\nversion: %s\n ", version))
if err := root.Execute(); err != nil {
os.Exit(1)
}
}