-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
52 lines (45 loc) · 1.36 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
package main
import (
"context"
"os"
"github.com/spf13/viper"
"github.com/turbot/flowpipe/internal/cache"
"github.com/turbot/flowpipe/internal/cmd"
localcmdconfig "github.com/turbot/flowpipe/internal/cmdconfig"
"github.com/turbot/flowpipe/internal/fperr"
"github.com/turbot/flowpipe/internal/log"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/constants"
"github.com/turbot/pipe-fittings/error_helpers"
)
var (
// These variables will be set by GoReleaser. We have them in main package because we put everything else in internal
// and I couldn't get Go Release to modify the internal packages
version = "0.0.1-local.1"
commit = "none"
date = "unknown"
builtBy = "local"
)
func main() {
// Create a single, global context for the application
ctx := context.Background()
defer func() {
var err error
if r := recover(); r != nil {
err = helpers.ToError(r)
error_helpers.ShowError(ctx, err)
exitCode := fperr.GetExitCode(err, true)
os.Exit(exitCode)
}
}()
viper.SetDefault(constants.ArgProcessRetention, 604800) // 7 days
viper.SetDefault("main.version", version)
viper.SetDefault("main.commit", commit)
viper.SetDefault("main.date", date)
viper.SetDefault("main.builtBy", builtBy)
localcmdconfig.SetAppSpecificConstants()
log.SetDefaultLogger()
cache.InMemoryInitialize(nil)
// Run the CLI
cmd.RunCLI(ctx)
}