diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -0,0 +1,45 @@ | |||
1 | package main | ||
2 | |||
3 | import ( | ||
4 | "embed" | ||
5 | "io/fs" | ||
6 | "log" | ||
7 | |||
8 | "code.crute.us/mcrute/cloud-identity-broker/cmd/web" | ||
9 | |||
10 | "github.com/spf13/cobra" | ||
11 | |||
12 | // Import backup data. By default zoneinfo is installed in the docker image | ||
13 | // if something breaks this will still result in us having correct TZ info. | ||
14 | _ "time/tzdata" | ||
15 | ) | ||
16 | |||
17 | //go:embed templates | ||
18 | var embeddedTemplates embed.FS | ||
19 | |||
20 | func main() { | ||
21 | rootCmd := &cobra.Command{ | ||
22 | Use: "cloud-identity-broker", | ||
23 | Short: "Identity broker for cloud account access", | ||
24 | } | ||
25 | |||
26 | rootCmd.PersistentFlags().Bool("debug", false, "Enable debug mode") | ||
27 | rootCmd.PersistentFlags().String("template-glob", "*.tpl", "Glob to match templates") | ||
28 | rootCmd.PersistentFlags().String("template-path", "templates/", "Path where site files are located") | ||
29 | rootCmd.PersistentFlags().String("mongodb-uri", "", "URI for connection to mongodb") | ||
30 | rootCmd.PersistentFlags().String("mongodb-vault-path", "", "Database path for mongodb vault credentials") | ||
31 | rootCmd.PersistentFlags().Bool("disable-bg-jobs", false, "Disable background jobs and only serve web pages") | ||
32 | |||
33 | // This is here because the trimmed prefix must match the embed prefix | ||
34 | // above and there's no need to bury it and de-couple that relationship. | ||
35 | templates, err := fs.Sub(embeddedTemplates, "templates") | ||
36 | if err != nil { | ||
37 | log.Fatalf("Error building sub-fs of embeded fs") | ||
38 | } | ||
39 | |||
40 | web.Register(rootCmd, templates) | ||
41 | |||
42 | if err := rootCmd.Execute(); err != nil { | ||
43 | log.Fatalf("Error running root command: %s", err) | ||
44 | } | ||
45 | } | ||