Skip to content

Commit

Permalink
adds bsp-agent to binary run info
Browse files Browse the repository at this point in the history
Signed-off-by: Pranay Valson <pranay.valson@gmail.com>
  • Loading branch information
noslav committed Sep 17, 2022
1 parent a6334f8 commit 866d094
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/bspagent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func init() {
outWriter = &bspLogger
}

utils.Version()
log.SetOutput(outWriter)
log.SetLevel(log.InfoLevel)
log.WithFields(log.Fields{"file": "main.go"}).Info("bsp-agent is running...")
Expand Down
30 changes: 30 additions & 0 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"os/user"
"path"
"runtime"
"strconv"
"strings"

Expand All @@ -26,6 +27,24 @@ import (
"google.golang.org/api/option"
)

const (
clientIdentifier = "bspagent" // Client identifier to advertise over the network
)

const (
// BspAgentVersionMajor is Major version component of the current release
BspAgentVersionMajor = 1
// BspAgentVersionMinor is Minor version component of the current release
BspAgentVersionMinor = 3
// BspAgentVersionPatch is Patch version component of the current release
BspAgentVersionPatch = 1
)

// BspAgentVersion holds the textual version string.
var BspAgentVersion = func() string {
return fmt.Sprintf("%d.%d.%d", BspAgentVersionMajor, BspAgentVersionMinor, BspAgentVersionPatch)
}()

// NewRedisClient provides a new redis client using a redis config
func NewRedisClient(rconfig *config.RedisConfig) (*redis.Client, string, string, error) {
var pwd string
Expand Down Expand Up @@ -319,3 +338,14 @@ func MapToAvroUnion(data map[string]interface{}) map[string]interface{} {

return vs
}

// Version Provides version info on bsp agent binary
func Version() {
fmt.Println(clientIdentifier)
fmt.Println("Bsp Agent Version:", BspAgentVersion)
fmt.Println("Architecture:", runtime.GOARCH)
fmt.Println("Go Version:", runtime.Version())
fmt.Println("Operating System:", runtime.GOOS)
fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH"))
fmt.Printf("GOROOT=%s\n", runtime.GOROOT())
}

0 comments on commit 866d094

Please sign in to comment.