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

klesh 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 289008f54 refactor: rename transformation rule to scope config (#5282)
289008f54 is described below

commit 289008f544dc22723772937ca5cd9c44a2c9fb6f
Author: Klesh Wong <[email protected]>
AuthorDate: Fri May 26 14:29:05 2023 +0800

    refactor: rename transformation rule to scope config (#5282)
---
 backend/core/models/common/base.go                 |   5 +
 backend/core/plugin/plugin_blueprint.go            |   6 +-
 backend/core/plugin/plugin_meta.go                 |   3 +-
 .../pluginhelper/api/scope_config_helper.go        | 132 +++++++++++++++++++++
 backend/plugins/bamboo/api/blueprint_V200_test.go  |  50 ++++----
 backend/plugins/bamboo/api/blueprint_v200.go       |  39 +++---
 backend/plugins/bamboo/api/init.go                 |   8 +-
 backend/plugins/bamboo/api/scope.go                |   2 +-
 backend/plugins/bamboo/api/scope_config.go         |  83 +++++++++++++
 backend/plugins/bamboo/api/transformation_rule.go  |  83 -------------
 backend/plugins/bamboo/bamboo.go                   |   2 +-
 backend/plugins/bamboo/e2e/deploy_build_test.go    |   2 +-
 backend/plugins/bamboo/e2e/deploy_test.go          |   6 +-
 backend/plugins/bamboo/e2e/job_build_test.go       |   2 +-
 backend/plugins/bamboo/e2e/job_test.go             |   2 +-
 .../plugins/bamboo/e2e/plan_build_commits_test.go  |   2 +-
 backend/plugins/bamboo/e2e/plan_build_test.go      |   2 +-
 backend/plugins/bamboo/e2e/plan_test.go            |   6 +-
 backend/plugins/bamboo/impl/impl.go                |  52 ++++----
 ...22_add_connection_id_to_transformation_rules.go |   8 +-
 .../migrationscripts/20230518_scope_config.go      |  56 +++++++++
 .../bamboo/models/migrationscripts/register.go     |   1 +
 backend/plugins/bamboo/models/project.go           |  17 +--
 .../{transformation_rule.go => scope_config.go}    |  12 +-
 backend/plugins/bamboo/models/task.go              |  10 +-
 .../plugins/bamboo/tasks/deploy_build_extractor.go |   1 -
 .../plugins/bamboo/tasks/job_build_extractor.go    |   1 -
 .../services/remote/plugin/plugin_extensions.go    |   3 +-
 28 files changed, 396 insertions(+), 200 deletions(-)

diff --git a/backend/core/models/common/base.go 
b/backend/core/models/common/base.go
index 1f37e73fc..e33631735 100644
--- a/backend/core/models/common/base.go
+++ b/backend/core/models/common/base.go
@@ -28,6 +28,11 @@ type Model struct {
        UpdatedAt time.Time `json:"updatedAt"`
 }
 
+type ScopeConfig struct {
+       Model
+       Entities []string `gorm:"type:json;serializer:json" json:"entities" 
mapstructure:"entities"`
+}
+
 type NoPKModel struct {
        CreatedAt     time.Time `json:"createdAt"`
        UpdatedAt     time.Time `json:"updatedAt"`
diff --git a/backend/core/plugin/plugin_blueprint.go 
b/backend/core/plugin/plugin_blueprint.go
index 9487bccb4..644163015 100644
--- a/backend/core/plugin/plugin_blueprint.go
+++ b/backend/core/plugin/plugin_blueprint.go
@@ -124,10 +124,10 @@ type BlueprintConnectionV200 struct {
 }
 
 // BlueprintScopeV200 contains the `id` and `name` for a specific scope
-// transformationRuleId should be deduced by the ScopeId
 type BlueprintScopeV200 struct {
-       Id       string   `json:"id"`
-       Name     string   `json:"name"`
+       Id   string `json:"id"`
+       Name string `json:"name"`
+       // Deprecated: Entities is moved to the ScopeConfig struct
        Entities []string `json:"entities"`
 }
 
diff --git a/backend/core/plugin/plugin_meta.go 
b/backend/core/plugin/plugin_meta.go
index 5f8fe41ed..37c135966 100644
--- a/backend/core/plugin/plugin_meta.go
+++ b/backend/core/plugin/plugin_meta.go
@@ -45,5 +45,6 @@ type PluginIcon interface {
 type PluginSource interface {
        Connection() interface{}
        Scope() interface{}
-       TransformationRule() interface{}
+       // Deprecated: rename to ScopeConfig
+       // TransformationRule() interface{}
 }
diff --git a/backend/helpers/pluginhelper/api/scope_config_helper.go 
b/backend/helpers/pluginhelper/api/scope_config_helper.go
new file mode 100644
index 000000000..f2ad2d004
--- /dev/null
+++ b/backend/helpers/pluginhelper/api/scope_config_helper.go
@@ -0,0 +1,132 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package api
+
+import (
+       "net/http"
+       "reflect"
+       "strconv"
+
+       "github.com/apache/incubator-devlake/core/context"
+       "github.com/apache/incubator-devlake/core/dal"
+       "github.com/apache/incubator-devlake/core/errors"
+       "github.com/apache/incubator-devlake/core/log"
+       "github.com/apache/incubator-devlake/core/plugin"
+       "github.com/go-playground/validator/v10"
+)
+
+// ScopeConfigHelper is used to write the CURD of transformation rule
+type ScopeConfigHelper[Tr dal.Tabler] struct {
+       log       log.Logger
+       db        dal.Dal
+       validator *validator.Validate
+}
+
+// NewScopeConfigHelper creates a ScopeConfigHelper for transformation rule 
management
+func NewScopeConfigHelper[Tr dal.Tabler](
+       basicRes context.BasicRes,
+       vld *validator.Validate,
+) *ScopeConfigHelper[Tr] {
+       if vld == nil {
+               vld = validator.New()
+       }
+       return &ScopeConfigHelper[Tr]{
+               log:       basicRes.GetLogger(),
+               db:        basicRes.GetDal(),
+               validator: vld,
+       }
+}
+
+func (t ScopeConfigHelper[Tr]) Create(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
+       connectionId, e := strconv.ParseUint(input.Params["connectionId"], 10, 
64)
+       if e != nil || connectionId == 0 {
+               return nil, errors.Default.Wrap(e, "the connection ID should be 
an non-zero integer")
+       }
+       var rule Tr
+       if err := DecodeMapStruct(input.Body, &rule, false); err != nil {
+               return nil, errors.Default.Wrap(err, "error in decoding 
transformation rule")
+       }
+       if t.validator != nil {
+               if err := t.validator.Struct(rule); err != nil {
+                       return nil, errors.Default.Wrap(err, "error validating 
transformation rule")
+               }
+       }
+       valueConnectionId := 
reflect.ValueOf(&rule).Elem().FieldByName("ConnectionId")
+       if valueConnectionId.IsValid() {
+               valueConnectionId.SetUint(connectionId)
+       }
+
+       if err := t.db.Create(&rule); err != nil {
+               if t.db.IsDuplicationError(err) {
+                       return nil, errors.BadInput.New("there was a 
transformation rule with the same name, please choose another name")
+               }
+               return nil, errors.BadInput.Wrap(err, "error on saving 
ScopeConfig")
+       }
+       return &plugin.ApiResourceOutput{Body: rule, Status: http.StatusOK}, nil
+}
+
+func (t ScopeConfigHelper[Tr]) Update(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
+       scopeConfigId, e := strconv.ParseUint(input.Params["id"], 10, 64)
+       if e != nil {
+               return nil, errors.Default.Wrap(e, "the transformation rule ID 
should be an integer")
+       }
+       var old Tr
+       err := t.db.First(&old, dal.Where("id = ?", scopeConfigId))
+       if err != nil {
+               return nil, errors.Default.Wrap(err, "error on saving 
ScopeConfig")
+       }
+       err = DecodeMapStruct(input.Body, &old, false)
+       if err != nil {
+               return nil, errors.Default.Wrap(err, "error decoding map into 
scopeConfig")
+       }
+       err = t.db.Update(&old, dal.Where("id = ?", scopeConfigId))
+       if err != nil {
+               if t.db.IsDuplicationError(err) {
+                       return nil, errors.BadInput.New("there was a 
transformation rule with the same name, please choose another name")
+               }
+               return nil, errors.BadInput.Wrap(err, "error on saving 
ScopeConfig")
+       }
+       return &plugin.ApiResourceOutput{Body: old, Status: http.StatusOK}, nil
+}
+
+func (t ScopeConfigHelper[Tr]) Get(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
+       scopeConfigId, err := strconv.ParseUint(input.Params["id"], 10, 64)
+       if err != nil {
+               return nil, errors.Default.Wrap(err, "the transformation rule 
ID should be an integer")
+       }
+       var rule Tr
+       err = t.db.First(&rule, dal.Where("id = ?", scopeConfigId))
+       if err != nil {
+               return nil, errors.Default.Wrap(err, "error on get ScopeConfig")
+       }
+       return &plugin.ApiResourceOutput{Body: rule, Status: http.StatusOK}, nil
+}
+
+func (t ScopeConfigHelper[Tr]) List(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
+       connectionId, e := strconv.ParseUint(input.Params["connectionId"], 10, 
64)
+       if e != nil || connectionId == 0 {
+               return nil, errors.Default.Wrap(e, "the connection ID should be 
an non-zero integer")
+       }
+       var rules []Tr
+       limit, offset := GetLimitOffset(input.Query, "pageSize", "page")
+       err := t.db.All(&rules, dal.Where("connection_id = ?", connectionId), 
dal.Limit(limit), dal.Offset(offset))
+       if err != nil {
+               return nil, errors.Default.Wrap(err, "error on get ScopeConfig 
list")
+       }
+       return &plugin.ApiResourceOutput{Body: rules, Status: http.StatusOK}, 
nil
+}
diff --git a/backend/plugins/bamboo/api/blueprint_V200_test.go 
b/backend/plugins/bamboo/api/blueprint_V200_test.go
index e9f1f4b43..4e93e34de 100644
--- a/backend/plugins/bamboo/api/blueprint_V200_test.go
+++ b/backend/plugins/bamboo/api/blueprint_V200_test.go
@@ -38,22 +38,21 @@ import (
 
 func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
        const testConnectionID uint64 = 1
-       const testTransformationRuleId uint64 = 2
+       const testScopeConfigId uint64 = 2
        const testKey string = "TEST"
        const testBambooEndPoint string = 
"http://mail.nddtf.com:8085/rest/api/latest/";
        const testLink string = 
"http://mail.nddtf.com:8085/rest/api/latest/project/TEST";
        const testUser string = "username"
        const testPass string = "password"
        const testName string = "bamboo-test"
-       const testTransformationRuleName string = "bamboo transformation rule"
+       const testScopeConfigName string = "bamboo scope config"
        const testProxy string = ""
 
        syncPolicy := &plugin.BlueprintSyncPolicy{}
        bpScopes := []*plugin.BlueprintScopeV200{
                {
-                       Entities: []string{plugin.DOMAIN_TYPE_CICD},
-                       Id:       testKey,
-                       Name:     testName,
+                       Id:   testKey,
+                       Name: testName,
                },
        }
 
@@ -63,14 +62,17 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
                Name:         testName,
                Href:         testLink,
 
-               TransformationRuleId: testTransformationRuleId,
+               ScopeConfigId: testScopeConfigId,
        }
 
-       var testTransformationRule = &models.BambooTransformationRule{
-               Model: common.Model{
-                       ID: testTransformationRuleId,
+       var testScopeConfig = &models.BambooScopeConfig{
+               ScopeConfig: common.ScopeConfig{
+                       Model: common.Model{
+                               ID: testScopeConfigId,
+                       },
+                       Entities: []string{plugin.DOMAIN_TYPE_CICD},
                },
-               Name: testTransformationRuleName,
+               Name: testScopeConfigName,
        }
 
        var testBambooConnection = &models.BambooConnection{
@@ -107,9 +109,9 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
                                        tasks.ConvertProjectsMeta.Name,
                                },
                                Options: map[string]interface{}{
-                                       "connectionId":         uint64(1),
-                                       "projectKey":           testKey,
-                                       "transformationRuleId": 
testTransformationRuleId,
+                                       "connectionId":  uint64(1),
+                                       "projectKey":    testKey,
+                                       "scopeConfigId": testScopeConfigId,
                                },
                        },
                },
@@ -130,19 +132,15 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
        // Refresh Global Variables and set the sql mock
        basicRes = unithelper.DummyBasicRes(func(mockDal *mockdal.Dal) {
                mockDal.On("First", mock.Anything, mock.Anything).Run(func(args 
mock.Arguments) {
-                       dst := args.Get(0).(*models.BambooConnection)
-                       *dst = *testBambooConnection
-               }).Return(nil).Once()
-
-               mockDal.On("First", mock.Anything, mock.Anything).Run(func(args 
mock.Arguments) {
-                       dst := args.Get(0).(*models.BambooProject)
-                       *dst = *testBambooProject
-               }).Return(nil).Twice()
-
-               mockDal.On("First", mock.Anything, mock.Anything).Run(func(args 
mock.Arguments) {
-                       dst := args.Get(0).(*models.BambooTransformationRule)
-                       *dst = *testTransformationRule
-               }).Return(nil).Once()
+                       switch dst := args.Get(0).(type) {
+                       case *models.BambooConnection:
+                               *dst = *testBambooConnection
+                       case *models.BambooProject:
+                               *dst = *testBambooProject
+                       case *models.BambooScopeConfig:
+                               *dst = *testScopeConfig
+                       }
+               }).Return(nil)
        })
        connectionHelper = helper.NewConnectionHelper(
                basicRes,
diff --git a/backend/plugins/bamboo/api/blueprint_v200.go 
b/backend/plugins/bamboo/api/blueprint_v200.go
index 3ce938993..7fdf12f43 100644
--- a/backend/plugins/bamboo/api/blueprint_v200.go
+++ b/backend/plugins/bamboo/api/blueprint_v200.go
@@ -19,6 +19,7 @@ package api
 
 import (
        "fmt"
+
        "github.com/apache/incubator-devlake/plugins/bamboo/models"
 
        "github.com/apache/incubator-devlake/core/errors"
@@ -64,14 +65,19 @@ func makeScopeV200(connectionId uint64, scopes 
[]*plugin.BlueprintScopeV200) ([]
                id := 
didgen.NewDomainIdGenerator(&models.BambooProject{}).Generate(connectionId, 
scope.Id)
 
                // get project from db
-               BambooProject, err := 
GetProjectByConnectionIdAndscopeId(connectionId, scope.Id)
+               project, err := 
GetProjectByConnectionIdAndscopeId(connectionId, scope.Id)
+               if err != nil {
+                       return nil, err
+               }
+
+               scopeConfig, err := GetScopeConfigByproject(project)
                if err != nil {
                        return nil, err
                }
 
                // add cicd_scope to scopes
-               if utils.StringsContains(scope.Entities, 
plugin.DOMAIN_TYPE_CICD) {
-                       scopeCICD := devops.NewCicdScope(id, BambooProject.Name)
+               if utils.StringsContains(scopeConfig.Entities, 
plugin.DOMAIN_TYPE_CICD) {
+                       scopeCICD := devops.NewCicdScope(id, project.Name)
 
                        sc = append(sc, scopeCICD)
                }
@@ -95,8 +101,7 @@ func makePipelinePlanV200(
                        return nil, err
                }
 
-               // get transformationRuleId
-               transformationRules, err := 
GetTransformationRuleByproject(project)
+               scopeConfig, err := GetScopeConfigByproject(project)
                if err != nil {
                        return nil, err
                }
@@ -105,10 +110,10 @@ func makePipelinePlanV200(
                options := make(map[string]interface{})
                options["connectionId"] = connection.ID
                options["projectKey"] = scope.Id
-               options["transformationRuleId"] = transformationRules.ID
+               options["scopeConfigId"] = scopeConfig.ID
 
                // construct subtasks
-               subtasks, err := helper.MakePipelinePlanSubtasks(subtaskMetas, 
scope.Entities)
+               subtasks, err := helper.MakePipelinePlanSubtasks(subtaskMetas, 
scopeConfig.Entities)
                if err != nil {
                        return nil, err
                }
@@ -140,22 +145,22 @@ func GetProjectByConnectionIdAndscopeId(connectionId 
uint64, scopeId string) (*m
        return project, nil
 }
 
-// GetTransformationRuleByproject get the GetTransformationRule by project
-func GetTransformationRuleByproject(project *models.BambooProject) 
(*models.BambooTransformationRule, errors.Error) {
-       transformationRules := &models.BambooTransformationRule{}
-       transformationRuleId := project.TransformationRuleId
-       if transformationRuleId != 0 {
+// GetScopeConfigByproject get the BambooScopeConfig by project
+func GetScopeConfigByproject(project *models.BambooProject) 
(*models.BambooScopeConfig, errors.Error) {
+       scopeConfig := &models.BambooScopeConfig{}
+       scopeConfigId := project.ScopeConfigId
+       if scopeConfigId != 0 {
                db := basicRes.GetDal()
-               err := db.First(transformationRules, dal.Where("id = ?", 
transformationRuleId))
+               err := db.First(scopeConfig, dal.Where("id = ?", scopeConfigId))
                if err != nil {
                        if db.IsErrorNotFound(err) {
-                               return nil, errors.Default.Wrap(err, 
fmt.Sprintf("can not find transformationRules by transformationRuleId [%d]", 
transformationRuleId))
+                               return nil, errors.Default.Wrap(err, 
fmt.Sprintf("can not find ScopeConfig by ScopeConfig [%d]", scopeConfigId))
                        }
-                       return nil, errors.Default.Wrap(err, fmt.Sprintf("fail 
to find transformationRules by transformationRuleId [%d]", 
transformationRuleId))
+                       return nil, errors.Default.Wrap(err, fmt.Sprintf("fail 
to find ScopeConfig by ScopeConfig [%d]", scopeConfigId))
                }
        } else {
-               transformationRules.ID = 0
+               scopeConfig.ID = 0
        }
 
-       return transformationRules, nil
+       return scopeConfig, nil
 }
diff --git a/backend/plugins/bamboo/api/init.go 
b/backend/plugins/bamboo/api/init.go
index 71b3bd589..e6833f341 100644
--- a/backend/plugins/bamboo/api/init.go
+++ b/backend/plugins/bamboo/api/init.go
@@ -26,9 +26,9 @@ import (
 
 var vld *validator.Validate
 var connectionHelper *api.ConnectionApiHelper
-var scopeHelper *api.ScopeApiHelper[models.BambooConnection, 
models.BambooProject, models.BambooTransformationRule]
+var scopeHelper *api.ScopeApiHelper[models.BambooConnection, 
models.BambooProject, models.BambooScopeConfig]
 var remoteHelper *api.RemoteApiHelper[models.BambooConnection, 
models.BambooProject, models.ApiBambooProject, api.NoRemoteGroupResponse]
-var trHelper *api.TransformationRuleHelper[models.BambooTransformationRule]
+var scopeConfigHelper *api.ScopeConfigHelper[models.BambooScopeConfig]
 
 var basicRes context.BasicRes
 
@@ -39,7 +39,7 @@ func Init(br context.BasicRes) {
                basicRes,
                vld,
        )
-       scopeHelper = api.NewScopeHelper[models.BambooConnection, 
models.BambooProject, models.BambooTransformationRule](
+       scopeHelper = api.NewScopeHelper[models.BambooConnection, 
models.BambooProject, models.BambooScopeConfig](
                basicRes,
                vld,
                connectionHelper,
@@ -49,7 +49,7 @@ func Init(br context.BasicRes) {
                vld,
                connectionHelper,
        )
-       trHelper = 
api.NewTransformationRuleHelper[models.BambooTransformationRule](
+       scopeConfigHelper = api.NewScopeConfigHelper[models.BambooScopeConfig](
                basicRes,
                vld,
        )
diff --git a/backend/plugins/bamboo/api/scope.go 
b/backend/plugins/bamboo/api/scope.go
index 3b318da8f..0870eabb2 100644
--- a/backend/plugins/bamboo/api/scope.go
+++ b/backend/plugins/bamboo/api/scope.go
@@ -26,7 +26,7 @@ import (
 
 type ScopeRes struct {
        models.BambooProject
-       TransformationRuleName string `json:"transformationRuleName,omitempty"`
+       ScopeConfigName string `json:"scopeConfigName,omitempty"`
 }
 
 type ScopeReq api.ScopeReq[models.BambooProject]
diff --git a/backend/plugins/bamboo/api/scope_config.go 
b/backend/plugins/bamboo/api/scope_config.go
new file mode 100644
index 000000000..5890fe3d8
--- /dev/null
+++ b/backend/plugins/bamboo/api/scope_config.go
@@ -0,0 +1,83 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package api
+
+import (
+       "github.com/apache/incubator-devlake/core/errors"
+       "github.com/apache/incubator-devlake/core/plugin"
+)
+
+// CreateScopeConfig create scope config for Bamboo
+// @Summary create scope config for Bamboo
+// @Description create scope config for Bamboo
+// @Tags plugins/bamboo
+// @Accept application/json
+// @Param connectionId path int true "connectionId"
+// @Param scopeConfig body models.BambooScopeConfig true "scope config"
+// @Success 200  {object} models.BambooScopeConfig
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/bamboo/connections/{connectionId}/scope_configs [POST]
+func CreateScopeConfig(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
+       return scopeConfigHelper.Create(input)
+}
+
+// UpdateScopeConfig update scope config for Bamboo
+// @Summary update scope config for Bamboo
+// @Description update scope config for Bamboo
+// @Tags plugins/bamboo
+// @Accept application/json
+// @Param id path int true "id"
+// @Param scopeConfig body models.BambooScopeConfig true "scope config"
+// @Param connectionId path int true "connectionId"
+// @Success 200  {object} models.BambooScopeConfig
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/bamboo/connections/{connectionId}/scope_configs/{id} 
[PATCH]
+func UpdateScopeConfig(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
+       return scopeConfigHelper.Update(input)
+}
+
+// GetScopeConfig return onescope config
+// @Summary return onescope config
+// @Description return onescope config
+// @Tags plugins/bamboo
+// @Param id path int true "id"
+// @Param connectionId path int true "connectionId"
+// @Success 200  {object} models.BambooScopeConfig
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/bamboo/connections/{connectionId}/scope_configs/{id} [GET]
+func GetScopeConfig(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
+       return scopeConfigHelper.Get(input)
+}
+
+// GetScopeConfigList return all scope configs
+// @Summary return all scope configs
+// @Description return all scope configs
+// @Tags plugins/bamboo
+// @Param pageSize query int false "page size, default 50"
+// @Param page query int false "page size, default 1"
+// @Param connectionId path int true "connectionId"
+// @Success 200  {object} []models.BambooScopeConfig
+// @Failure 400  {object} shared.ApiBody "Bad Request"
+// @Failure 500  {object} shared.ApiBody "Internal Error"
+// @Router /plugins/bamboo/connections/{connectionId}/scope_configs [GET]
+func GetScopeConfigList(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
+       return scopeConfigHelper.List(input)
+}
diff --git a/backend/plugins/bamboo/api/transformation_rule.go 
b/backend/plugins/bamboo/api/transformation_rule.go
deleted file mode 100644
index 99e6812e5..000000000
--- a/backend/plugins/bamboo/api/transformation_rule.go
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package api
-
-import (
-       "github.com/apache/incubator-devlake/core/errors"
-       "github.com/apache/incubator-devlake/core/plugin"
-)
-
-// CreateTransformationRule create transformation rule for Bamboo
-// @Summary create transformation rule for Bamboo
-// @Description create transformation rule for Bamboo
-// @Tags plugins/bamboo
-// @Accept application/json
-// @Param connectionId path int true "connectionId"
-// @Param transformationRule body models.BambooTransformationRule true 
"transformation rule"
-// @Success 200  {object} models.BambooTransformationRule
-// @Failure 400  {object} shared.ApiBody "Bad Request"
-// @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/bamboo/connections/{connectionId}/transformation_rules 
[POST]
-func CreateTransformationRule(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
-       return trHelper.Create(input)
-}
-
-// UpdateTransformationRule update transformation rule for Bamboo
-// @Summary update transformation rule for Bamboo
-// @Description update transformation rule for Bamboo
-// @Tags plugins/bamboo
-// @Accept application/json
-// @Param id path int true "id"
-// @Param transformationRule body models.BambooTransformationRule true 
"transformation rule"
-// @Param connectionId path int true "connectionId"
-// @Success 200  {object} models.BambooTransformationRule
-// @Failure 400  {object} shared.ApiBody "Bad Request"
-// @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router 
/plugins/bamboo/connections/{connectionId}/transformation_rules/{id} [PATCH]
-func UpdateTransformationRule(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
-       return trHelper.Update(input)
-}
-
-// GetTransformationRule return one transformation rule
-// @Summary return one transformation rule
-// @Description return one transformation rule
-// @Tags plugins/bamboo
-// @Param id path int true "id"
-// @Param connectionId path int true "connectionId"
-// @Success 200  {object} models.BambooTransformationRule
-// @Failure 400  {object} shared.ApiBody "Bad Request"
-// @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router 
/plugins/bamboo/connections/{connectionId}/transformation_rules/{id} [GET]
-func GetTransformationRule(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
-       return trHelper.Get(input)
-}
-
-// GetTransformationRuleList return all transformation rules
-// @Summary return all transformation rules
-// @Description return all transformation rules
-// @Tags plugins/bamboo
-// @Param pageSize query int false "page size, default 50"
-// @Param page query int false "page size, default 1"
-// @Param connectionId path int true "connectionId"
-// @Success 200  {object} []models.BambooTransformationRule
-// @Failure 400  {object} shared.ApiBody "Bad Request"
-// @Failure 500  {object} shared.ApiBody "Internal Error"
-// @Router /plugins/bamboo/connections/{connectionId}/transformation_rules 
[GET]
-func GetTransformationRuleList(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, errors.Error) {
-       return trHelper.List(input)
-}
diff --git a/backend/plugins/bamboo/bamboo.go b/backend/plugins/bamboo/bamboo.go
index 72233823e..c89d0bc63 100644
--- a/backend/plugins/bamboo/bamboo.go
+++ b/backend/plugins/bamboo/bamboo.go
@@ -38,7 +38,7 @@ func main() {
                runner.DirectRun(cmd, args, PluginEntry, map[string]interface{}{
                        "connectionId": *connectionId,
                        "projectKey":   *projectKey,
-                       "transformationRules": map[string]string{
+                       "scopeConfig": map[string]string{
                                "deploymentPattern": *deploymentPattern,
                                "productionPattern": *productionPattern,
                        },
diff --git a/backend/plugins/bamboo/e2e/deploy_build_test.go 
b/backend/plugins/bamboo/e2e/deploy_build_test.go
index e5ea6657a..8fac7a33e 100644
--- a/backend/plugins/bamboo/e2e/deploy_build_test.go
+++ b/backend/plugins/bamboo/e2e/deploy_build_test.go
@@ -36,7 +36,7 @@ func TestBambooDeployBuildDataFlow(t *testing.T) {
                Options: &models.BambooOptions{
                        ConnectionId: 1,
                        ProjectKey:   "TEST1",
-                       BambooTransformationRule: 
&models.BambooTransformationRule{
+                       BambooScopeConfig: &models.BambooScopeConfig{
                                DeploymentPattern: "(?i)release",
                                ProductionPattern: "(?i)release",
                        },
diff --git a/backend/plugins/bamboo/e2e/deploy_test.go 
b/backend/plugins/bamboo/e2e/deploy_test.go
index 7d809a4e8..079043a94 100644
--- a/backend/plugins/bamboo/e2e/deploy_test.go
+++ b/backend/plugins/bamboo/e2e/deploy_test.go
@@ -31,9 +31,9 @@ func TestBambooDeployDataFlow(t *testing.T) {
        dataflowTester := e2ehelper.NewDataFlowTester(t, "bamboo", bamboo)
        taskData := &tasks.BambooTaskData{
                Options: &models.BambooOptions{
-                       ConnectionId:             3,
-                       ProjectKey:               "TEST1",
-                       BambooTransformationRule: 
new(models.BambooTransformationRule),
+                       ConnectionId:      3,
+                       ProjectKey:        "TEST1",
+                       BambooScopeConfig: new(models.BambooScopeConfig),
                },
        }
 
diff --git a/backend/plugins/bamboo/e2e/job_build_test.go 
b/backend/plugins/bamboo/e2e/job_build_test.go
index 82677f2f5..1c8ef1c6c 100644
--- a/backend/plugins/bamboo/e2e/job_build_test.go
+++ b/backend/plugins/bamboo/e2e/job_build_test.go
@@ -37,7 +37,7 @@ func TestBambooJobBuildDataFlow(t *testing.T) {
                Options: &models.BambooOptions{
                        ConnectionId: 3,
                        ProjectKey:   "TEST1",
-                       BambooTransformationRule: 
&models.BambooTransformationRule{
+                       BambooScopeConfig: &models.BambooScopeConfig{
                                DeploymentPattern: "(?i)compile",
                                ProductionPattern: "(?i)compile",
                        },
diff --git a/backend/plugins/bamboo/e2e/job_test.go 
b/backend/plugins/bamboo/e2e/job_test.go
index 7dab01e9a..c1a32db8c 100644
--- a/backend/plugins/bamboo/e2e/job_test.go
+++ b/backend/plugins/bamboo/e2e/job_test.go
@@ -35,7 +35,7 @@ func TestBambooJobDataFlow(t *testing.T) {
                Options: &models.BambooOptions{
                        ConnectionId: 3,
                        ProjectKey:   "TEST1",
-                       BambooTransformationRule: 
&models.BambooTransformationRule{
+                       BambooScopeConfig: &models.BambooScopeConfig{
                                DeploymentPattern: "(?i)compile",
                                ProductionPattern: "(?i)compile",
                        },
diff --git a/backend/plugins/bamboo/e2e/plan_build_commits_test.go 
b/backend/plugins/bamboo/e2e/plan_build_commits_test.go
index cf695f845..35a40b42d 100644
--- a/backend/plugins/bamboo/e2e/plan_build_commits_test.go
+++ b/backend/plugins/bamboo/e2e/plan_build_commits_test.go
@@ -36,7 +36,7 @@ func TestBambooPlanBuildCommitsDataFlow(t *testing.T) {
                Options: &models.BambooOptions{
                        ConnectionId: 3,
                        ProjectKey:   "TEST1",
-                       BambooTransformationRule: 
&models.BambooTransformationRule{
+                       BambooScopeConfig: &models.BambooScopeConfig{
                                DeploymentPattern: "(?i)compile",
                                ProductionPattern: "(?i)compile",
                        },
diff --git a/backend/plugins/bamboo/e2e/plan_build_test.go 
b/backend/plugins/bamboo/e2e/plan_build_test.go
index 5e1bd9d8d..775b668de 100644
--- a/backend/plugins/bamboo/e2e/plan_build_test.go
+++ b/backend/plugins/bamboo/e2e/plan_build_test.go
@@ -38,7 +38,7 @@ func TestBambooPlanBuildDataFlow(t *testing.T) {
                Options: &models.BambooOptions{
                        ConnectionId: 3,
                        ProjectKey:   "TEST1",
-                       BambooTransformationRule: 
&models.BambooTransformationRule{
+                       BambooScopeConfig: &models.BambooScopeConfig{
                                DeploymentPattern: "(?i)compile",
                                ProductionPattern: "(?i)compile",
                        },
diff --git a/backend/plugins/bamboo/e2e/plan_test.go 
b/backend/plugins/bamboo/e2e/plan_test.go
index 648b46c45..361f27b42 100644
--- a/backend/plugins/bamboo/e2e/plan_test.go
+++ b/backend/plugins/bamboo/e2e/plan_test.go
@@ -33,9 +33,9 @@ func TestBambooPlanDataFlow(t *testing.T) {
 
        taskData := &tasks.BambooTaskData{
                Options: &models.BambooOptions{
-                       ConnectionId:             3,
-                       ProjectKey:               "TEST1",
-                       BambooTransformationRule: 
new(models.BambooTransformationRule),
+                       ConnectionId:      3,
+                       ProjectKey:        "TEST1",
+                       BambooScopeConfig: new(models.BambooScopeConfig),
                },
        }
        // import raw data table
diff --git a/backend/plugins/bamboo/impl/impl.go 
b/backend/plugins/bamboo/impl/impl.go
index 499e81947..dc19f9e54 100644
--- a/backend/plugins/bamboo/impl/impl.go
+++ b/backend/plugins/bamboo/impl/impl.go
@@ -33,17 +33,15 @@ import (
 )
 
 // make sure interface is implemented
-var _ interface {
-       plugin.PluginMeta
-       plugin.PluginInit
-       plugin.PluginTask
-       plugin.PluginModel
-       plugin.PluginMigration
-       plugin.PluginBlueprintV100
-       plugin.DataSourcePluginBlueprintV200
-       plugin.CloseablePluginTask
-       plugin.PluginSource
-} = (*Bamboo)(nil)
+var _ plugin.PluginMeta = (*Bamboo)(nil)
+var _ plugin.PluginInit = (*Bamboo)(nil)
+var _ plugin.PluginTask = (*Bamboo)(nil)
+var _ plugin.PluginModel = (*Bamboo)(nil)
+var _ plugin.PluginMigration = (*Bamboo)(nil)
+var _ plugin.PluginBlueprintV100 = (*Bamboo)(nil)
+var _ plugin.DataSourcePluginBlueprintV200 = (*Bamboo)(nil)
+var _ plugin.CloseablePluginTask = (*Bamboo)(nil)
+var _ plugin.PluginSource = (*Bamboo)(nil)
 
 type Bamboo struct{}
 
@@ -60,7 +58,7 @@ func (p Bamboo) Scope() interface{} {
        return nil
 }
 
-func (p Bamboo) TransformationRule() interface{} {
+func (p Bamboo) ScopeConfig() interface{} {
        return nil
 }
 
@@ -150,26 +148,26 @@ func (p Bamboo) PrepareTaskData(taskCtx 
plugin.TaskContext, options map[string]i
                                return nil, err
                        }
                }
-               op.TransformationRuleId = scope.TransformationRuleId
+               op.ScopeConfigId = scope.ScopeConfigId
                if err != nil {
                        return nil, errors.Default.Wrap(err, fmt.Sprintf("fail 
to find project: %s", op.ProjectKey))
                }
        }
 
-       if op.BambooTransformationRule == nil && op.TransformationRuleId != 0 {
-               var transformationRule models.BambooTransformationRule
+       if op.BambooScopeConfig == nil && op.ScopeConfigId != 0 {
+               var scopeConfig models.BambooScopeConfig
                db := taskCtx.GetDal()
-               err = db.First(&transformationRule, dal.Where("id = ?", 
op.TransformationRuleId))
+               err = db.First(&scopeConfig, dal.Where("id = ?", 
op.ScopeConfigId))
                if err != nil {
                        if db.IsErrorNotFound(err) {
-                               return nil, errors.Default.Wrap(err, 
fmt.Sprintf("can not find transformationRules by transformationRuleId [%d]", 
op.TransformationRuleId))
+                               return nil, errors.Default.Wrap(err, 
fmt.Sprintf("can not find scopeConfig by scopeConfigId [%d]", op.ScopeConfigId))
                        }
-                       return nil, errors.Default.Wrap(err, fmt.Sprintf("fail 
to find transformationRules by transformationRuleId [%d]", 
op.TransformationRuleId))
+                       return nil, errors.Default.Wrap(err, fmt.Sprintf("fail 
to find scopeConfig by scopeConfigId [%d]", op.ScopeConfigId))
                }
-               op.BambooTransformationRule = &transformationRule
+               op.BambooScopeConfig = &scopeConfig
        }
-       if op.BambooTransformationRule == nil && op.TransformationRuleId == 0 {
-               op.BambooTransformationRule = 
new(models.BambooTransformationRule)
+       if op.BambooScopeConfig == nil && op.ScopeConfigId == 0 {
+               op.BambooScopeConfig = new(models.BambooScopeConfig)
        }
        regexEnricher := helper.NewRegexEnricher()
        if err := regexEnricher.TryAdd(devops.DEPLOYMENT, 
op.DeploymentPattern); err != nil {
@@ -208,13 +206,13 @@ func (p Bamboo) ApiResources() 
map[string]map[string]plugin.ApiResourceHandler {
                        "PATCH":  api.PatchConnection,
                        "DELETE": api.DeleteConnection,
                },
-               "connections/:connectionId/transformation_rules": {
-                       "POST": api.CreateTransformationRule,
-                       "GET":  api.GetTransformationRuleList,
+               "connections/:connectionId/scope_configs": {
+                       "POST": api.CreateScopeConfig,
+                       "GET":  api.GetScopeConfigList,
                },
-               "connections/:connectionId/transformation_rules/:id": {
-                       "PATCH": api.UpdateTransformationRule,
-                       "GET":   api.GetTransformationRule,
+               "connections/:connectionId/scope_configs/:id": {
+                       "PATCH": api.UpdateScopeConfig,
+                       "GET":   api.GetScopeConfig,
                },
                "connections/:connectionId/scopes": {
                        "GET": api.GetScopeList,
diff --git 
a/backend/plugins/bamboo/models/migrationscripts/20230322_add_connection_id_to_transformation_rules.go
 
b/backend/plugins/bamboo/models/migrationscripts/20230322_add_connection_id_to_transformation_rules.go
index a72397df0..95d637750 100644
--- 
a/backend/plugins/bamboo/models/migrationscripts/20230322_add_connection_id_to_transformation_rules.go
+++ 
b/backend/plugins/bamboo/models/migrationscripts/20230322_add_connection_id_to_transformation_rules.go
@@ -22,7 +22,7 @@ import (
        "github.com/apache/incubator-devlake/core/dal"
        "github.com/apache/incubator-devlake/core/errors"
        "github.com/apache/incubator-devlake/helpers/migrationhelper"
-       "github.com/apache/incubator-devlake/plugins/bamboo/models"
+       
"github.com/apache/incubator-devlake/plugins/bamboo/models/migrationscripts/archived"
 )
 
 type addConnectionIdToTransformationRule struct{}
@@ -39,7 +39,7 @@ func (u *addConnectionIdToTransformationRule) Up(baseRes 
context.BasicRes) error
        if err != nil {
                return err
        }
-       var scopes []models.BambooProject
+       var scopes []archived.BambooProject
        err = baseRes.GetDal().All(&scopes)
        if err != nil {
                return err
@@ -54,14 +54,14 @@ func (u *addConnectionIdToTransformationRule) Up(baseRes 
context.BasicRes) error
        // set connection_id for rules
        for trId, cId := range idMap {
                err = baseRes.GetDal().UpdateColumn(
-                       &models.BambooTransformationRule{}, "connection_id", 
cId,
+                       &archived.BambooTransformationRule{}, "connection_id", 
cId,
                        dal.Where("id = ?", trId))
                if err != nil {
                        return err
                }
        }
        // delete all rules that are not referenced.
-       return baseRes.GetDal().Delete(&models.BambooTransformationRule{}, 
dal.Where("connection_id = ? OR connection_id = ?", nil, 0))
+       return baseRes.GetDal().Delete(&archived.BambooTransformationRule{}, 
dal.Where("connection_id = ? OR connection_id = ?", nil, 0))
 }
 
 func (*addConnectionIdToTransformationRule) Version() uint64 {
diff --git 
a/backend/plugins/bamboo/models/migrationscripts/20230518_scope_config.go 
b/backend/plugins/bamboo/models/migrationscripts/20230518_scope_config.go
new file mode 100644
index 000000000..847a5a0fd
--- /dev/null
+++ b/backend/plugins/bamboo/models/migrationscripts/20230518_scope_config.go
@@ -0,0 +1,56 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+       "github.com/apache/incubator-devlake/core/context"
+       "github.com/apache/incubator-devlake/core/errors"
+       "github.com/apache/incubator-devlake/helpers/migrationhelper"
+)
+
+type renameTr2ScopeConfig struct {
+}
+
+type scopeConfig20230518 struct {
+       Entities []string `gorm:"type:json" json:"entities"`
+}
+
+func (scopeConfig20230518) TableName() string {
+       return "_tool_bamboo_scope_configs"
+}
+
+func (u *renameTr2ScopeConfig) Up(baseRes context.BasicRes) errors.Error {
+       db := baseRes.GetDal()
+       err := db.RenameColumn("_tool_bamboo_projects", 
"transformation_rule_id", "scope_config_id")
+       if err != nil {
+               return err
+       }
+       err = db.RenameTable("_tool_bamboo_transformation_rules", 
"_tool_bamboo_scope_configs")
+       if err != nil {
+               return err
+       }
+       return migrationhelper.AutoMigrateTables(baseRes, 
&scopeConfig20230518{})
+}
+
+func (*renameTr2ScopeConfig) Version() uint64 {
+       return 20230518141352
+}
+
+func (*renameTr2ScopeConfig) Name() string {
+       return "rename transformation rule to scope config"
+}
diff --git a/backend/plugins/bamboo/models/migrationscripts/register.go 
b/backend/plugins/bamboo/models/migrationscripts/register.go
index 1d63cccba..a8b234e29 100644
--- a/backend/plugins/bamboo/models/migrationscripts/register.go
+++ b/backend/plugins/bamboo/models/migrationscripts/register.go
@@ -27,5 +27,6 @@ func All() []plugin.MigrationScript {
                new(addInitTables),
                new(addConnectionIdToTransformationRule),
                new(addTypeAndEnvironment),
+               new(renameTr2ScopeConfig),
        }
 }
diff --git a/backend/plugins/bamboo/models/project.go 
b/backend/plugins/bamboo/models/project.go
index 56fe9879d..d7b745eea 100644
--- a/backend/plugins/bamboo/models/project.go
+++ b/backend/plugins/bamboo/models/project.go
@@ -19,6 +19,7 @@ package models
 
 import (
        "encoding/json"
+
        "github.com/apache/incubator-devlake/core/models/common"
        "github.com/apache/incubator-devlake/core/plugin"
        "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
@@ -29,14 +30,14 @@ var _ plugin.ApiGroup = (*api.NoRemoteGroupResponse)(nil)
 var _ plugin.ApiScope = (*ApiBambooProject)(nil)
 
 type BambooProject struct {
-       ConnectionId         uint64 `json:"connectionId" 
mapstructure:"connectionId" validate:"required" gorm:"primaryKey"`
-       ProjectKey           string `json:"projectKey" 
gorm:"primaryKey;type:varchar(256)" validate:"required"`
-       TransformationRuleId uint64 `json:"transformationRuleId,omitempty" 
mapstructure:"transformationRuleId"`
-       Name                 string `json:"name" gorm:"index;type:varchar(256)"`
-       Description          string `json:"description"`
-       Href                 string `json:"link"`
-       Rel                  string `json:"rel" gorm:"type:varchar(100)"`
-       common.NoPKModel     `json:"-" mapstructure:"-"`
+       ConnectionId     uint64 `json:"connectionId" 
mapstructure:"connectionId" validate:"required" gorm:"primaryKey"`
+       ProjectKey       string `json:"projectKey" 
gorm:"primaryKey;type:varchar(256)" validate:"required"`
+       ScopeConfigId    uint64 `json:"scopeConfigId,omitempty" 
mapstructure:"scopeConfigId"`
+       Name             string `json:"name" gorm:"index;type:varchar(256)"`
+       Description      string `json:"description"`
+       Href             string `json:"link"`
+       Rel              string `json:"rel" gorm:"type:varchar(100)"`
+       common.NoPKModel `json:"-" mapstructure:"-"`
 }
 
 func (p BambooProject) ScopeId() string {
diff --git a/backend/plugins/bamboo/models/transformation_rule.go 
b/backend/plugins/bamboo/models/scope_config.go
similarity index 74%
rename from backend/plugins/bamboo/models/transformation_rule.go
rename to backend/plugins/bamboo/models/scope_config.go
index d4be4e9a5..66d424303 100644
--- a/backend/plugins/bamboo/models/transformation_rule.go
+++ b/backend/plugins/bamboo/models/scope_config.go
@@ -22,16 +22,16 @@ import (
        "gorm.io/datatypes"
 )
 
-type BambooTransformationRule struct {
-       common.Model
-       ConnectionId uint64 `mapstructure:"connectionId" json:"connectionId"`
-       Name         string 
`gorm:"type:varchar(255);index:idx_name_gitlab,unique" validate:"required" 
mapstructure:"name" json:"name"`
+type BambooScopeConfig struct {
+       common.ScopeConfig `mapstructure:",squash" json:",inline" 
gorm:"embedded"`
+       ConnectionId       uint64 `mapstructure:"connectionId" 
json:"connectionId"`
+       Name               string 
`gorm:"type:varchar(255);index:idx_name_gitlab,unique" validate:"required" 
mapstructure:"name" json:"name"`
        // should be {realRepoName: [bamboo_repoId]}
        RepoMap           datatypes.JSONMap
        DeploymentPattern string `mapstructure:"deploymentPattern,omitempty" 
json:"deploymentPattern" gorm:"type:varchar(255)"`
        ProductionPattern string `mapstructure:"productionPattern,omitempty" 
json:"productionPattern" gorm:"type:varchar(255)"`
 }
 
-func (BambooTransformationRule) TableName() string {
-       return "_tool_bamboo_transformation_rules"
+func (BambooScopeConfig) TableName() string {
+       return "_tool_bamboo_scope_configs"
 }
diff --git a/backend/plugins/bamboo/models/task.go 
b/backend/plugins/bamboo/models/task.go
index 827f37110..84dc69648 100644
--- a/backend/plugins/bamboo/models/task.go
+++ b/backend/plugins/bamboo/models/task.go
@@ -27,9 +27,9 @@ type BambooOptions struct {
        // options means some custom params required by plugin running.
        // Such As How many rows do your want
        // You can use it in sub tasks and you need pass it in main.go and 
pipelines.
-       ConnectionId              uint64   `json:"connectionId"`
-       ProjectKey                string   `json:"projectKey"`
-       Tasks                     []string `json:"tasks,omitempty"`
-       TransformationRuleId      uint64   `mapstructure:"transformationRuleId" 
json:"transformationRuleId"`
-       *BambooTransformationRule `mapstructure:"transformationRules" 
json:"transformationRules"`
+       ConnectionId       uint64   `json:"connectionId"`
+       ProjectKey         string   `json:"projectKey"`
+       Tasks              []string `json:"tasks,omitempty"`
+       ScopeConfigId      uint64   `mapstructure:"scopeConfigId" 
json:"scopeConfigId"`
+       *BambooScopeConfig `mapstructure:"scopeConfig" json:"scopeConfig"`
 }
diff --git a/backend/plugins/bamboo/tasks/deploy_build_extractor.go 
b/backend/plugins/bamboo/tasks/deploy_build_extractor.go
index 7c8da8e7f..01022c312 100644
--- a/backend/plugins/bamboo/tasks/deploy_build_extractor.go
+++ b/backend/plugins/bamboo/tasks/deploy_build_extractor.go
@@ -31,7 +31,6 @@ var _ plugin.SubTaskEntryPoint = ExtractDeployBuild
 
 func ExtractDeployBuild(taskCtx plugin.SubTaskContext) errors.Error {
        rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, 
RAW_DEPLOY_BUILD_TABLE)
-       //repoMap := getRepoMap(data.Options.BambooTransformationRule.RepoMap)
        extractor, err := helper.NewApiExtractor(helper.ApiExtractorArgs{
                RawDataSubTaskArgs: *rawDataSubTaskArgs,
 
diff --git a/backend/plugins/bamboo/tasks/job_build_extractor.go 
b/backend/plugins/bamboo/tasks/job_build_extractor.go
index 6d6608297..2cca09dc9 100644
--- a/backend/plugins/bamboo/tasks/job_build_extractor.go
+++ b/backend/plugins/bamboo/tasks/job_build_extractor.go
@@ -32,7 +32,6 @@ var _ plugin.SubTaskEntryPoint = ExtractJobBuild
 
 func ExtractJobBuild(taskCtx plugin.SubTaskContext) errors.Error {
        rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, 
RAW_JOB_BUILD_TABLE)
-       //repoMap := getRepoMap(data.Options.BambooTransformationRule.RepoMap)
        extractor, err := helper.NewApiExtractor(helper.ApiExtractorArgs{
                RawDataSubTaskArgs: *rawDataSubTaskArgs,
 
diff --git a/backend/server/services/remote/plugin/plugin_extensions.go 
b/backend/server/services/remote/plugin/plugin_extensions.go
index 538e50f38..73cc68220 100644
--- a/backend/server/services/remote/plugin/plugin_extensions.go
+++ b/backend/server/services/remote/plugin/plugin_extensions.go
@@ -69,7 +69,8 @@ func (p remoteDatasourcePlugin) 
MakeDataSourcePipelinePlanV200(connectionId uint
                toolScopeTxRulePairs[i] = 
[]interface{}{wrappedToolScope.Unwrap(), txRule}
        }
 
-       entities := bpScopes[0].Entities
+       // TODO: @camille: no need to pass the entities separately as they are 
already in the scope config (tx rule)
+       entities := []string{}
 
        plan_data := models.PipelineData{}
        err = p.invoker.Call("make-pipeline", bridge.DefaultContext, 
toolScopeTxRulePairs, entities, connection.Unwrap()).Get(&plan_data)


Reply via email to