@@ -3,7 +3,6 @@ package main
3
3
import (
4
4
"log/slog"
5
5
"os"
6
- "runtime/debug"
7
6
"time"
8
7
9
8
"github.com/persona-id/proxysql-agent/internal/configuration"
@@ -13,41 +12,16 @@ import (
13
12
14
13
var (
15
14
// Version will be the version tag if the binary is built with "go install url/tool@version".
16
- // If the binary is built some other way, it will be "(devel)".
17
- Version = "unknown" //nolint:gochecknoglobals
18
- // Revision is taken from the vcs.revision tag in Go 1.18+.
19
- Revision = "unknown" //nolint:gochecknoglobals
20
- // LastCommit is taken from the vcs.time tag in Go 1.18+.
21
- LastCommit time.Time //nolint:gochecknoglobals
22
- // DirtyBuild is taken from the vcs.modified tag in Go 1.18+.
23
- DirtyBuild = true //nolint:gochecknoglobals
15
+ // See https://goreleaser.com/cookbooks/using-main.version/
16
+ // Current git tag.
17
+ version = "unknown" //nolint:gochecknoglobals
18
+ // Current git commit sha.
19
+ commit = "unknown" //nolint:gochecknoglobals
20
+ // Built at date.
21
+ date = "unknown" //nolint:gochecknoglobals
24
22
)
25
23
26
- func getVersionInfo () {
27
- info , ok := debug .ReadBuildInfo ()
28
- if ! ok {
29
- return
30
- }
31
-
32
- for _ , kv := range info .Settings {
33
- if kv .Value == "" {
34
- continue
35
- }
36
-
37
- switch kv .Key {
38
- case "vcs.revision" :
39
- Revision = kv .Value
40
- case "vcs.time" :
41
- LastCommit , _ = time .Parse (time .RFC3339 , kv .Value )
42
- case "vcs.modified" :
43
- DirtyBuild = kv .Value == "true"
44
- }
45
- }
46
- }
47
-
48
24
func main () {
49
- getVersionInfo ()
50
-
51
25
settings , err := configuration .Configure ()
52
26
if err != nil {
53
27
slog .Error ("Error in Configure()" , slog .Any ("err" , err ))
@@ -56,7 +30,7 @@ func main() {
56
30
57
31
setupLogger (settings )
58
32
59
- slog .Info ("build info" , slog .Any ("version" , Version ), slog .Any ("committed" , LastCommit ), slog .Any ("revision" , Revision ), slog . Any ( "dirty" , DirtyBuild ))
33
+ slog .Info ("build info" , slog .Any ("version" , version ), slog .Any ("committed" , date ), slog .Any ("revision" , commit ))
60
34
61
35
// if defined, pause before booting; this allows the proxysql containers to fully come up before the agent tries
62
36
// connecting; sometimes the proxysql container can take a few seconds to fully start. This is mainly only
0 commit comments