You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ma...@apache.org on 2022/10/26 02:10:04 UTC

[incubator-devlake] branch main updated: fix: gitee create conn with empty env (#3572)

This is an automated email from the ASF dual-hosted git repository.

mappjzc 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 5618601d fix: gitee create conn with empty env (#3572)
5618601d is described below

commit 5618601dde91589043f2b15f1c5bd09202dc434c
Author: mappjzc <zh...@merico.dev>
AuthorDate: Wed Oct 26 10:10:00 2022 +0800

    fix: gitee create conn with empty env (#3572)
    
    if env not set endpoint or enckey
    gitee will not create conn any more.
    
    Nddtfjiang <zh...@merico.dev>
---
 config/config.go                                                  | 8 +++-----
 plugins/gitee/models/migrationscripts/20220714_add_init_tables.go | 5 +++++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/config/config.go b/config/config.go
index 315293dc..d83d2839 100644
--- a/config/config.go
+++ b/config/config.go
@@ -19,13 +19,14 @@ package config
 
 import (
 	"fmt"
-	"github.com/apache/incubator-devlake/errors"
-	goerror "github.com/cockroachdb/errors"
 	"os"
 	"path/filepath"
 	"regexp"
 	"strings"
 
+	"github.com/apache/incubator-devlake/errors"
+	goerror "github.com/cockroachdb/errors"
+
 	"github.com/sirupsen/logrus"
 	"github.com/spf13/afero"
 	"github.com/spf13/viper"
@@ -69,9 +70,6 @@ func setDefaultValue(v *viper.Viper) {
 	v.SetDefault("PORT", ":8080")
 	v.SetDefault("PLUGIN_DIR", "bin/plugins")
 	v.SetDefault("TEMPORAL_TASK_QUEUE", "DEVLAKE_TASK_QUEUE")
-	v.SetDefault("GITLAB_ENDPOINT", "https://gitlab.com/api/v4/")
-	v.SetDefault("GITHUB_ENDPOINT", "https://api.github.com/")
-	v.SetDefault("GITEE_ENDPOINT", "https://gitee.com/api/v5/")
 }
 
 // replaceNewEnvItemInOldContent replace old config to new config in env file content
diff --git a/plugins/gitee/models/migrationscripts/20220714_add_init_tables.go b/plugins/gitee/models/migrationscripts/20220714_add_init_tables.go
index 44006327..cb6cb90a 100644
--- a/plugins/gitee/models/migrationscripts/20220714_add_init_tables.go
+++ b/plugins/gitee/models/migrationscripts/20220714_add_init_tables.go
@@ -92,10 +92,15 @@ func (*addInitTables) Up(baseRes core.BasicRes) errors.Error {
 	conn.Name = "init gitee connection"
 	conn.ID = 1
 	conn.Endpoint = baseRes.GetConfig("GITEE_ENDPOINT")
+	if encKey == "" || conn.Endpoint == "" {
+		return nil
+	}
+
 	conn.Token, err = core.Encrypt(encKey, baseRes.GetConfig("GITEE_AUTH"))
 	if err != nil {
 		return err
 	}
+
 	conn.Proxy = baseRes.GetConfig("GITEE_PROXY")
 
 	var err1 error