Skip to content

Commit

Permalink
fix(zentao): make sure connection uncacheable (#8245)
Browse files Browse the repository at this point in the history
* fix(zentao): make sure connection uncacheable

* fix(zentao): fix lint errors

* Revert "fix(zentao): fix lint errors"

This reverts commit e216a23.

* fix(zentao): fix lint errors

* fix(zentao): remove UnCacheableConnetion interface, try to fix it with another way
  • Loading branch information
d4x1 authored Dec 18, 2024
1 parent 3de9840 commit bebd054
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 1 addition & 5 deletions backend/helpers/pluginhelper/api/ds_remote_api_proxy_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
9 changes: 9 additions & 0 deletions backend/plugins/zentao/models/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bebd054

Please sign in to comment.