This is an automated email from the ASF dual-hosted git repository.
lynwee pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 62f71ad32 refactor: removed unused code (#6243)
62f71ad32 is described below
commit 62f71ad324136adb0aaf3f3cee18d53dcab827c4
Author: Klesh Wong <[email protected]>
AuthorDate: Fri Oct 13 16:44:17 2023 +0800
refactor: removed unused code (#6243)
---
backend/server/api/api.go | 13 ++++---------
backend/server/main.go | 2 +-
backend/server/services/remote/plugin/plugin_impl.go | 2 +-
backend/test/helper/client.go | 2 +-
4 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/backend/server/api/api.go b/backend/server/api/api.go
index 2faa423b6..698e9e1c9 100644
--- a/backend/server/api/api.go
+++ b/backend/server/api/api.go
@@ -56,7 +56,7 @@ Alternatively, you may downgrade back to the previous DevLake
version.
// @license.name Apache-2.0
// @host localhost:8080
// @BasePath /
-func CreateApiService() {
+func CreateApiService(router *gin.Engine) {
// Get configuration
v := config.GetConfig()
// Initialize services
@@ -64,18 +64,13 @@ func CreateApiService() {
// Set gin mode
gin.SetMode(v.GetString("MODE"))
// Create a gin router
- router := gin.Default()
+ if router == nil {
+ router = gin.Default()
+ }
// For both protected and unprotected routes
router.GET("/ping", ping.Get)
router.GET("/version", version.Get)
- router.GET("/userinfo", func(ctx *gin.Context) {
- shared.ApiOutputSuccess(ctx, gin.H{
- "user": ctx.Request.Header.Get("X-Forwarded-User"),
- "email":
ctx.Request.Header.Get("X-Forwarded-Email"),
- "logoutURI": config.GetConfig().GetString("LOGOUT_URI"),
- }, http.StatusOK)
- })
// Endpoint to proceed database migration
router.GET("/proceed-db-migration", func(ctx *gin.Context) {
diff --git a/backend/server/main.go b/backend/server/main.go
index 5988dea91..514a179e6 100644
--- a/backend/server/main.go
+++ b/backend/server/main.go
@@ -30,5 +30,5 @@ func main() {
if encryptionSecret == "" {
panic("ENCRYPTION_SECRET must be set in environment variable or
.env file")
}
- api.CreateApiService()
+ api.CreateApiService(nil)
}
diff --git a/backend/server/services/remote/plugin/plugin_impl.go
b/backend/server/services/remote/plugin/plugin_impl.go
index 7ced36f9d..6242b1600 100644
--- a/backend/server/services/remote/plugin/plugin_impl.go
+++ b/backend/server/services/remote/plugin/plugin_impl.go
@@ -84,7 +84,7 @@ func newPlugin(info *models.PluginInfo, invoker
bridge.Invoker) (*remotePluginIm
}
openApiSpec, err := doc.GenerateOpenApiSpec(info)
if err != nil {
- return nil, errors.Default.Wrap(err, fmt.Sprintf("Couldn't
generate OpenAPI spec for plugin %s", info.Name))
+ panic(err)
}
scripts := make([]plugin.MigrationScript, 0)
for _, script := range info.MigrationScripts {
diff --git a/backend/test/helper/client.go b/backend/test/helper/client.go
index 0970db916..840dbc25c 100644
--- a/backend/test/helper/client.go
+++ b/backend/test/helper/client.go
@@ -172,7 +172,7 @@ func ConnectLocalServer(t *testing.T, clientConfig
*LocalClientConfig) *DevlakeC
cfg.Set("PLUGIN_DIR", throwawayDir)
cfg.Set("LOGGING_DIR", throwawayDir)
go func() {
- initService.Do(api.CreateApiService)
+ initService.Do(func() { api.CreateApiService(nil) })
}()
req, err2 := http.NewRequest(http.MethodGet,
fmt.Sprintf("%s/proceed-db-migration", addr), nil)
require.NoError(t, err2)