You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have a suitable `Go` environment set up, you can build the binary from `/src/`. For development, a `devcontainer` with a suitable `Dockerfile` is provided as well.
80
+
If you have a suitable `Go` environment set up, you can build the binary from `/src/`. For development, a `devcontainer` with a suitable `Dockerfile` is provided as well. If you run `make build` instead of `go build`, `git` commit/branch/date information are injected into to binary.
Copy file name to clipboardExpand all lines: src/docker-event-monitor.go
+42-5Lines changed: 42 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ type args struct {
44
44
Filtermap[string][]string`arg:"-"`
45
45
LogLevelstring`arg:"env:LOG_LEVEL" default:"info" help:"Set log level. Use debug for more logging."`
46
46
ServerTagstring`arg:"env:SERVER_TAG" help:"Prefix to include in the title of notifications. Useful when running docker-event-monitors on multiple machines."`
47
+
Versionbool`arg:"-v" help:"Print version information."`
47
48
}
48
49
49
50
// Creating a global logger
@@ -52,11 +53,31 @@ var logger zerolog.Logger
52
53
// hold the supplied run-time arguments globally
53
54
varglb_argumentsargs
54
55
56
+
// version information, are injected during build process
57
+
var (
58
+
versionstring="n/a"
59
+
commitstring="n/a"
60
+
datestring
61
+
gitdatestring
62
+
branchstring="n/a"
63
+
)
64
+
55
65
funcinit() {
56
66
parseArgs()
57
-
58
67
configureLogger(glb_arguments.LogLevel)
59
68
69
+
// if the -v flag was set, print version information and exit
70
+
ifglb_arguments.Version {
71
+
logger.Info().
72
+
Str("Version", version).
73
+
Str("Branch", branch).
74
+
Str("Commit", commit).
75
+
Time("Compile_date", stringToUnix(date)).
76
+
Time("Git_date", stringToUnix(gitdate)).
77
+
Msg("Version Information")
78
+
os.Exit(0)
79
+
}
80
+
60
81
ifglb_arguments.Pushover {
61
82
iflen(glb_arguments.PushoverAPIToken) ==0 {
62
83
logger.Fatal().Msg("Pushover enabled. Pushover API token required!")
0 commit comments