From 3d4fd984fa919a564e574f71d1f8c9d9b8afeacb Mon Sep 17 00:00:00 2001 From: Jonathan Vuillemin Date: Fri, 26 Jul 2024 12:11:49 +0200 Subject: [PATCH] feat(fxcore): Added app description (#274) --- fxcore/.golangci.yml | 2 +- fxcore/README.md | 1 + fxcore/go.mod | 10 +++++----- fxcore/go.sum | 20 ++++++++++---------- fxcore/info.go | 11 +++++++---- fxcore/info_test.go | 9 +++++---- fxcore/module.go | 2 ++ fxcore/templates/dashboard.html | 15 ++++++++++++--- fxcore/testdata/config/config.yaml | 1 + 9 files changed, 44 insertions(+), 27 deletions(-) diff --git a/fxcore/.golangci.yml b/fxcore/.golangci.yml index 79115168..8600ce16 100644 --- a/fxcore/.golangci.yml +++ b/fxcore/.golangci.yml @@ -38,7 +38,7 @@ linters: - importas - ineffassign - interfacebloat - - logrlint + - loggercheck - maintidx - makezero - misspell diff --git a/fxcore/README.md b/fxcore/README.md index e181b1cb..b39b7536 100644 --- a/fxcore/README.md +++ b/fxcore/README.md @@ -70,6 +70,7 @@ Configuration reference: # ./configs/config.yaml app: name: app + description: app description env: dev version: 0.1.0 debug: true diff --git a/fxcore/go.mod b/fxcore/go.mod index 9596954f..d541aaa6 100644 --- a/fxcore/go.mod +++ b/fxcore/go.mod @@ -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 @@ -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 ( diff --git a/fxcore/go.sum b/fxcore/go.sum index 3596672d..d61afe34 100644 --- a/fxcore/go.sum +++ b/fxcore/go.sum @@ -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= @@ -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= @@ -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= diff --git a/fxcore/info.go b/fxcore/info.go index 470c1e71..320cd7cb 100644 --- a/fxcore/info.go +++ b/fxcore/info.go @@ -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 @@ -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(), @@ -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, diff --git a/fxcore/info_test.go b/fxcore/info_test.go index eeedcd13..b1ed0f3f 100644 --- a/fxcore/info_test.go +++ b/fxcore/info_test.go @@ -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", diff --git a/fxcore/module.go b/fxcore/module.go index e7795787..ab713351 100644 --- a/fxcore/module.go +++ b/fxcore/module.go @@ -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") @@ -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, diff --git a/fxcore/templates/dashboard.html b/fxcore/templates/dashboard.html index ff7f50df..e61eb4fb 100644 --- a/fxcore/templates/dashboard.html +++ b/fxcore/templates/dashboard.html @@ -18,6 +18,9 @@
 {{ .overviewInfo.AppName }} + {{ if and .overviewAppDescriptionExpose .overviewInfo.AppDescription }} +  / {{ .overviewInfo.AppDescription }} + {{ end }} @@ -154,19 +157,25 @@

- {{ if or .overviewAppEnvExpose }} + {{ if and .overviewAppDescriptionExpose .overviewInfo.AppDescription }} + + + + + {{ end }} + {{ if .overviewAppEnvExpose }} {{ end }} - {{ if or .overviewAppDebugExpose }} + {{ if .overviewAppDebugExpose }} {{ end }} - {{ if or .overviewAppVersionExpose }} + {{ if .overviewAppVersionExpose }} diff --git a/fxcore/testdata/config/config.yaml b/fxcore/testdata/config/config.yaml index db0d8ee6..db70eb5b 100644 --- a/fxcore/testdata/config/config.yaml +++ b/fxcore/testdata/config/config.yaml @@ -1,5 +1,6 @@ app: name: core-app + description: core app description env: dev version: 0.1.0 debug: false
Description{{ .overviewInfo.AppDescription }}
Env {{ .overviewInfo.AppEnv }}
Debug {{ .overviewInfo.AppDebug }}
Version {{ .overviewInfo.AppVersion }}