You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by he...@apache.org on 2023/05/05 15:30:51 UTC
[incubator-devlake] branch main updated: chore: Remove old go azure plugin (#5106)
This is an automated email from the ASF dual-hosted git repository.
hez 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 72b01ef8f chore: Remove old go azure plugin (#5106)
72b01ef8f is described below
commit 72b01ef8f1f43d084655845060b048919810d8f6
Author: Camille Teruel <ca...@gmail.com>
AuthorDate: Fri May 5 17:30:45 2023 +0200
chore: Remove old go azure plugin (#5106)
Co-authored-by: Camille Teruel <ca...@meri.co>
---
backend/plugins/azure/api/blueprint.go | 63 --------
backend/plugins/azure/api/connection.go | 159 ---------------------
backend/plugins/azure/api/init.go | 37 -----
backend/plugins/azure/azure.go | 42 ------
backend/plugins/azure/e2e/build_definition_test.go | 64 ---------
.../_raw_azure_api_build_definitions.csv | 13 --
.../e2e/raw_tables/_raw_azure_api_repositories.csv | 2 -
backend/plugins/azure/e2e/repo_test.go | 63 --------
.../_tool_azure_build_definitions.csv | 13 --
.../e2e/snapshot_tables/_tool_azure_repos.csv | 2 -
backend/plugins/azure/impl/impl.go | 140 ------------------
backend/plugins/azure/models/build.go | 42 ------
backend/plugins/azure/models/build_definition.go | 44 ------
backend/plugins/azure/models/connection.go | 38 -----
.../migrationscripts/20220825_add_init_tables.go | 44 ------
.../migrationscripts/archived/build_definition.go | 44 ------
.../models/migrationscripts/archived/connection.go | 62 --------
.../azure/models/migrationscripts/archived/repo.go | 41 ------
.../azure/models/migrationscripts/register.go | 29 ----
backend/plugins/azure/models/repo.go | 41 ------
backend/plugins/azure/models/response.go | 18 ---
backend/plugins/azure/tasks/api_client.go | 49 -------
.../azure/tasks/build_definition_collector.go | 72 ----------
.../azure/tasks/build_definition_extractor.go | 138 ------------------
backend/plugins/azure/tasks/repo_collector.go | 78 ----------
backend/plugins/azure/tasks/repo_extractor.go | 115 ---------------
backend/plugins/azure/tasks/task_data.go | 56 --------
27 files changed, 1509 deletions(-)
diff --git a/backend/plugins/azure/api/blueprint.go b/backend/plugins/azure/api/blueprint.go
deleted file mode 100644
index 9bb8edae9..000000000
--- a/backend/plugins/azure/api/blueprint.go
+++ /dev/null
@@ -1,63 +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 (
- "encoding/json"
- "github.com/apache/incubator-devlake/core/errors"
- "github.com/apache/incubator-devlake/core/plugin"
- helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "github.com/apache/incubator-devlake/plugins/jenkins/tasks"
-)
-
-func MakePipelinePlan(subtaskMetas []plugin.SubTaskMeta, connectionId uint64, scope []*plugin.BlueprintScopeV100) (plugin.PipelinePlan, errors.Error) {
- var err errors.Error
- plan := make(plugin.PipelinePlan, len(scope))
- for i, scopeElem := range scope {
- // handle taskOptions and transformationRules, by dumping them to taskOptions
- taskOptions := make(map[string]interface{})
- err1 := json.Unmarshal(scopeElem.Options, &taskOptions)
- if err1 != nil {
- return nil, errors.Default.Wrap(err, "unable to deserialize pipeline task options")
- }
- taskOptions["connectionId"] = connectionId
- op, err := tasks.DecodeTaskOptions(taskOptions)
- if err != nil {
- return nil, err
- }
- _, err = tasks.ValidateTaskOptions(op)
- if err != nil {
- return nil, err
- }
- // subtasks
- subtasks, err := helper.MakePipelinePlanSubtasks(subtaskMetas, scopeElem.Entities)
- if err != nil {
- return nil, err
- }
- stage := plugin.PipelineStage{
- {
- Plugin: "azure",
- Subtasks: subtasks,
- Options: taskOptions,
- },
- }
-
- plan[i] = stage
- }
- return plan, nil
-}
diff --git a/backend/plugins/azure/api/connection.go b/backend/plugins/azure/api/connection.go
deleted file mode 100644
index 285bcc84a..000000000
--- a/backend/plugins/azure/api/connection.go
+++ /dev/null
@@ -1,159 +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 (
- "context"
- "net/http"
-
- "github.com/apache/incubator-devlake/server/api/shared"
-
- "github.com/apache/incubator-devlake/core/errors"
- plugin "github.com/apache/incubator-devlake/core/plugin"
- "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "github.com/apache/incubator-devlake/plugins/azure/models"
-)
-
-type AzureTestConnResponse struct {
- shared.ApiBody
- Connection *models.AzureConn
-}
-
-// @Summary test azure connection
-// @Description Test azure Connection. endpoint: "https://dev.azure.com/{organization}/
-// @Tags plugins/azure
-// @Param body body models.AzureConn true "json body"
-// @Success 200 {object} AzureTestConnResponse "Success"
-// @Failure 400 {string} errcode.Error "Bad Request"
-// @Failure 500 {string} errcode.Error "Internal Error"
-// @Router /plugins/azure/test [POST]
-func TestConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
- // decode
- var connection models.AzureConn
- if err := api.Decode(input.Body, &connection, vld); err != nil {
- return nil, errors.BadInput.Wrap(err, "could not decode request parameters")
- }
- // test connection
- apiClient, err := api.NewApiClientFromConnection(context.TODO(), basicRes, &connection)
- if err != nil {
- return nil, err
- }
-
- res, err := apiClient.Get("_apis/projects", nil, nil)
- if err != nil {
- return nil, err
- }
-
- if res.StatusCode == http.StatusUnauthorized {
- return nil, errors.HttpStatus(http.StatusBadRequest).New("StatusUnauthorized error while testing connection")
- }
- if res.StatusCode != http.StatusOK {
- return nil, errors.HttpStatus(res.StatusCode).New("unexpected status code while testing connection")
- }
- body := AzureTestConnResponse{}
- body.Success = true
- body.Message = "success"
- body.Connection = &connection
- // output
- return &plugin.ApiResourceOutput{Body: body, Status: 200}, nil
-}
-
-// @Summary create azure connection
-// @Description Create azure connection
-// @Tags plugins/azure
-// @Param body body models.AzureConnection true "json body"
-// @Success 200 {object} models.AzureConnection
-// @Failure 400 {string} errcode.Error "Bad Request"
-// @Failure 500 {string} errcode.Error "Internal Error"
-// @Router /plugins/azure/connections [POST]
-func PostConnections(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
- // create a new connection
- connection := &models.AzureConnection{}
-
- // update from request and save to database
- err := connectionHelper.Create(connection, input)
- if err != nil {
- return nil, err
- }
- return &plugin.ApiResourceOutput{Body: connection, Status: http.StatusOK}, nil
-}
-
-// @Summary patch azure connection
-// @Description Patch azure connection
-// @Tags plugins/azure
-// @Param body body models.AzureConnection true "json body"
-// @Success 200 {object} models.AzureConnection
-// @Failure 400 {string} errcode.Error "Bad Request"
-// @Failure 500 {string} errcode.Error "Internal Error"
-// @Router /plugins/azure/connections/{connectionId} [PATCH]
-func PatchConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
- connection := &models.AzureConnection{}
- err := connectionHelper.Patch(connection, input)
- if err != nil {
- return nil, err
- }
-
- return &plugin.ApiResourceOutput{Body: connection}, nil
-}
-
-// @Summary delete a azure connection
-// @Description Delete a azure connection
-// @Tags plugins/azure
-// @Success 200 {object} models.AzureConnection
-// @Failure 400 {string} errcode.Error "Bad Request"
-// @Failure 500 {string} errcode.Error "Internal Error"
-// @Router /plugins/azure/connections/{connectionId} [DELETE]
-func DeleteConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
- connection := &models.AzureConnection{}
- err := connectionHelper.First(connection, input.Params)
- if err != nil {
- return nil, err
- }
- err = connectionHelper.Delete(connection)
- return &plugin.ApiResourceOutput{Body: connection}, err
-}
-
-// @Summary get all azure connections
-// @Description Get all azure connections
-// @Tags plugins/azure
-// @Success 200 {object} []models.AzureConnection
-// @Failure 400 {string} errcode.Error "Bad Request"
-// @Failure 500 {string} errcode.Error "Internal Error"
-// @Router /plugins/azure/connections [GET]
-func ListConnections(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
- var connections []models.AzureConnection
- err := connectionHelper.List(&connections)
- if err != nil {
- return nil, err
- }
-
- return &plugin.ApiResourceOutput{Body: connections, Status: http.StatusOK}, nil
-}
-
-// @Summary get azure connection detail
-// @Description Get azure connection detail
-// @Tags plugins/azure
-// @Success 200 {object} models.AzureConnection
-// @Failure 400 {string} errcode.Error "Bad Request"
-// @Failure 500 {string} errcode.Error "Internal Error"
-// @Router /plugins/azure/connections/{connectionId} [GET]
-func GetConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
- connection := &models.AzureConnection{}
- err := connectionHelper.First(connection, input.Params)
- return &plugin.ApiResourceOutput{Body: connection}, err
-}
diff --git a/backend/plugins/azure/api/init.go b/backend/plugins/azure/api/init.go
deleted file mode 100644
index d92c2b334..000000000
--- a/backend/plugins/azure/api/init.go
+++ /dev/null
@@ -1,37 +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/context"
- "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "github.com/go-playground/validator/v10"
-)
-
-var vld *validator.Validate
-var connectionHelper *api.ConnectionApiHelper
-var basicRes context.BasicRes
-
-func Init(br context.BasicRes) {
- basicRes = br
- vld = validator.New()
- connectionHelper = api.NewConnectionHelper(
- basicRes,
- vld,
- )
-}
diff --git a/backend/plugins/azure/azure.go b/backend/plugins/azure/azure.go
deleted file mode 100644
index fb1fab3e7..000000000
--- a/backend/plugins/azure/azure.go
+++ /dev/null
@@ -1,42 +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 main
-
-import (
- "github.com/apache/incubator-devlake/core/runner"
- "github.com/apache/incubator-devlake/plugins/azure/impl"
- "github.com/spf13/cobra"
-)
-
-var PluginEntry impl.Azure
-
-// standalone mode for debugging
-func main() {
- cmd := &cobra.Command{Use: "azure"}
-
- connectionId := cmd.Flags().Uint64P("connection", "c", 1, "azure connection id")
- project := cmd.Flags().StringP("project", "p", "", "azure project name")
-
- cmd.Run = func(cmd *cobra.Command, args []string) {
- runner.DirectRun(cmd, args, PluginEntry, map[string]interface{}{
- "connectionId": *connectionId,
- "project": *project,
- })
- }
- runner.RunCmd(cmd)
-}
diff --git a/backend/plugins/azure/e2e/build_definition_test.go b/backend/plugins/azure/e2e/build_definition_test.go
deleted file mode 100644
index 01ab51899..000000000
--- a/backend/plugins/azure/e2e/build_definition_test.go
+++ /dev/null
@@ -1,64 +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 e2e
-
-import (
- "github.com/apache/incubator-devlake/helpers/e2ehelper"
- "github.com/apache/incubator-devlake/plugins/azure/impl"
- "github.com/apache/incubator-devlake/plugins/azure/models"
- "github.com/apache/incubator-devlake/plugins/azure/tasks"
- "testing"
-)
-
-func TestAzureBuildDefinitionDataFlow(t *testing.T) {
- var github impl.Azure
- dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", github)
-
- taskData := &tasks.AzureTaskData{
- Options: &tasks.AzureOptions{
- ConnectionId: 1,
- Project: "test",
- },
- }
-
- // import raw data table
- // SELECT * FROM _raw_azure_api_build_definitions INTO OUTFILE "/tmp/_raw_azure_api_build_definitions.csv" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n';
- dataflowTester.ImportCsvIntoRawTable("./raw_tables/_raw_azure_api_build_definitions.csv", "_raw_azure_api_build_definitions")
-
- // verify extraction
- dataflowTester.FlushTabler(&models.AzureBuildDefinition{})
- dataflowTester.Subtask(tasks.ExtractApiBuildDefinitionMeta, taskData)
- dataflowTester.VerifyTable(
- models.AzureBuildDefinition{},
- "./snapshot_tables/_tool_azure_build_definitions.csv",
- e2ehelper.ColumnWithRawData(
- "connection_id",
- "project_id",
- "azure_id",
- "author_id",
- "queue_id",
- "url",
- "name",
- "path",
- "type",
- "queue_status",
- "revision",
- "azure_created_date",
- ),
- )
-}
diff --git a/backend/plugins/azure/e2e/raw_tables/_raw_azure_api_build_definitions.csv b/backend/plugins/azure/e2e/raw_tables/_raw_azure_api_build_definitions.csv
deleted file mode 100644
index 4007e82ec..000000000
--- a/backend/plugins/azure/e2e/raw_tables/_raw_azure_api_build_definitions.csv
+++ /dev/null
@@ -1,13 +0,0 @@
-id,params,data,url,input,created_at
-4,"{""ConnectionId"":1,""Project"":""test""}","{""_links"":{""self"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/1?revision=1""},""web"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/definition?definitionId=1""},""editor"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/designer?id=1&_a=edit-build-definition""},""badge"":{""href"":""https://dev.az [...]
-5,"{""ConnectionId"":1,""Project"":""test""}","{""_links"":{""self"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1""},""web"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/definition?definitionId=2""},""editor"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/designer?id=2&_a=edit-build-definition""},""badge"":{""href"":""https://dev.az [...]
-6,"{""ConnectionId"":1,""Project"":""test""}","{""_links"":{""self"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1""},""web"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/definition?definitionId=3""},""editor"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/designer?id=3&_a=edit-build-definition""},""badge"":{""href"":""https://dev.az [...]
-7,"{""ConnectionId"":1,""Project"":""test""}","{""_links"":{""self"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1""},""web"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/definition?definitionId=4""},""editor"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/designer?id=4&_a=edit-build-definition""},""badge"":{""href"":""https://dev.az [...]
-8,"{""ConnectionId"":1,""Project"":""test""}","{""_links"":{""self"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1""},""web"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/definition?definitionId=5""},""editor"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/designer?id=5&_a=edit-build-definition""},""badge"":{""href"":""https://dev.az [...]
-9,"{""ConnectionId"":1,""Project"":""test""}","{""_links"":{""self"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1""},""web"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/definition?definitionId=6""},""editor"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/designer?id=6&_a=edit-build-definition""},""badge"":{""href"":""https://dev.az [...]
-10,"{""ConnectionId"":1,""Project"":""test""}","{""_links"":{""self"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1""},""web"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/definition?definitionId=7""},""editor"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/designer?id=7&_a=edit-build-definition""},""badge"":{""href"":""https://dev.a [...]
-11,"{""ConnectionId"":1,""Project"":""test""}","{""_links"":{""self"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1""},""web"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/definition?definitionId=8""},""editor"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/designer?id=8&_a=edit-build-definition""},""badge"":{""href"":""https://dev.a [...]
-12,"{""ConnectionId"":1,""Project"":""test""}","{""_links"":{""self"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1""},""web"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/definition?definitionId=9""},""editor"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/designer?id=9&_a=edit-build-definition""},""badge"":{""href"":""https://dev.a [...]
-13,"{""ConnectionId"":1,""Project"":""test""}","{""_links"":{""self"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1""},""web"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/definition?definitionId=10""},""editor"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/designer?id=10&_a=edit-build-definition""},""badge"":{""href"":""https://dev [...]
-14,"{""ConnectionId"":1,""Project"":""test""}","{""_links"":{""self"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1""},""web"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/definition?definitionId=11""},""editor"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/designer?id=11&_a=edit-build-definition""},""badge"":{""href"":""https://dev [...]
-15,"{""ConnectionId"":1,""Project"":""test""}","{""_links"":{""self"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1""},""web"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/definition?definitionId=12""},""editor"":{""href"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_build/designer?id=12&_a=edit-build-definition""},""badge"":{""href"":""https://dev [...]
diff --git a/backend/plugins/azure/e2e/raw_tables/_raw_azure_api_repositories.csv b/backend/plugins/azure/e2e/raw_tables/_raw_azure_api_repositories.csv
deleted file mode 100644
index d9bb7df71..000000000
--- a/backend/plugins/azure/e2e/raw_tables/_raw_azure_api_repositories.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-id,params,data,url,input,created_at
-5,"{""ConnectionId"":1,""Project"":""test""}","{""id"":""5dc348ab-98a9-4c49-95da-b70b24a62932"",""name"":""test"",""url"":""https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/git/repositories/5dc348ab-98a9-4c49-95da-b70b24a62932"",""project"":{""id"":""30473eea-ca3f-4f40-a711-9cfa2e75e4b0"",""name"":""test"",""url"":""https://dev.azure.com/mericojzc/_apis/projects/30473eea-ca3f-4f40-a711-9cfa2e75e4b0"",""state"":""wellFormed"",""revision"":11,""visibility"":""priv [...]
\ No newline at end of file
diff --git a/backend/plugins/azure/e2e/repo_test.go b/backend/plugins/azure/e2e/repo_test.go
deleted file mode 100644
index 0864974f7..000000000
--- a/backend/plugins/azure/e2e/repo_test.go
+++ /dev/null
@@ -1,63 +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 e2e
-
-import (
- "github.com/apache/incubator-devlake/helpers/e2ehelper"
- "github.com/apache/incubator-devlake/plugins/azure/impl"
- "github.com/apache/incubator-devlake/plugins/azure/models"
- "github.com/apache/incubator-devlake/plugins/azure/tasks"
- "testing"
-)
-
-func TestAzureRepoDataFlow(t *testing.T) {
- var github impl.Azure
- dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", github)
-
- taskData := &tasks.AzureTaskData{
- Options: &tasks.AzureOptions{
- ConnectionId: 1,
- Project: "test",
- },
- }
-
- // import raw data table
- // SELECT * FROM _raw_azure_api_repositories INTO OUTFILE "/tmp/_raw_azure_api_repositories.csv" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n';
- dataflowTester.ImportCsvIntoRawTable("./raw_tables/_raw_azure_api_repositories.csv", "_raw_azure_api_repositories")
-
- // verify extraction
- dataflowTester.FlushTabler(&models.AzureRepo{})
- dataflowTester.Subtask(tasks.ExtractApiRepoMeta, taskData)
- dataflowTester.VerifyTable(
- models.AzureRepo{},
- "./snapshot_tables/_tool_azure_repos.csv",
- e2ehelper.ColumnWithRawData(
- "connection_id",
- "azure_id",
- "name",
- "url",
- "project_id",
- "default_branch",
- "size",
- "remote_url",
- "ssh_url",
- "web_url",
- "is_disabled",
- ),
- )
-}
diff --git a/backend/plugins/azure/e2e/snapshot_tables/_tool_azure_build_definitions.csv b/backend/plugins/azure/e2e/snapshot_tables/_tool_azure_build_definitions.csv
deleted file mode 100644
index d85190197..000000000
--- a/backend/plugins/azure/e2e/snapshot_tables/_tool_azure_build_definitions.csv
+++ /dev/null
@@ -1,13 +0,0 @@
-connection_id,project_id,azure_id,author_id,queue_id,url,name,path,type,queue_status,revision,azure_created_date,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
-1,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,1,2b39fa56-bd8f-6805-94e2-16e535dfb387,9,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/1?revision=1,test,\\,build,enabled,1,2022-08-25T16:12:50.260+00:00,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_build_definitions,4,
-1,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,2,2b39fa56-bd8f-6805-94e2-16e535dfb387,9,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1,test (1),\\,build,enabled,1,2022-09-02T14:56:10.680+00:00,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_build_definitions,5,
-1,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,3,2b39fa56-bd8f-6805-94e2-16e535dfb387,9,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1,test (2),\\,build,enabled,1,2022-09-02T14:56:10.680+00:00,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_build_definitions,6,
-1,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,4,2b39fa56-bd8f-6805-94e2-16e535dfb387,9,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1,test (3),\\,build,enabled,1,2022-09-02T14:56:10.680+00:00,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_build_definitions,7,
-1,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,5,2b39fa56-bd8f-6805-94e2-16e535dfb387,9,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1,test (4),\\,build,enabled,1,2022-09-02T14:56:10.680+00:00,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_build_definitions,8,
-1,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,6,2b39fa56-bd8f-6805-94e2-16e535dfb387,9,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1,test (5),\\,build,enabled,1,2022-09-02T14:56:10.680+00:00,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_build_definitions,9,
-1,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,7,2b39fa56-bd8f-6805-94e2-16e535dfb387,9,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1,test (6),\\,build,enabled,1,2022-09-02T14:56:10.680+00:00,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_build_definitions,10,
-1,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,8,2b39fa56-bd8f-6805-94e2-16e535dfb387,9,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1,test (7),\\,build,enabled,1,2022-09-02T14:56:10.680+00:00,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_build_definitions,11,
-1,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,9,2b39fa56-bd8f-6805-94e2-16e535dfb387,9,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1,test (8),\\,build,enabled,1,2022-09-02T14:56:10.680+00:00,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_build_definitions,12,
-1,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,10,2b39fa56-bd8f-6805-94e2-16e535dfb387,9,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1,test (9),\\,build,enabled,1,2022-09-02T14:56:10.680+00:00,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_build_definitions,13,
-1,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,11,2b39fa56-bd8f-6805-94e2-16e535dfb387,9,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1,test (10),\\,build,enabled,1,2022-09-02T14:56:10.680+00:00,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_build_definitions,14,
-1,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,12,2b39fa56-bd8f-6805-94e2-16e535dfb387,9,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/build/Definitions/2?revision=1,test (11),\\,build,enabled,1,2022-09-02T14:56:10.680+00:00,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_build_definitions,15,
diff --git a/backend/plugins/azure/e2e/snapshot_tables/_tool_azure_repos.csv b/backend/plugins/azure/e2e/snapshot_tables/_tool_azure_repos.csv
deleted file mode 100644
index 22e50dac4..000000000
--- a/backend/plugins/azure/e2e/snapshot_tables/_tool_azure_repos.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-connection_id,azure_id,name,url,project_id,default_branch,size,remote_url,ssh_url,web_url,is_disabled,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
-1,5dc348ab-98a9-4c49-95da-b70b24a62932,test,https://dev.azure.com/mericojzc/30473eea-ca3f-4f40-a711-9cfa2e75e4b0/_apis/git/repositories/5dc348ab-98a9-4c49-95da-b70b24a62932,30473eea-ca3f-4f40-a711-9cfa2e75e4b0,refs/heads/asf-site,38627917,https://mericojzc@dev.azure.com/mericojzc/test/_git/test,git@ssh.dev.azure.com:v3/mericojzc/test/test,https://dev.azure.com/mericojzc/test/_git/test,0,"{""ConnectionId"":1,""Project"":""test""}",_raw_azure_api_repositories,5,
diff --git a/backend/plugins/azure/impl/impl.go b/backend/plugins/azure/impl/impl.go
deleted file mode 100644
index 9dc7f3f8b..000000000
--- a/backend/plugins/azure/impl/impl.go
+++ /dev/null
@@ -1,140 +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 impl
-
-import (
- "fmt"
- "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/plugin"
- helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "github.com/apache/incubator-devlake/plugins/azure/api"
- "github.com/apache/incubator-devlake/plugins/azure/models"
- "github.com/apache/incubator-devlake/plugins/azure/models/migrationscripts"
- "github.com/apache/incubator-devlake/plugins/azure/tasks"
-)
-
-// make sure interface is implemented
-var _ plugin.PluginMeta = (*Azure)(nil)
-var _ plugin.PluginInit = (*Azure)(nil)
-var _ plugin.PluginTask = (*Azure)(nil)
-var _ plugin.PluginApi = (*Azure)(nil)
-var _ plugin.PluginModel = (*Azure)(nil)
-var _ plugin.CloseablePluginTask = (*Azure)(nil)
-var _ plugin.PluginMigration = (*Azure)(nil)
-
-// PluginEntry exports for Framework to search and load
-var PluginEntry Azure //nolint
-
-type Azure struct{}
-
-func (p Azure) Description() string {
- return "collect some Azure data"
-}
-
-func (p Azure) Init(basicRes context.BasicRes) errors.Error {
- api.Init(basicRes)
- return nil
-}
-
-func (p Azure) GetTablesInfo() []dal.Tabler {
- return []dal.Tabler{
- &models.AzureBuild{},
- &models.AzureBuildDefinition{},
- &models.AzureConnection{},
- &models.AzureRepo{},
- }
-}
-
-func (p Azure) SubTaskMetas() []plugin.SubTaskMeta {
- return []plugin.SubTaskMeta{
- tasks.CollectApiRepoMeta,
- tasks.ExtractApiRepoMeta,
- tasks.CollectApiBuildDefinitionMeta,
- tasks.ExtractApiBuildDefinitionMeta,
- }
-}
-
-func (p Azure) PrepareTaskData(taskCtx plugin.TaskContext, options map[string]interface{}) (interface{}, errors.Error) {
- op, err := tasks.DecodeAndValidateTaskOptions(options)
- if err != nil {
- return nil, err
- }
- if op.ConnectionId == 0 {
- return nil, errors.Default.New("connectionId is invalid")
- }
-
- connection := &models.AzureConnection{}
- connectionHelper := helper.NewConnectionHelper(
- taskCtx,
- nil,
- )
- if err != nil {
- return nil, err
- }
- err = connectionHelper.FirstById(connection, op.ConnectionId)
- if err != nil {
- return nil, err
- }
-
- apiClient, err := tasks.CreateApiClient(taskCtx, connection)
- if err != nil {
- return nil, err
- }
- return &tasks.AzureTaskData{
- Options: op,
- ApiClient: apiClient,
- Connection: connection,
- }, nil
-}
-
-// PkgPath information lost when compiled as plugin(.so)
-func (p Azure) RootPkgPath() string {
- return "github.com/apache/incubator-devlake/plugins/azure"
-}
-
-func (p Azure) ApiResources() map[string]map[string]plugin.ApiResourceHandler {
- return map[string]map[string]plugin.ApiResourceHandler{
- "test": {
- "POST": api.TestConnection,
- },
- "connections": {
- "POST": api.PostConnections,
- "GET": api.ListConnections,
- },
- "connections/:connectionId": {
- "GET": api.GetConnection,
- "PATCH": api.PatchConnection,
- "DELETE": api.DeleteConnection,
- },
- }
-}
-
-func (p Azure) MigrationScripts() []plugin.MigrationScript {
- return migrationscripts.All()
-}
-
-func (p Azure) Close(taskCtx plugin.TaskContext) errors.Error {
- data, ok := taskCtx.GetData().(*tasks.AzureTaskData)
- if !ok {
- return errors.Default.New(fmt.Sprintf("GetData failed when try to close %+v", taskCtx))
- }
- data.ApiClient.Release()
- return nil
-}
diff --git a/backend/plugins/azure/models/build.go b/backend/plugins/azure/models/build.go
deleted file mode 100644
index 94956baf3..000000000
--- a/backend/plugins/azure/models/build.go
+++ /dev/null
@@ -1,42 +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 models
-
-import (
- "github.com/apache/incubator-devlake/core/models/common"
- "time"
-)
-
-type AzureBuild struct {
- common.NoPKModel
- // collected fields
- ConnectionId uint64 `gorm:"primaryKey"`
- JobName string `gorm:"primaryKey;type:varchar(255)"`
- Duration float64 // build time
- DisplayName string `gorm:"type:varchar(255)"` // "#7"
- EstimatedDuration float64 // EstimatedDuration
- Number int64 `gorm:"primaryKey"`
- Result string // Result
- Timestamp int64 // start time
- StartTime time.Time // convered by timestamp
- CommitSha string `gorm:"type:varchar(255)"`
-}
-
-func (AzureBuild) TableName() string {
- return "_tool_azure_builds"
-}
diff --git a/backend/plugins/azure/models/build_definition.go b/backend/plugins/azure/models/build_definition.go
deleted file mode 100644
index d110f154b..000000000
--- a/backend/plugins/azure/models/build_definition.go
+++ /dev/null
@@ -1,44 +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 models
-
-import (
- "github.com/apache/incubator-devlake/core/models/common"
- "time"
-)
-
-type AzureBuildDefinition struct {
- common.NoPKModel
- // collected fields
- ConnectionId uint64 `gorm:"primaryKey"`
- ProjectId string `gorm:"primaryKey;type:varchar(255)"`
- AzureId int `gorm:"primaryKey"`
- AuthorId string `gorm:"type:varchar(255)"`
- QueueId int
- Url string `gorm:"type:varchar(255)"`
- Name string `gorm:"type:varchar(255)"`
- Path string `gorm:"type:varchar(255)"`
- Type string `gorm:"type:varchar(255)"`
- QueueStatus string `json:"queueStatus" gorm:"type:varchar(255)"`
- Revision int `json:"revision"`
- AzureCreatedDate time.Time `json:"createdDate"`
-}
-
-func (AzureBuildDefinition) TableName() string {
- return "_tool_azure_build_definitions"
-}
diff --git a/backend/plugins/azure/models/connection.go b/backend/plugins/azure/models/connection.go
deleted file mode 100644
index 4d58ec368..000000000
--- a/backend/plugins/azure/models/connection.go
+++ /dev/null
@@ -1,38 +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 models
-
-import (
- helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
-)
-
-// AzureConn holds the essential information to connect to the Azure API
-type AzureConn struct {
- helper.RestConnection `mapstructure:",squash"`
- helper.BasicAuth `mapstructure:",squash"`
-}
-
-// AzureConnection holds AzureConn plus ID/Name for database storage
-type AzureConnection struct {
- helper.BaseConnection `mapstructure:",squash"`
- AzureConn `mapstructure:",squash"`
-}
-
-func (AzureConnection) TableName() string {
- return "_tool_azure_connections"
-}
diff --git a/backend/plugins/azure/models/migrationscripts/20220825_add_init_tables.go b/backend/plugins/azure/models/migrationscripts/20220825_add_init_tables.go
deleted file mode 100644
index 55ffe890c..000000000
--- a/backend/plugins/azure/models/migrationscripts/20220825_add_init_tables.go
+++ /dev/null
@@ -1,44 +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 migrationscripts
-
-import (
- "github.com/apache/incubator-devlake/core/context"
- "github.com/apache/incubator-devlake/core/errors"
- "github.com/apache/incubator-devlake/helpers/migrationhelper"
- "github.com/apache/incubator-devlake/plugins/azure/models/migrationscripts/archived"
-)
-
-type addInitTables20220825 struct{}
-
-func (*addInitTables20220825) Up(basicRes context.BasicRes) errors.Error {
- return migrationhelper.AutoMigrateTables(
- basicRes,
- &archived.AzureConnection{},
- &archived.AzureRepo{},
- &archived.AzureBuildDefinition{},
- )
-}
-
-func (*addInitTables20220825) Version() uint64 {
- return 20220825231237
-}
-
-func (*addInitTables20220825) Name() string {
- return "Azure init schemas"
-}
diff --git a/backend/plugins/azure/models/migrationscripts/archived/build_definition.go b/backend/plugins/azure/models/migrationscripts/archived/build_definition.go
deleted file mode 100644
index 6ba4e1ed6..000000000
--- a/backend/plugins/azure/models/migrationscripts/archived/build_definition.go
+++ /dev/null
@@ -1,44 +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 archived
-
-import (
- "github.com/apache/incubator-devlake/core/models/migrationscripts/archived"
- "time"
-)
-
-type AzureBuildDefinition struct {
- archived.NoPKModel
- // collected fields
- ConnectionId uint64 `gorm:"primaryKey"`
- ProjectId string `gorm:"primaryKey;type:varchar(255)"`
- AzureId int `gorm:"primaryKey"`
- AuthorId string `gorm:"type:varchar(255)"`
- QueueId int
- Url string `gorm:"type:varchar(255)"`
- Name string `gorm:"type:varchar(255)"`
- Path string `gorm:"type:varchar(255)"`
- Type string `gorm:"type:varchar(255)"`
- QueueStatus string `json:"queueStatus" gorm:"type:varchar(255)"`
- Revision int `json:"revision"`
- AzureCreatedDate time.Time `json:"createdDate"`
-}
-
-func (AzureBuildDefinition) TableName() string {
- return "_tool_azure_build_definitions"
-}
diff --git a/backend/plugins/azure/models/migrationscripts/archived/connection.go b/backend/plugins/azure/models/migrationscripts/archived/connection.go
deleted file mode 100644
index 8dc5dd861..000000000
--- a/backend/plugins/azure/models/migrationscripts/archived/connection.go
+++ /dev/null
@@ -1,62 +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 archived
-
-import (
- "github.com/apache/incubator-devlake/core/models/migrationscripts/archived"
-)
-
-type BaseConnection struct {
- Name string `gorm:"type:varchar(100);uniqueIndex" json:"name" validate:"required"`
- archived.Model
-}
-
-type BasicAuth struct {
- Username string `mapstructure:"username" validate:"required" json:"username"`
- Password string `mapstructure:"password" validate:"required" json:"password" encrypt:"yes"`
-}
-
-type RestConnection struct {
- BaseConnection `mapstructure:",squash"`
- Endpoint string `mapstructure:"endpoint" validate:"required" json:"endpoint"`
- Proxy string `mapstructure:"proxy" json:"proxy"`
- RateLimitPerHour int `comment:"api request rate limt per hour" json:"rateLimit"`
-}
-
-// This object conforms to what the frontend currently sends.
-type AzureConnection struct {
- RestConnection `mapstructure:",squash"`
- BasicAuth `mapstructure:",squash"`
-}
-
-type AzureResponse struct {
- ID int `json:"id"`
- Name string `json:"name"`
- AzureConnection
-}
-
-type TestConnectionRequest struct {
- Endpoint string `json:"endpoint" validate:"required"`
- Username string `json:"username" validate:"required"`
- Password string `json:"password" validate:"required"`
- Proxy string `json:"proxy"`
-}
-
-func (AzureConnection) TableName() string {
- return "_tool_azure_connections"
-}
diff --git a/backend/plugins/azure/models/migrationscripts/archived/repo.go b/backend/plugins/azure/models/migrationscripts/archived/repo.go
deleted file mode 100644
index a4213bdbd..000000000
--- a/backend/plugins/azure/models/migrationscripts/archived/repo.go
+++ /dev/null
@@ -1,41 +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 archived
-
-import (
- "github.com/apache/incubator-devlake/core/models/migrationscripts/archived"
-)
-
-type AzureRepo struct {
- ConnectionId uint64 `gorm:"primaryKey"`
- AzureId string `gorm:"primaryKey;type:varchar(255)" json:"id"`
- Name string `gorm:"type:varchar(255)" json:"name"`
- Url string `gorm:"type:varchar(255)" json:"url"`
- ProjectId string `gorm:"type:varchar(255);index"`
- DefaultBranch string `json:"defaultBranch"`
- Size int `json:"size"`
- RemoteURL string `json:"remoteUrl"`
- SshUrl string `gorm:"type:varchar(255)" json:"sshUrl"`
- WebUrl string `gorm:"type:varchar(255)" json:"webUrl"`
- IsDisabled bool `json:"isDisabled"`
- archived.NoPKModel
-}
-
-func (AzureRepo) TableName() string {
- return "_tool_azure_repos"
-}
diff --git a/backend/plugins/azure/models/migrationscripts/register.go b/backend/plugins/azure/models/migrationscripts/register.go
deleted file mode 100644
index 7ccbc6e2d..000000000
--- a/backend/plugins/azure/models/migrationscripts/register.go
+++ /dev/null
@@ -1,29 +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 migrationscripts
-
-import (
- plugin "github.com/apache/incubator-devlake/core/plugin"
-)
-
-// All return all the migration scripts
-func All() []plugin.MigrationScript {
- return []plugin.MigrationScript{
- new(addInitTables20220825),
- }
-}
diff --git a/backend/plugins/azure/models/repo.go b/backend/plugins/azure/models/repo.go
deleted file mode 100644
index 1619b1747..000000000
--- a/backend/plugins/azure/models/repo.go
+++ /dev/null
@@ -1,41 +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 models
-
-import (
- "github.com/apache/incubator-devlake/core/models/common"
-)
-
-type AzureRepo struct {
- ConnectionId uint64 `gorm:"primaryKey"`
- AzureId string `gorm:"primaryKey;type:varchar(255)" json:"id"`
- Name string `gorm:"type:varchar(255)" json:"name"`
- Url string `gorm:"type:varchar(255)" json:"url"`
- ProjectId string `gorm:"type:varchar(255);index"`
- DefaultBranch string `json:"defaultBranch"`
- Size int `json:"size"`
- RemoteURL string `json:"remoteUrl"`
- SshUrl string `gorm:"type:varchar(255)" json:"sshUrl"`
- WebUrl string `gorm:"type:varchar(255)" json:"webUrl"`
- IsDisabled bool `json:"isDisabled"`
- common.NoPKModel
-}
-
-func (AzureRepo) TableName() string {
- return "_tool_azure_repos"
-}
diff --git a/backend/plugins/azure/models/response.go b/backend/plugins/azure/models/response.go
deleted file mode 100644
index 556be1890..000000000
--- a/backend/plugins/azure/models/response.go
+++ /dev/null
@@ -1,18 +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 models
diff --git a/backend/plugins/azure/tasks/api_client.go b/backend/plugins/azure/tasks/api_client.go
deleted file mode 100644
index cb0853156..000000000
--- a/backend/plugins/azure/tasks/api_client.go
+++ /dev/null
@@ -1,49 +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 tasks
-
-import (
- "github.com/apache/incubator-devlake/core/errors"
- "github.com/apache/incubator-devlake/core/plugin"
- "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "github.com/apache/incubator-devlake/plugins/azure/models"
-)
-
-func CreateApiClient(taskCtx plugin.TaskContext, connection *models.AzureConnection) (*api.ApiAsyncClient, errors.Error) {
- // create synchronize api client so we can calculate api rate limit dynamically
- apiClient, err := api.NewApiClientFromConnection(taskCtx.GetContext(), taskCtx, connection)
- if err != nil {
- return nil, err
- }
-
- // TODO add some check after request if necessary
- // create rate limit calculator
- rateLimiter := &api.ApiRateLimitCalculator{
- UserRateLimitPerHour: connection.RateLimitPerHour,
- }
- asyncApiClient, err := api.CreateAsyncApiClient(
- taskCtx,
- apiClient,
- rateLimiter,
- )
- if err != nil {
- return nil, err
- }
-
- return asyncApiClient, nil
-}
diff --git a/backend/plugins/azure/tasks/build_definition_collector.go b/backend/plugins/azure/tasks/build_definition_collector.go
deleted file mode 100644
index a1609a60a..000000000
--- a/backend/plugins/azure/tasks/build_definition_collector.go
+++ /dev/null
@@ -1,72 +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 tasks
-
-import (
- "encoding/json"
- "github.com/apache/incubator-devlake/core/errors"
- plugin "github.com/apache/incubator-devlake/core/plugin"
- "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "net/http"
- "net/url"
-)
-
-const RAW_BUILD_DEFINITION_TABLE = "azure_api_build_definitions"
-
-var CollectApiBuildDefinitionMeta = plugin.SubTaskMeta{
- Name: "collectApiBuild",
- EntryPoint: CollectApiBuildDefinitions,
- Required: true,
- Description: "Collect BuildDefinition data from Azure api",
- DomainTypes: []string{plugin.DOMAIN_TYPE_CICD},
-}
-
-func CollectApiBuildDefinitions(taskCtx plugin.SubTaskContext) errors.Error {
- data := taskCtx.GetData().(*AzureTaskData)
-
- collector, err := api.NewApiCollector(api.ApiCollectorArgs{
- RawDataSubTaskArgs: api.RawDataSubTaskArgs{
- Ctx: taskCtx,
- Params: AzureApiParams{
- ConnectionId: data.Options.ConnectionId,
- Project: data.Options.Project,
- },
- Table: RAW_BUILD_DEFINITION_TABLE,
- },
- ApiClient: data.ApiClient,
-
- UrlTemplate: "{{ .Params.Project }}/_apis/build/definitions?api-version=7.1-preview.7",
- Query: func(reqData *api.RequestData) (url.Values, errors.Error) {
- query := url.Values{}
- return query, nil
- },
- ResponseParser: func(res *http.Response) ([]json.RawMessage, errors.Error) {
- var data struct {
- Builds []json.RawMessage `json:"value"`
- }
- err := api.UnmarshalResponse(res, &data)
- return data.Builds, err
- },
- })
-
- if err != nil {
- return err
- }
-
- return collector.Execute()
-}
diff --git a/backend/plugins/azure/tasks/build_definition_extractor.go b/backend/plugins/azure/tasks/build_definition_extractor.go
deleted file mode 100644
index e947d6563..000000000
--- a/backend/plugins/azure/tasks/build_definition_extractor.go
+++ /dev/null
@@ -1,138 +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 tasks
-
-import (
- "encoding/json"
- "github.com/apache/incubator-devlake/core/errors"
- plugin "github.com/apache/incubator-devlake/core/plugin"
- "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "github.com/apache/incubator-devlake/plugins/azure/models"
- "time"
-)
-
-type AzureApiBuildDefinition struct {
- Quality string `json:"quality"`
- AuthoredBy struct {
- DisplayName string `json:"displayName"`
- URL string `json:"url"`
- Links struct {
- Avatar struct {
- Href string `json:"href"`
- } `json:"avatar"`
- } `json:"_links"`
- ID string `json:"id"`
- UniqueName string `json:"uniqueName"`
- ImageURL string `json:"imageUrl"`
- Descriptor string `json:"descriptor"`
- } `json:"authoredBy"`
- Queue struct {
- Links struct {
- Self struct {
- Href string `json:"href"`
- } `json:"self"`
- } `json:"_links"`
- ID int `json:"id"`
- Name string `json:"name"`
- URL string `json:"url"`
- Pool struct {
- ID int `json:"id"`
- Name string `json:"name"`
- IsHosted bool `json:"isHosted"`
- } `json:"pool"`
- } `json:"queue"`
- ID int `json:"id"`
- Name string `json:"name"`
- URL string `json:"url"`
- URI string `json:"uri"`
- Path string `json:"path"`
- Type string `json:"type"`
- QueueStatus string `json:"queueStatus"`
- Revision int `json:"revision"`
- CreatedDate time.Time `json:"createdDate"`
- Project struct {
- ID string `json:"id"`
- Name string `json:"name"`
- URL string `json:"url"`
- State string `json:"state"`
- Revision int `json:"revision"`
- Visibility string `json:"visibility"`
- LastUpdateTime time.Time `json:"lastUpdateTime"`
- } `json:"project"`
-}
-
-var ExtractApiBuildDefinitionMeta = plugin.SubTaskMeta{
- Name: "extractApiBuild",
- EntryPoint: ExtractApiBuildDefinition,
- Required: true,
- Description: "Extract raw BuildDefinition data into tool layer table azure_repos",
- DomainTypes: []string{plugin.DOMAIN_TYPE_CICD},
-}
-
-func ExtractApiBuildDefinition(taskCtx plugin.SubTaskContext) errors.Error {
- data := taskCtx.GetData().(*AzureTaskData)
- extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{
- RawDataSubTaskArgs: api.RawDataSubTaskArgs{
- Ctx: taskCtx,
- /*
- This struct will be JSONEncoded and stored into database along with raw data itself, to identity minimal
- set of data to be process, for example, we process JiraIssues by Board
- */
- Params: AzureApiParams{
- ConnectionId: data.Options.ConnectionId,
- Project: data.Options.Project,
- },
- /*
- Table store raw data
- */
- Table: RAW_BUILD_DEFINITION_TABLE,
- },
- Extract: func(row *api.RawData) ([]interface{}, errors.Error) {
- body := &AzureApiBuildDefinition{}
- err := errors.Convert(json.Unmarshal(row.Data, body))
- if err != nil {
- return nil, err
- }
-
- results := make([]interface{}, 0, 1)
- azureBuildDefinition := &models.AzureBuildDefinition{
- ConnectionId: data.Options.ConnectionId,
- ProjectId: body.Project.ID,
- AzureId: body.ID,
- AuthorId: body.AuthoredBy.ID,
- QueueId: body.Queue.ID,
- Url: body.URL,
- Name: body.Name,
- Path: body.Path,
- Type: body.Type,
- QueueStatus: body.QueueStatus,
- Revision: body.Revision,
- AzureCreatedDate: body.CreatedDate,
- }
- results = append(results, azureBuildDefinition)
-
- return results, nil
- },
- })
-
- if err != nil {
- return err
- }
-
- return extractor.Execute()
-}
diff --git a/backend/plugins/azure/tasks/repo_collector.go b/backend/plugins/azure/tasks/repo_collector.go
deleted file mode 100644
index 107c5579c..000000000
--- a/backend/plugins/azure/tasks/repo_collector.go
+++ /dev/null
@@ -1,78 +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 tasks
-
-import (
- "encoding/json"
- "fmt"
- "github.com/apache/incubator-devlake/core/errors"
- plugin "github.com/apache/incubator-devlake/core/plugin"
- "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "net/http"
- "net/url"
-)
-
-const RAW_REPOSITORIES_TABLE = "azure_api_repositories"
-
-var CollectApiRepoMeta = plugin.SubTaskMeta{
- Name: "collectApiRepo",
- EntryPoint: CollectApiRepositories,
- Required: true,
- Description: "Collect repositories data from Azure api",
- DomainTypes: []string{plugin.DOMAIN_TYPE_CODE},
-}
-
-func CollectApiRepositories(taskCtx plugin.SubTaskContext) errors.Error {
- data := taskCtx.GetData().(*AzureTaskData)
-
- collector, err := api.NewApiCollector(api.ApiCollectorArgs{
- RawDataSubTaskArgs: api.RawDataSubTaskArgs{
- Ctx: taskCtx,
- Params: AzureApiParams{
- ConnectionId: data.Options.ConnectionId,
- Project: data.Options.Project,
- },
- Table: RAW_REPOSITORIES_TABLE,
- },
- ApiClient: data.ApiClient,
-
- UrlTemplate: "{{ .Params.Project }}/_apis/git/repositories?api-version=7.1-preview.1",
- Query: func(reqData *api.RequestData) (url.Values, errors.Error) {
- query := url.Values{}
- query.Set("state", "all")
- query.Set("page", fmt.Sprintf("%v", reqData.Pager.Page))
- query.Set("direction", "asc")
- query.Set("per_page", fmt.Sprintf("%v", reqData.Pager.Size))
-
- return query, nil
- },
- ResponseParser: func(res *http.Response) ([]json.RawMessage, errors.Error) {
- var data struct {
- Repos []json.RawMessage `json:"value"`
- }
- err := api.UnmarshalResponse(res, &data)
- return data.Repos, err
- },
- })
-
- if err != nil {
- return err
- }
-
- return collector.Execute()
-}
diff --git a/backend/plugins/azure/tasks/repo_extractor.go b/backend/plugins/azure/tasks/repo_extractor.go
deleted file mode 100644
index 88b479d27..000000000
--- a/backend/plugins/azure/tasks/repo_extractor.go
+++ /dev/null
@@ -1,115 +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 tasks
-
-import (
- "encoding/json"
- "fmt"
- "github.com/apache/incubator-devlake/core/errors"
- plugin "github.com/apache/incubator-devlake/core/plugin"
- "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "github.com/apache/incubator-devlake/plugins/azure/models"
- "time"
-)
-
-type AzureApiRepo struct {
- ID string `json:"id"`
- Name string `json:"name"`
- URL string `json:"url"`
- Project struct {
- ID string `json:"id"`
- Name string `json:"name"`
- URL string `json:"url"`
- State string `json:"state"`
- Revision int `json:"revision"`
- Visibility string `json:"visibility"`
- LastUpdateTime time.Time `json:"lastUpdateTime"`
- } `json:"project"`
- DefaultBranch string `json:"defaultBranch"`
- Size int `json:"size"`
- RemoteURL string `json:"remoteUrl"`
- SSHURL string `json:"sshUrl"`
- WebURL string `json:"webUrl"`
- IsDisabled bool `json:"isDisabled"`
-}
-
-var ExtractApiRepoMeta = plugin.SubTaskMeta{
- Name: "extractApiRepo",
- EntryPoint: ExtractApiRepositories,
- Required: true,
- Description: "Extract raw Repositories data into tool layer table azure_repos",
- DomainTypes: []string{plugin.DOMAIN_TYPE_CODE},
-}
-
-type ApiRepoResponse AzureApiRepo
-
-func ExtractApiRepositories(taskCtx plugin.SubTaskContext) errors.Error {
- data := taskCtx.GetData().(*AzureTaskData)
- extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{
- RawDataSubTaskArgs: api.RawDataSubTaskArgs{
- Ctx: taskCtx,
- /*
- This struct will be JSONEncoded and stored into database along with raw data itself, to identity minimal
- set of data to be process, for example, we process JiraIssues by Board
- */
- Params: AzureApiParams{
- ConnectionId: data.Options.ConnectionId,
- Project: data.Options.Project,
- },
- /*
- Table store raw data
- */
- Table: RAW_REPOSITORIES_TABLE,
- },
- Extract: func(row *api.RawData) ([]interface{}, errors.Error) {
- body := &ApiRepoResponse{}
- err := errors.Convert(json.Unmarshal(row.Data, body))
- if err != nil {
- return nil, err
- }
- if body.ID == "" {
- return nil, errors.Default.New(fmt.Sprintf("repo %s not found", data.Options.Project))
- }
- results := make([]interface{}, 0, 1)
- azureRepository := &models.AzureRepo{
- ConnectionId: data.Options.ConnectionId,
- AzureId: body.ID,
- Name: body.Name,
- Url: body.URL,
- ProjectId: body.Project.ID,
- DefaultBranch: body.DefaultBranch,
- Size: body.Size,
- RemoteURL: body.RemoteURL,
- SshUrl: body.SSHURL,
- WebUrl: body.WebURL,
- IsDisabled: body.IsDisabled,
- }
- data.Repo = azureRepository
-
- results = append(results, azureRepository)
-
- return results, nil
- },
- })
-
- if err != nil {
- return err
- }
-
- return extractor.Execute()
-}
diff --git a/backend/plugins/azure/tasks/task_data.go b/backend/plugins/azure/tasks/task_data.go
deleted file mode 100644
index 605d3fd3e..000000000
--- a/backend/plugins/azure/tasks/task_data.go
+++ /dev/null
@@ -1,56 +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 tasks
-
-import (
- "github.com/apache/incubator-devlake/core/errors"
- "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "github.com/apache/incubator-devlake/plugins/azure/models"
-)
-
-type AzureApiParams struct {
- ConnectionId uint64
- Project string
-}
-
-type AzureOptions struct {
- ConnectionId uint64 `json:"connectionId"`
- Project string
- Since string
- Tasks []string `json:"tasks,omitempty"`
-}
-
-type AzureTaskData struct {
- Options *AzureOptions
- ApiClient *api.ApiAsyncClient
- Connection *models.AzureConnection
- Repo *models.AzureRepo
-}
-
-func DecodeAndValidateTaskOptions(options map[string]interface{}) (*AzureOptions, errors.Error) {
- var op AzureOptions
- err := api.Decode(options, &op, nil)
- if err != nil {
- return nil, errors.Default.Wrap(err, "unable to decode Azure options")
- }
- // find the needed Azure now
- if op.ConnectionId == 0 {
- return nil, errors.BadInput.New("Azure connectionId is invalid")
- }
- return &op, nil
-}