You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/10/24 06:56:45 UTC

[incubator-devlake] branch main updated: feat: add `GetTablesInfo` and `CloseablePluginTask` for `bitbucket` plugin (#3167)

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

warren 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 6a12e0e1 feat: add `GetTablesInfo` and `CloseablePluginTask` for `bitbucket` plugin (#3167)
6a12e0e1 is described below

commit 6a12e0e19e4e8c4b133b303473c80b65cb9a2368
Author: tsoc <47...@users.noreply.github.com>
AuthorDate: Mon Oct 24 14:56:38 2022 +0800

    feat: add `GetTablesInfo` and `CloseablePluginTask` for `bitbucket` plugin (#3167)
    
    * feat: add GetTablesInfo and CloseablePluginTask for `bitbucket` plugin
    
    * style: change import style
---
 plugins/bitbucket/impl/impl.go | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/plugins/bitbucket/impl/impl.go b/plugins/bitbucket/impl/impl.go
index 9f23a181..cfa6c7fb 100644
--- a/plugins/bitbucket/impl/impl.go
+++ b/plugins/bitbucket/impl/impl.go
@@ -18,6 +18,8 @@ limitations under the License.
 package impl
 
 import (
+	"fmt"
+
 	"github.com/apache/incubator-devlake/errors"
 	"github.com/apache/incubator-devlake/plugins/bitbucket/api"
 	"github.com/apache/incubator-devlake/plugins/bitbucket/models"
@@ -35,6 +37,7 @@ var _ core.PluginTask = (*Bitbucket)(nil)
 var _ core.PluginApi = (*Bitbucket)(nil)
 var _ core.PluginMigration = (*Bitbucket)(nil)
 var _ core.PluginBlueprintV100 = (*Bitbucket)(nil)
+var _ core.CloseablePluginTask = (*Bitbucket)(nil)
 
 type Bitbucket string
 
@@ -43,6 +46,21 @@ func (plugin Bitbucket) Init(config *viper.Viper, logger core.Logger, db *gorm.D
 	return nil
 }
 
+func (plugin Bitbucket) GetTablesInfo() []core.Tabler {
+	return []core.Tabler{
+		&models.BitbucketConnection{},
+		&models.BitbucketAccount{},
+		&models.BitbucketCommit{},
+		&models.BitbucketPullRequest{},
+		&models.BitbucketIssue{},
+		&models.BitbucketPrComment{},
+		&models.BitbucketIssueComment{},
+		&models.BitbucketPipeline{},
+		&models.BitbucketRepo{},
+		&models.BitbucketRepoCommit{},
+	}
+}
+
 func (plugin Bitbucket) Description() string {
 	return "To collect and enrich data from Bitbucket"
 }
@@ -128,3 +146,12 @@ func (plugin Bitbucket) ApiResources() map[string]map[string]core.ApiResourceHan
 		},
 	}
 }
+
+func (plugin Bitbucket) Close(taskCtx core.TaskContext) errors.Error {
+	data, ok := taskCtx.GetData().(*tasks.BitbucketTaskData)
+	if !ok {
+		return errors.Default.New(fmt.Sprintf("GetData failed when try to close %+v", taskCtx))
+	}
+	data.ApiClient.Release()
+	return nil
+}