aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2021-11-16 14:46:24 -0800
committerMike Crute <mike@crute.us>2021-11-17 07:56:10 -0800
commitcc58a3da7d647de8520e33dc4356672d2ed1a366 (patch)
tree1b232a0d51446eb6370cfb13932190d31ce053df /main.go
parenta42d794a286154a3106551e6e483861af2a9ef16 (diff)
downloadcloud-identity-broker-cc58a3da7d647de8520e33dc4356672d2ed1a366.tar.bz2
cloud-identity-broker-cc58a3da7d647de8520e33dc4356672d2ed1a366.tar.xz
cloud-identity-broker-cc58a3da7d647de8520e33dc4356672d2ed1a366.zip
Import of source code
Diffstat (limited to 'main.go')
-rw-r--r--main.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..f262847
--- /dev/null
+++ b/main.go
@@ -0,0 +1,45 @@
1package main
2
3import (
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
18var embeddedTemplates embed.FS
19
20func 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}