diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 21 |
1 files changed, 7 insertions, 14 deletions
@@ -2,13 +2,13 @@ package main | |||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "embed" | 4 | "embed" |
5 | "io/fs" | ||
6 | "log" | 5 | "log" |
7 | 6 | ||
8 | "code.crute.us/mcrute/cloud-identity-broker/app" | 7 | "code.crute.us/mcrute/cloud-identity-broker/app" |
9 | "code.crute.us/mcrute/cloud-identity-broker/cmd/web" | 8 | "code.crute.us/mcrute/cloud-identity-broker/cmd/web" |
10 | 9 | ||
11 | "code.crute.us/mcrute/golib/cli" | 10 | "code.crute.us/mcrute/golib/cli" |
11 | "code.crute.us/mcrute/golib/fs" | ||
12 | 12 | ||
13 | "github.com/spf13/cobra" | 13 | "github.com/spf13/cobra" |
14 | 14 | ||
@@ -18,27 +18,20 @@ import ( | |||
18 | ) | 18 | ) |
19 | 19 | ||
20 | //go:embed templates | 20 | //go:embed templates |
21 | var embeddedTemplates embed.FS | 21 | var templates embed.FS |
22 | 22 | ||
23 | var appVersion string | 23 | var version string |
24 | 24 | ||
25 | func main() { | 25 | func main() { |
26 | rootCmd := &cobra.Command{ | 26 | r := &cobra.Command{ |
27 | Use: "cloud-identity-broker", | 27 | Use: "cloud-identity-broker", |
28 | Short: "Identity broker for cloud account access", | 28 | Short: "Identity broker for cloud account access", |
29 | } | 29 | } |
30 | cli.AddFlags(rootCmd, &app.Config{}, app.DefaultConfig, "") | 30 | cli.AddFlags(r, &app.Config{}, app.DefaultConfig, "") |
31 | 31 | ||
32 | // This is here because the trimmed prefix must match the embed prefix | 32 | web.Register(r, fs.MustSub(templates, "templates"), version) |
33 | // above and there's no need to bury it and de-couple that relationship. | ||
34 | templates, err := fs.Sub(embeddedTemplates, "templates") | ||
35 | if err != nil { | ||
36 | log.Fatalf("Error building sub-fs of embeded fs") | ||
37 | } | ||
38 | |||
39 | web.Register(rootCmd, templates, appVersion) | ||
40 | 33 | ||
41 | if err := rootCmd.Execute(); err != nil { | 34 | if err := r.Execute(); err != nil { |
42 | log.Fatalf("Error running root command: %s", err) | 35 | log.Fatalf("Error running root command: %s", err) |
43 | } | 36 | } |
44 | } | 37 | } |