Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test case for internal/info pacakge. #514

Merged
merged 7 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ require (
github.com/gocql/gocql v0.0.0-20200131111108-92af2e088537
github.com/gocraft/dbr/v2 v2.7.0
github.com/gogo/protobuf v1.3.1
github.com/google/go-cmp v0.5.0
github.com/google/gofuzz v1.1.0
github.com/gorilla/mux v1.7.1
github.com/hashicorp/go-version v1.2.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.4.1 h1:/exdXoGamhu5ONeUJH0deniYLWYvQwW66yvlfiiKTu0=
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/go-replayers/grpcreplay v0.1.0 h1:eNb1y9rZFmY4ax45uEEECSa8fsxGRU+8Bil52ASAwic=
github.com/google/go-replayers/grpcreplay v0.1.0/go.mod h1:8Ig2Idjpr6gifRd6pNVggX6TC1Zw6Jx74AKp7QNH2QE=
Expand Down
7 changes: 7 additions & 0 deletions internal/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/vdaas/vald/internal/log"
)

// Detail represents environment information of system and stacktrace information.
type Detail struct {
Version string `json:"vald_version,omitempty" yaml:"vald_version,omitempty"`
ServerName string `json:"server_name,omitempty" yaml:"server_name,omitempty"`
Expand All @@ -45,6 +46,7 @@ type Detail struct {
PrepOnce sync.Once `json:"-" yaml:"-"`
}

// StackTrace represents stacktrace information about url, function name, file, line ..etc.
type StackTrace struct {
URL string `json:"url,omitempty" yaml:"url,omitempty"`
FuncName string `json:"function_name,omitempty" yaml:"func_name,omitempty"`
Expand Down Expand Up @@ -75,14 +77,17 @@ var (
detail Detail
)

// String calls String method of global detail object.
func String() string {
return detail.String()
}

// Get calls Get method of global detail object.
func Get() Detail {
return detail.Get()
}

// String returns summary of Detail object.
func (d Detail) String() string {
if len(d.StackTrace) == 0 {
d = d.Get()
Expand Down Expand Up @@ -143,6 +148,7 @@ func (d Detail) String() string {
return "\n" + strings.Join(strs, "\n")
}

// Get returns parased Detail object.
func (d Detail) Get() Detail {
d.prepare()
valdRepo := fmt.Sprintf("github.com/%s/%s", Organization, Repository)
Expand Down Expand Up @@ -221,6 +227,7 @@ func (d *Detail) prepare() {
})
}

// Init initializes Detail object only once.
func Init(name string) {
once.Do(func() {
detail = Detail{
Expand Down
Loading