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

feat(fxcore): Added app description #274

Merged
merged 7 commits into from
Jul 26, 2024
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
2 changes: 1 addition & 1 deletion fxcore/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ linters:
- importas
- ineffassign
- interfacebloat
- logrlint
- loggercheck
- maintidx
- makezero
- misspell
Expand Down
1 change: 1 addition & 0 deletions fxcore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Configuration reference:
# ./configs/config.yaml
app:
name: app
description: app description
env: dev
version: 0.1.0
debug: true
Expand Down
10 changes: 5 additions & 5 deletions fxcore/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module github.com/ankorstore/yokai/fxcore
go 1.20

require (
github.com/ankorstore/yokai/config v1.3.0
github.com/ankorstore/yokai/fxconfig v1.1.0
github.com/ankorstore/yokai/fxgenerate v1.1.0
github.com/ankorstore/yokai/config v1.4.0
github.com/ankorstore/yokai/fxconfig v1.2.0
github.com/ankorstore/yokai/fxgenerate v1.2.0
github.com/ankorstore/yokai/fxhealthcheck v1.1.0
github.com/ankorstore/yokai/fxlog v1.1.0
github.com/ankorstore/yokai/fxmetrics v1.2.0
github.com/ankorstore/yokai/fxtrace v1.2.0
github.com/ankorstore/yokai/generate v1.1.0
github.com/ankorstore/yokai/generate v1.2.0
github.com/ankorstore/yokai/healthcheck v1.1.0
github.com/ankorstore/yokai/httpserver v1.5.0
github.com/ankorstore/yokai/log v1.2.0
Expand All @@ -23,7 +23,7 @@ require (
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/otel v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
go.uber.org/fx v1.21.0
go.uber.org/fx v1.22.0
)

require (
Expand Down
20 changes: 10 additions & 10 deletions fxcore/go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
github.com/ankorstore/yokai/config v1.3.0 h1:si2h4mESPN5pj14CBMT/VGFgFn0voKEVylr8hQeIgEk=
github.com/ankorstore/yokai/config v1.3.0/go.mod h1:OV2QiL2dyNLCxhcGO+GcSa8Wm20+00H03VBHm9SPVuE=
github.com/ankorstore/yokai/fxconfig v1.1.0 h1:QgRDrZPpSy4wlnzNN37sWniRRAszerBb6WpvMa3hTB0=
github.com/ankorstore/yokai/fxconfig v1.1.0/go.mod h1:dU8W3eJtioegWEB7X5C+B40Ud+M+vRa5d2UdbAJr9Os=
github.com/ankorstore/yokai/fxgenerate v1.1.0 h1:kNEAsZJt7DgwVpG9+/M7p8610BdKHWkX/MYdBLuSIGU=
github.com/ankorstore/yokai/fxgenerate v1.1.0/go.mod h1:trC9VZEaVjTXuO9GWbqVPGKFkKULDZpLoxdTyTmmpYU=
github.com/ankorstore/yokai/config v1.4.0 h1:O3ZuTGud388Gq55bQwrfs/vdjYSZZvj0VUL6yZp4rcg=
github.com/ankorstore/yokai/config v1.4.0/go.mod h1:OV2QiL2dyNLCxhcGO+GcSa8Wm20+00H03VBHm9SPVuE=
github.com/ankorstore/yokai/fxconfig v1.2.0 h1:ezuyPD9xfw4b7fe4IgeF0cZQKs3f3n7QOS0hdLBjsc0=
github.com/ankorstore/yokai/fxconfig v1.2.0/go.mod h1:6sUUNd11awsM5BqiTW4BTCk+JdOIDrYETwWGpxoM+kg=
github.com/ankorstore/yokai/fxgenerate v1.2.0 h1:Fnw0DauFbuFwpKNVliKlZbvLC1Xg9Af0lxQCRkbvfLo=
github.com/ankorstore/yokai/fxgenerate v1.2.0/go.mod h1:cTn+S3Wk3rql/KRVtOXn4kQyMAYpi5n1rcXisWR9uks=
github.com/ankorstore/yokai/fxhealthcheck v1.1.0 h1:E/ADes6EC49kPwQlOel5BUyWNv45R21GtCa2WmSmZCQ=
github.com/ankorstore/yokai/fxhealthcheck v1.1.0/go.mod h1:j8ki4ZHL/G5zaD3GwVX3j5/xFyuQNNvsZPnoSG7E/AY=
github.com/ankorstore/yokai/fxlog v1.1.0 h1:vLI8Qd9KfCzAH9IvzGJTvFYmlE1jtMnjvA4z/vxJpYg=
Expand All @@ -12,8 +12,8 @@ github.com/ankorstore/yokai/fxmetrics v1.2.0 h1:B4vwfOxsUeFXC5rn0bDHsFnOhEFhRq9a
github.com/ankorstore/yokai/fxmetrics v1.2.0/go.mod h1:WBr76IIdlSZIpBsjKSdXCAJBWF0HCp46bwFX8bt0tFk=
github.com/ankorstore/yokai/fxtrace v1.2.0 h1:SXlWbjKSsb2wVH+hXSE9OD2VwyqkznwwW+kiQcNvEAU=
github.com/ankorstore/yokai/fxtrace v1.2.0/go.mod h1:ch72eVTlIedETOApK7SXk2NEWpn3yYeM018dNRccocg=
github.com/ankorstore/yokai/generate v1.1.0 h1:tu3S+uEYh+2qNo8Rf/WxWneDjh49YgDPzSnJfF8JkXA=
github.com/ankorstore/yokai/generate v1.1.0/go.mod h1:gqS/i20wnvCOhcXydYdiGcASzBaeuW7GK6YYg/kkuY4=
github.com/ankorstore/yokai/generate v1.2.0 h1:37siukjPGSS2kRnCnPhiuiF373+0tgwp0teXHnMsBhA=
github.com/ankorstore/yokai/generate v1.2.0/go.mod h1:gqS/i20wnvCOhcXydYdiGcASzBaeuW7GK6YYg/kkuY4=
github.com/ankorstore/yokai/healthcheck v1.1.0 h1:PXkEccym7iaVnQltpM5UFi0Xl0n+5rZDzlQju6HmGms=
github.com/ankorstore/yokai/healthcheck v1.1.0/go.mod h1:IiYgjRa4G3OLZMwAuacuryZZAfDHsBH8PQoK4PgRdZ4=
github.com/ankorstore/yokai/httpserver v1.5.0 h1:42nfCFCGWuBKbwU8Jhlf1/ofrezDes8HlCa0mhiVoI8=
Expand Down Expand Up @@ -141,8 +141,8 @@ go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxi
go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY=
go.uber.org/dig v1.17.1 h1:Tga8Lz8PcYNsWsyHMZ1Vm0OQOUaJNDyvPImgbAu9YSc=
go.uber.org/dig v1.17.1/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE=
go.uber.org/fx v1.21.0 h1:qqD6k7PyFHONffW5speYx403ywanuASqU4Rqdpc22XY=
go.uber.org/fx v1.21.0/go.mod h1:HT2M7d7RHo+ebKGh9NRcrsrHHfpZ60nW3QRubMRfv48=
go.uber.org/fx v1.22.0 h1:pApUK7yL0OUHMd8vkunWSlLxZVFFk70jR2nKde8X2NM=
go.uber.org/fx v1.22.0/go.mod h1:HT2M7d7RHo+ebKGh9NRcrsrHHfpZ60nW3QRubMRfv48=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
Expand Down
11 changes: 7 additions & 4 deletions fxcore/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type FxModuleInfo interface {
// FxCoreModuleInfo is a module info collector for the core.
type FxCoreModuleInfo struct {
AppName string
AppDescription string
AppEnv string
AppDebug bool
AppVersion string
Expand Down Expand Up @@ -90,6 +91,7 @@ func NewFxCoreModuleInfo(p FxCoreModuleInfoParam) *FxCoreModuleInfo {

return &FxCoreModuleInfo{
AppName: p.Config.AppName(),
AppDescription: p.Config.AppDescription(),
AppEnv: p.Config.AppEnv(),
AppDebug: p.Config.AppDebug(),
AppVersion: p.Config.AppVersion(),
Expand All @@ -110,10 +112,11 @@ func (i *FxCoreModuleInfo) Name() string {
func (i *FxCoreModuleInfo) Data() map[string]interface{} {
return map[string]interface{}{
"app": map[string]interface{}{
"name": i.AppName,
"env": i.AppEnv,
"debug": i.AppDebug,
"version": i.AppVersion,
"name": i.AppName,
"description": i.AppDescription,
"env": i.AppEnv,
"debug": i.AppDebug,
"version": i.AppVersion,
},
"log": map[string]interface{}{
"level": i.LogLevel,
Expand Down
9 changes: 5 additions & 4 deletions fxcore/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ func TestNewFxCoreModuleInfo(t *testing.T) {
t,
map[string]interface{}{
"app": map[string]interface{}{
"name": "core-app",
"env": "test",
"debug": true,
"version": "0.1.0",
"name": "core-app",
"description": "core app description",
"env": "test",
"debug": true,
"version": "0.1.0",
},
"log": map[string]interface{}{
"level": "debug",
Expand Down
2 changes: 2 additions & 0 deletions fxcore/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ func withHandlers(coreServer *echo.Echo, p FxCoreParam) (*echo.Echo, error) {
}

// dashboard overview expositions
overviewAppDescriptionExpose := p.Config.GetBool("modules.core.server.dashboard.overview.app_description")
overviewAppEnvExpose := p.Config.GetBool("modules.core.server.dashboard.overview.app_env")
overviewAppDebugExpose := p.Config.GetBool("modules.core.server.dashboard.overview.app_debug")
overviewAppVersionExpose := p.Config.GetBool("modules.core.server.dashboard.overview.app_version")
Expand Down Expand Up @@ -457,6 +458,7 @@ func withHandlers(coreServer *echo.Echo, p FxCoreParam) (*echo.Echo, error) {

return c.Render(http.StatusOK, "dashboard.html", map[string]interface{}{
"overviewInfo": overviewInfo,
"overviewAppDescriptionExpose": overviewAppDescriptionExpose,
"overviewAppEnvExpose": overviewAppEnvExpose,
"overviewAppDebugExpose": overviewAppDebugExpose,
"overviewAppVersionExpose": overviewAppVersionExpose,
Expand Down
15 changes: 12 additions & 3 deletions fxcore/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<div class="container-fluid">
<a class="navbar-brand icon-link icon-link-hover fw-bold" href="/" style="--bs-icon-link-transform: scale(1.2);">
<i class="bi bi-terminal"></i>&nbsp;{{ .overviewInfo.AppName }}
{{ if and .overviewAppDescriptionExpose .overviewInfo.AppDescription }}
&nbsp;/&nbsp;<span class="d-inline-block text-truncate text-secondary" style="max-width: 350px;">{{ .overviewInfo.AppDescription }}</span>
{{ end }}
</a>
<span>
<a class="btn btn-sm btn-outline-secondary" role="button" href="https://ankorstore.github.io/yokai/" target="_blank">
Expand Down Expand Up @@ -154,19 +157,25 @@
</p>
<table class="table table-borderless table-sm">
<tbody>
{{ if or .overviewAppEnvExpose }}
{{ if and .overviewAppDescriptionExpose .overviewInfo.AppDescription }}
<tr>
<td class="w-25">Description</td>
<td><code>{{ .overviewInfo.AppDescription }}</code></td>
</tr>
{{ end }}
{{ if .overviewAppEnvExpose }}
<tr>
<td class="w-25">Env</td>
<td><code>{{ .overviewInfo.AppEnv }}</code></td>
</tr>
{{ end }}
{{ if or .overviewAppDebugExpose }}
{{ if .overviewAppDebugExpose }}
<tr>
<td class="w-25">Debug</td>
<td><code>{{ .overviewInfo.AppDebug }}</code></td>
</tr>
{{ end }}
{{ if or .overviewAppVersionExpose }}
{{ if .overviewAppVersionExpose }}
<tr>
<td class="w-25">Version</td>
<td><code>{{ .overviewInfo.AppVersion }}</code></td>
Expand Down
1 change: 1 addition & 0 deletions fxcore/testdata/config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
app:
name: core-app
description: core app description
env: dev
version: 0.1.0
debug: false
Expand Down
Loading