package main import ( "embed" "io/fs" "log" "code.crute.us/mcrute/cloud-identity-broker/cmd/web" "github.com/spf13/cobra" // Import backup data. By default zoneinfo is installed in the docker image // if something breaks this will still result in us having correct TZ info. _ "time/tzdata" ) //go:embed templates var embeddedTemplates embed.FS var appVersion string func main() { rootCmd := &cobra.Command{ Use: "cloud-identity-broker", Short: "Identity broker for cloud account access", } rootCmd.PersistentFlags().Bool("debug", false, "Enable debug mode") rootCmd.PersistentFlags().String("template-glob", "*.tpl", "Glob to match templates") rootCmd.PersistentFlags().String("template-path", "templates/", "Path where site files are located") rootCmd.PersistentFlags().String("mongodb-uri", "", "URI for connection to mongodb") rootCmd.PersistentFlags().String("mongodb-vault-path", "", "Database path for mongodb vault credentials") rootCmd.PersistentFlags().Bool("disable-bg-jobs", false, "Disable background jobs and only serve web pages") // This is here because the trimmed prefix must match the embed prefix // above and there's no need to bury it and de-couple that relationship. templates, err := fs.Sub(embeddedTemplates, "templates") if err != nil { log.Fatalf("Error building sub-fs of embeded fs") } web.Register(rootCmd, templates, appVersion) if err := rootCmd.Execute(); err != nil { log.Fatalf("Error running root command: %s", err) } }