From bebd0541647b8aca71d976e6bd91cc11224052dd Mon Sep 17 00:00:00 2001 From: Lynwee <1507509064@qq.com> Date: Wed, 18 Dec 2024 15:51:09 +0800 Subject: [PATCH] fix(zentao): make sure connection uncacheable (#8245) * fix(zentao): make sure connection uncacheable * fix(zentao): fix lint errors * Revert "fix(zentao): fix lint errors" This reverts commit e216a23ac1fdb0cb2297fc1bfb8e88abb0da9a90. * fix(zentao): fix lint errors * fix(zentao): remove UnCacheableConnetion interface, try to fix it with another way --- .../helpers/pluginhelper/api/ds_remote_api_proxy_api.go | 6 +----- backend/plugins/zentao/models/connection.go | 9 +++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/backend/helpers/pluginhelper/api/ds_remote_api_proxy_api.go b/backend/helpers/pluginhelper/api/ds_remote_api_proxy_api.go index 9ea8b5d2a43..b0c4b0439c2 100644 --- a/backend/helpers/pluginhelper/api/ds_remote_api_proxy_api.go +++ b/backend/helpers/pluginhelper/api/ds_remote_api_proxy_api.go @@ -39,11 +39,7 @@ type DsRemoteApiProxyHelper[C plugin.ToolLayerApiConnection] struct { } // NewDsRemoteApiProxyHelper creates a new DsRemoteApiProxyHelper -func NewDsRemoteApiProxyHelper[ - C plugin.ToolLayerApiConnection, -]( - modelApiHelper *ModelApiHelper[C], -) *DsRemoteApiProxyHelper[C] { +func NewDsRemoteApiProxyHelper[C plugin.ToolLayerApiConnection](modelApiHelper *ModelApiHelper[C]) *DsRemoteApiProxyHelper[C] { return &DsRemoteApiProxyHelper[C]{ ModelApiHelper: modelApiHelper, logger: modelApiHelper.basicRes.GetLogger().Nested("remote_api_helper"), diff --git a/backend/plugins/zentao/models/connection.go b/backend/plugins/zentao/models/connection.go index 0554450e7ae..949dd36d2b4 100644 --- a/backend/plugins/zentao/models/connection.go +++ b/backend/plugins/zentao/models/connection.go @@ -73,6 +73,11 @@ type ZentaoConn struct { DbMaxConns int `json:"dbMaxConns" mapstructure:"dbMaxConns"` } +func (connection ZentaoConn) GetHash() string { + // zentao's token will expire after about 24min, so api client cannot be cached. + return "" +} + func (connection ZentaoConn) Sanitize() ZentaoConn { connection.Password = "" if connection.DbUrl != "" { @@ -106,6 +111,10 @@ func (connection ZentaoConn) SanitizeDbUrl() string { return dbUrl } +func (connection ZentaoConnection) GetHash() string { + return connection.ZentaoConn.GetHash() +} + func (connection ZentaoConnection) Sanitize() ZentaoConnection { connection.ZentaoConn = connection.ZentaoConn.Sanitize() return connection