45 lines
774 B
Go
45 lines
774 B
Go
package app
|
|
|
|
import (
|
|
"reflect"
|
|
"universe.mrlokop.dev/core/config"
|
|
)
|
|
|
|
type Info struct {
|
|
ServiceName string
|
|
Version string
|
|
BuildInfo *BuildInfo
|
|
}
|
|
|
|
type BuildInfo struct {
|
|
GitCommit string
|
|
BuildDate string
|
|
}
|
|
|
|
func provideAppInfo(
|
|
app Application,
|
|
cfg *config.UniverseConfig,
|
|
) *Info {
|
|
serviceInfo := cfg.ServiceInfo
|
|
if serviceInfo == nil {
|
|
serviceInfo = &config.ServiceInfo{}
|
|
// extract service name from app
|
|
serviceInfo.Name = extractServiceName(app)
|
|
}
|
|
return &Info{
|
|
ServiceName: serviceInfo.Name,
|
|
BuildInfo: &BuildInfo{
|
|
GitCommit: "",
|
|
BuildDate: "",
|
|
},
|
|
}
|
|
}
|
|
|
|
func extractServiceName(app Application) string {
|
|
appType := reflect.TypeOf(app)
|
|
if appType.Kind() == reflect.Ptr {
|
|
return appType.Elem().Name()
|
|
}
|
|
return appType.Name()
|
|
}
|