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 2022/09/09 17:09:34 UTC
[incubator-devlake] branch main updated: fix: golangci-lint error (#3032)
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 ef013b89 fix: golangci-lint error (#3032)
ef013b89 is described below
commit ef013b890f53b98b41611f508554c7084d6b3a28
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Sat Sep 10 01:09:31 2022 +0800
fix: golangci-lint error (#3032)
* fix: icla api unused
* fix: rest of linting errors
* fix: linting problem iter 3
* fix: linting strike 4
* fix: linting strike 5
* fix: linting strike 6
* fix: linting strike 7
* fix: linting strike 8
* fix: linting strike 9
* fix: linting strike 10
* fix: linting strike 11
* fix: linting strike 12
* fix: test cases
---
.golangci.yaml | 6 +--
generator/cmd/create_migration.go | 3 +-
generator/cmd/create_plugin.go | 3 +-
generator/template/plugin/plugin_main.go-template | 2 +-
generator/util/template.go | 9 ++--
models/domainlayer/devops/cicd_pipeline.go | 17 ++++++
models/domainlayer/devops/cicd_pipeline_repo.go | 17 ++++++
.../20220711_add_subtasks_table.go | 17 ++++++
.../migrationscripts/20220903_encrypt_blueprint.go | 4 ++
.../migrationscripts/20220904_encrypt_pipeline.go | 4 ++
plugins/ae/tasks/commits_collector.go | 4 +-
plugins/ae/tasks/project_collector.go | 4 +-
plugins/azure/impl/impl.go | 19 ++++++-
plugins/azure/models/build.go | 17 ++++++
plugins/azure/models/build_definition.go | 17 ++++++
.../models/migrationscripts/archived/build.go | 1 -
.../migrationscripts/archived/build_definition.go | 17 ++++++
plugins/bitbucket/api/blueprint.go | 4 +-
plugins/bitbucket/bitbucket.go | 2 +-
plugins/bitbucket/models/account.go | 2 +-
.../models/migrationscripts/archived/account.go | 2 +-
plugins/bitbucket/tasks/api_common.go | 4 +-
plugins/bitbucket/tasks/repo_collector.go | 4 +-
plugins/customize/api/api.go | 3 +-
plugins/customize/api/swagger.go | 2 +
.../customize/tasks/customized_fields_extractor.go | 2 +-
plugins/dbt/tasks/convertor.go | 5 +-
plugins/dora/api/data.go | 63 ----------------------
plugins/dora/api/init.go | 39 --------------
plugins/dora/dora.go | 2 +-
plugins/dora/impl/impl.go | 17 ------
plugins/dora/tasks/change_lead_time_convertor.go | 5 +-
plugins/gitee/tasks/commit_stats_collector.go | 4 +-
plugins/gitee/tasks/pr_review_collector.go | 1 -
plugins/gitee/tasks/repo_collector.go | 4 +-
plugins/gitee/tasks/shared.go | 4 +-
plugins/gitextractor/parser/clone.go | 3 +-
plugins/github/api/blueprint.go | 4 +-
plugins/github/api/connection.go | 2 +-
plugins/github/tasks/account_collector.go | 4 +-
plugins/github/tasks/account_org_collector.go | 4 +-
plugins/github/tasks/account_org_extractor.go | 3 ++
plugins/github/tasks/comment_collector.go | 3 ++
plugins/github/tasks/commit_stats_collector.go | 4 +-
plugins/github/tasks/repo_collector.go | 4 +-
plugins/github_graphql/plugin_main.go | 2 +-
plugins/github_graphql/tasks/account_collector.go | 0
.../tasks/account_rest_pre_extractor.go | 56 -------------------
plugins/github_graphql/tasks/issue_collector.go | 0
plugins/github_graphql/tasks/pr_collector.go | 0
plugins/github_graphql/tasks/repo_collector.go | 0
plugins/gitlab/api/blueprint.go | 4 +-
plugins/gitlab/api/proxy.go | 4 +-
.../20220906_fix_duration_to_float8.go | 3 ++
plugins/gitlab/tasks/shared.go | 4 +-
plugins/helper/api_async_client.go | 9 ++--
plugins/helper/api_client.go | 3 +-
plugins/helper/api_collector.go | 13 +++--
plugins/helper/api_collector_func.go | 6 +--
plugins/helper/graphql_async_client.go | 4 +-
plugins/helper/graphql_collector.go | 7 ++-
plugins/helper/iterator.go | 6 +++
plugins/helper/list.go | 3 ++
plugins/helper/queue.go | 9 +++-
plugins/icla/api/swagger.go | 2 +
plugins/jenkins/models/build_repo.go | 17 ++++++
plugins/jenkins/models/job_dag.go | 17 ++++++
plugins/jenkins/models/pipeline.go | 17 ++++++
plugins/jenkins/models/task.go | 17 ++++++
plugins/jenkins/tasks/build_stages_enricher.go | 3 ++
plugins/jira/api/proxy.go | 4 +-
.../migrationscripts/20220407_add_source_table.go | 17 ++++++
.../20220505_rename_source_table.go | 2 +
.../migrationscripts/20220716_add_init_tables.go | 1 +
.../models/migrationscripts/archived/source.go | 2 +
plugins/jira/tasks/board_collector.go | 4 +-
plugins/jira/tasks/epic_collector.go | 4 +-
plugins/jira/tasks/issue_collector.go | 4 +-
plugins/jira/tasks/issue_extractor.go | 5 +-
plugins/org/api/types.go | 26 ++++-----
plugins/org/tasks/user_account.go | 6 ---
plugins/refdiff/api/swagger.go | 3 +-
plugins/starrocks/starrocks.go | 5 +-
plugins/starrocks/task_data.go | 3 +-
plugins/starrocks/tasks.go | 6 ++-
plugins/starrocks/utils.go | 3 +-
plugins/tapd/tasks/shared.go | 4 +-
plugins/tapd/tasks/task_changelog_collector.go | 2 +-
runner/directrun.go | 2 +-
runner/run_task.go | 30 +++++------
services/blueprint_helper.go | 8 +--
services/init.go | 2 +
services/notification.go | 4 +-
services/pipeline_helper.go | 14 ++---
services/pluginapi.go | 1 +
95 files changed, 404 insertions(+), 325 deletions(-)
diff --git a/.golangci.yaml b/.golangci.yaml
index e5aabc80..807ae4e7 100644
--- a/.golangci.yaml
+++ b/.golangci.yaml
@@ -19,16 +19,16 @@
linters:
disable-all: true
enable:
- - deadcode
+ # - deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- - structcheck
+ # - structcheck
- typecheck
- unused
- - varcheck
+ # - varcheck
# - exhaustive
# - funlen
# - goconst
diff --git a/generator/cmd/create_migration.go b/generator/cmd/create_migration.go
index 7e101fd5..4ee48081 100644
--- a/generator/cmd/create_migration.go
+++ b/generator/cmd/create_migration.go
@@ -20,7 +20,6 @@ package cmd
import (
"fmt"
"github.com/apache/incubator-devlake/errors"
- "io/ioutil"
"os"
"path/filepath"
"regexp"
@@ -93,7 +92,7 @@ If framework passed, generator will create a new migration in models/migrationsc
values := map[string]string{}
values[`Date`] = time.Now().Format(`20060102`)
values[`Purpose`] = strcase.LowerCamelCase(purpose)
- existMigrations, err := ioutil.ReadDir(migrationPath)
+ existMigrations, err := os.ReadDir(migrationPath)
cobra.CheckErr(err)
values[`Count`] = fmt.Sprintf(`%06d`, len(existMigrations))
diff --git a/generator/cmd/create_plugin.go b/generator/cmd/create_plugin.go
index 1eaf8e06..17fe46e5 100644
--- a/generator/cmd/create_plugin.go
+++ b/generator/cmd/create_plugin.go
@@ -23,7 +23,6 @@ import (
"github.com/apache/incubator-devlake/generator/util"
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
- "io/ioutil"
"os"
"regexp"
"strings"
@@ -64,7 +63,7 @@ func pluginNameExistValidate(input string) error {
}
func pluginNames(withFramework bool) (pluginItems []string, err error) {
- files, err := ioutil.ReadDir(`plugins`)
+ files, err := os.ReadDir(`plugins`)
if err != nil {
return nil, err
}
diff --git a/generator/template/plugin/plugin_main.go-template b/generator/template/plugin/plugin_main.go-template
index 04db3d71..6ef3cd92 100644
--- a/generator/template/plugin/plugin_main.go-template
+++ b/generator/template/plugin/plugin_main.go-template
@@ -33,7 +33,7 @@ var _ core.PluginInit = (*{{ .PluginName }})(nil)
var _ core.PluginTask = (*{{ .PluginName }})(nil)
var _ core.PluginApi = (*{{ .PluginName }})(nil)
-// Export a variable named PluginEntry for Framework to search and load
+// PluginEntry exports a symbol for Framework to load
var PluginEntry {{ .PluginName }} //nolint
type {{ .PluginName }} struct{}
diff --git a/generator/util/template.go b/generator/util/template.go
index 908caf70..2f466198 100644
--- a/generator/util/template.go
+++ b/generator/util/template.go
@@ -21,7 +21,6 @@ import (
"fmt"
"github.com/spf13/cobra"
"github.com/stoewer/go-strcase"
- "io/ioutil"
"os"
"path/filepath"
"regexp"
@@ -40,7 +39,7 @@ func GenerateAllFormatVar(values map[string]string, baseVarName, baseValue strin
// ReadTemplate read a file to string
func ReadTemplate(templateFile string) string {
- f, err := ioutil.ReadFile(templateFile)
+ f, err := os.ReadFile(templateFile)
cobra.CheckErr(err)
return string(f)
}
@@ -52,7 +51,7 @@ func WriteTemplates(path string, templates map[string]string) {
for name, template := range templates {
err := os.MkdirAll(filepath.Dir(filepath.Join(path, name)), 0755)
cobra.CheckErr(err)
- err = ioutil.WriteFile(filepath.Join(path, name), []byte(template), 0600)
+ err = os.WriteFile(filepath.Join(path, name), []byte(template), 0600)
cobra.CheckErr(err)
println(filepath.Join(path, name), ` generated`)
}
@@ -60,11 +59,11 @@ func WriteTemplates(path string, templates map[string]string) {
// ReplaceVarInFile replacte var into file without reading
func ReplaceVarInFile(filename string, reg *regexp.Regexp, new string) {
- f, err := ioutil.ReadFile(filename)
+ f, err := os.ReadFile(filename)
cobra.CheckErr(err)
f = reg.ReplaceAll(f, []byte(new))
- err = ioutil.WriteFile(filename, f, 0777)
+ err = os.WriteFile(filename, f, 0777)
cobra.CheckErr(err)
println(filename, ` updated`)
}
diff --git a/models/domainlayer/devops/cicd_pipeline.go b/models/domainlayer/devops/cicd_pipeline.go
index 87d75b41..fb314c02 100644
--- a/models/domainlayer/devops/cicd_pipeline.go
+++ b/models/domainlayer/devops/cicd_pipeline.go
@@ -1,3 +1,20 @@
+/*
+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 devops
import (
diff --git a/models/domainlayer/devops/cicd_pipeline_repo.go b/models/domainlayer/devops/cicd_pipeline_repo.go
index ac891c80..ec237182 100644
--- a/models/domainlayer/devops/cicd_pipeline_repo.go
+++ b/models/domainlayer/devops/cicd_pipeline_repo.go
@@ -1,3 +1,20 @@
+/*
+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 devops
import "github.com/apache/incubator-devlake/models/domainlayer"
diff --git a/models/migrationscripts/20220711_add_subtasks_table.go b/models/migrationscripts/20220711_add_subtasks_table.go
index 3798289f..3e422e21 100644
--- a/models/migrationscripts/20220711_add_subtasks_table.go
+++ b/models/migrationscripts/20220711_add_subtasks_table.go
@@ -1,3 +1,20 @@
+/*
+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 (
diff --git a/models/migrationscripts/20220903_encrypt_blueprint.go b/models/migrationscripts/20220903_encrypt_blueprint.go
index 8babfb10..fd93105b 100644
--- a/models/migrationscripts/20220903_encrypt_blueprint.go
+++ b/models/migrationscripts/20220903_encrypt_blueprint.go
@@ -66,6 +66,7 @@ func (*encryptBLueprint) Up(ctx context.Context, db *gorm.DB) error {
if err != nil {
return err
}
+ //nolint:errcheck
defer db.Migrator().DropTable(&Blueprint0903Temp{})
var result *gorm.DB
@@ -102,6 +103,9 @@ func (*encryptBLueprint) Up(ctx context.Context, db *gorm.DB) error {
Settings: encryptedSettings,
}
err = db.Create(newBlueprint).Error
+ if err != nil {
+ return err
+ }
}
err = db.Migrator().DropTable(&BlueprintOldVersion{})
diff --git a/models/migrationscripts/20220904_encrypt_pipeline.go b/models/migrationscripts/20220904_encrypt_pipeline.go
index db4b6f1b..a503b2dd 100644
--- a/models/migrationscripts/20220904_encrypt_pipeline.go
+++ b/models/migrationscripts/20220904_encrypt_pipeline.go
@@ -73,6 +73,7 @@ func (*encryptPipeline) Up(ctx context.Context, db *gorm.DB) error {
if err != nil {
return err
}
+ //nolint:errcheck
defer db.Migrator().DropTable(&Pipeline0904Temp{})
var result *gorm.DB
@@ -107,6 +108,9 @@ func (*encryptPipeline) Up(ctx context.Context, db *gorm.DB) error {
Plan: encryptedPlan,
}
err = db.Create(newPipeline).Error
+ if err != nil {
+ return err
+ }
}
err = db.Migrator().DropTable(&PipelineOldVersion{})
diff --git a/plugins/ae/tasks/commits_collector.go b/plugins/ae/tasks/commits_collector.go
index 3df2ef29..2a3ad55e 100644
--- a/plugins/ae/tasks/commits_collector.go
+++ b/plugins/ae/tasks/commits_collector.go
@@ -20,7 +20,7 @@ package tasks
import (
"encoding/json"
"fmt"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
@@ -51,7 +51,7 @@ func CollectCommits(taskCtx core.SubTaskContext) error {
return query, nil
},
ResponseParser: func(res *http.Response) ([]json.RawMessage, error) {
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
diff --git a/plugins/ae/tasks/project_collector.go b/plugins/ae/tasks/project_collector.go
index 7a4c8fbe..033463d4 100644
--- a/plugins/ae/tasks/project_collector.go
+++ b/plugins/ae/tasks/project_collector.go
@@ -19,7 +19,7 @@ package tasks
import (
"encoding/json"
- "io/ioutil"
+ "io"
"net/http"
"github.com/apache/incubator-devlake/plugins/core"
@@ -42,7 +42,7 @@ func CollectProject(taskCtx core.SubTaskContext) error {
ApiClient: data.ApiClient,
UrlTemplate: "projects/{{ .Params.ProjectId }}",
ResponseParser: func(res *http.Response) ([]json.RawMessage, error) {
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
diff --git a/plugins/azure/impl/impl.go b/plugins/azure/impl/impl.go
index c832ad01..6e3eafe4 100644
--- a/plugins/azure/impl/impl.go
+++ b/plugins/azure/impl/impl.go
@@ -1,3 +1,20 @@
+/*
+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 (
@@ -22,7 +39,7 @@ var _ core.PluginTask = (*Azure)(nil)
var _ core.PluginApi = (*Azure)(nil)
var _ core.CloseablePluginTask = (*Azure)(nil)
-// Export a variable named PluginEntry for Framework to search and load
+// PluginEntry exports for Framework to search and load
var PluginEntry Azure //nolint
type Azure struct{}
diff --git a/plugins/azure/models/build.go b/plugins/azure/models/build.go
index 06109b15..e347fb90 100644
--- a/plugins/azure/models/build.go
+++ b/plugins/azure/models/build.go
@@ -1,3 +1,20 @@
+/*
+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 (
diff --git a/plugins/azure/models/build_definition.go b/plugins/azure/models/build_definition.go
index 3e5a51b0..81112c11 100644
--- a/plugins/azure/models/build_definition.go
+++ b/plugins/azure/models/build_definition.go
@@ -1,3 +1,20 @@
+/*
+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 (
diff --git a/plugins/azure/models/migrationscripts/archived/build.go b/plugins/azure/models/migrationscripts/archived/build.go
deleted file mode 100644
index c24c8254..00000000
--- a/plugins/azure/models/migrationscripts/archived/build.go
+++ /dev/null
@@ -1 +0,0 @@
-package archived
diff --git a/plugins/azure/models/migrationscripts/archived/build_definition.go b/plugins/azure/models/migrationscripts/archived/build_definition.go
index cf4c739f..193c8459 100644
--- a/plugins/azure/models/migrationscripts/archived/build_definition.go
+++ b/plugins/azure/models/migrationscripts/archived/build_definition.go
@@ -1,3 +1,20 @@
+/*
+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 (
diff --git a/plugins/bitbucket/api/blueprint.go b/plugins/bitbucket/api/blueprint.go
index 2039037f..0ee73606 100644
--- a/plugins/bitbucket/api/blueprint.go
+++ b/plugins/bitbucket/api/blueprint.go
@@ -22,7 +22,7 @@ import (
"encoding/json"
"fmt"
"github.com/apache/incubator-devlake/errors"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
"strings"
@@ -124,7 +124,7 @@ func MakePipelinePlan(subtaskMetas []core.SubTaskMeta, connectionId uint64, scop
res.StatusCode, res.Request.URL.String(),
))
}
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
diff --git a/plugins/bitbucket/bitbucket.go b/plugins/bitbucket/bitbucket.go
index f4a056a8..7273178c 100644
--- a/plugins/bitbucket/bitbucket.go
+++ b/plugins/bitbucket/bitbucket.go
@@ -23,7 +23,7 @@ import (
"github.com/spf13/cobra"
)
-// Export a variable named PluginEntry for Framework to search and load
+// PluginEntry exports for Framework to search and load
var PluginEntry impl.Bitbucket //nolint
// standalone mode for debugging
diff --git a/plugins/bitbucket/models/account.go b/plugins/bitbucket/models/account.go
index 83cbaef3..c0badf8c 100644
--- a/plugins/bitbucket/models/account.go
+++ b/plugins/bitbucket/models/account.go
@@ -6,7 +6,7 @@ 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
+ 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,
diff --git a/plugins/bitbucket/models/migrationscripts/archived/account.go b/plugins/bitbucket/models/migrationscripts/archived/account.go
index 5d4cfa40..41bb5425 100644
--- a/plugins/bitbucket/models/migrationscripts/archived/account.go
+++ b/plugins/bitbucket/models/migrationscripts/archived/account.go
@@ -6,7 +6,7 @@ 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
+ 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,
diff --git a/plugins/bitbucket/tasks/api_common.go b/plugins/bitbucket/tasks/api_common.go
index 689426a4..91dc7839 100644
--- a/plugins/bitbucket/tasks/api_common.go
+++ b/plugins/bitbucket/tasks/api_common.go
@@ -24,7 +24,7 @@ import (
"github.com/apache/incubator-devlake/plugins/core"
"github.com/apache/incubator-devlake/plugins/core/dal"
"github.com/apache/incubator-devlake/plugins/helper"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
"reflect"
@@ -84,7 +84,7 @@ func GetRawMessageFromResponse(res *http.Response) ([]json.RawMessage, error) {
return nil, errors.Default.New("res is nil")
}
defer res.Body.Close()
- resBody, err := ioutil.ReadAll(res.Body)
+ resBody, err := io.ReadAll(res.Body)
if err != nil {
return nil, errors.Default.Wrap(err, fmt.Sprintf("error reading response from %s", res.Request.URL.String()))
}
diff --git a/plugins/bitbucket/tasks/repo_collector.go b/plugins/bitbucket/tasks/repo_collector.go
index d74955aa..dc4dc120 100644
--- a/plugins/bitbucket/tasks/repo_collector.go
+++ b/plugins/bitbucket/tasks/repo_collector.go
@@ -20,7 +20,7 @@ package tasks
import (
"encoding/json"
"github.com/apache/incubator-devlake/plugins/helper"
- "io/ioutil"
+ "io"
"net/http"
"github.com/apache/incubator-devlake/plugins/core"
@@ -46,7 +46,7 @@ func CollectApiRepositories(taskCtx core.SubTaskContext) error {
UrlTemplate: "repositories/{{ .Params.Owner }}/{{ .Params.Repo }}",
Query: GetQuery,
ResponseParser: func(res *http.Response) ([]json.RawMessage, error) {
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return nil, err
diff --git a/plugins/customize/api/api.go b/plugins/customize/api/api.go
index 08312c43..9b712477 100644
--- a/plugins/customize/api/api.go
+++ b/plugins/customize/api/api.go
@@ -34,7 +34,7 @@ type field struct {
}
func getFields(d dal.Dal, tbl string) ([]field, error) {
- columns, err := d.GetColumns(&models.Table{tbl}, func(columnMeta dal.ColumnMeta) bool {
+ columns, err := d.GetColumns(&models.Table{Name: tbl}, func(columnMeta dal.ColumnMeta) bool {
return strings.HasPrefix(columnMeta.Name(), "x_")
})
if err != nil {
@@ -95,6 +95,7 @@ func deleteField(d dal.Dal, table, field string) error {
return nil
}
+//nolint:unused
type input struct {
Name string `json:"name" example:"x_new_column"`
}
diff --git a/plugins/customize/api/swagger.go b/plugins/customize/api/swagger.go
index 7d8d3be1..fd85132a 100644
--- a/plugins/customize/api/swagger.go
+++ b/plugins/customize/api/swagger.go
@@ -27,6 +27,7 @@ import "github.com/apache/incubator-devlake/plugins/customize/tasks"
// @Router /blueprints/customize/blueprint-setting [post]
func _() {}
+//nolint:unused
type blueprintSetting []struct {
Version string `json:"version" example:"1.0.0"`
Connections []struct {
@@ -45,6 +46,7 @@ type blueprintSetting []struct {
// @Router /pipelines/customize/pipeline-plan [post]
func _() {}
+//nolint:unused
type pipelinePlan [][]struct {
Plugin string `json:"plugin"`
Subtasks []string `json:"subtasks"`
diff --git a/plugins/customize/tasks/customized_fields_extractor.go b/plugins/customize/tasks/customized_fields_extractor.go
index 6bf1f9ce..76181932 100644
--- a/plugins/customize/tasks/customized_fields_extractor.go
+++ b/plugins/customize/tasks/customized_fields_extractor.go
@@ -55,7 +55,7 @@ func ExtractCustomizedFields(taskCtx core.SubTaskContext) error {
}
func extractCustomizedFields(ctx context.Context, d dal.Dal, table, rawTable, rawDataParams string, extractor map[string]string) error {
- pkFields, err := dal.GetPrimarykeyColumns(d, &models.Table{table})
+ pkFields, err := dal.GetPrimarykeyColumns(d, &models.Table{Name: table})
if err != nil {
return err
}
diff --git a/plugins/dbt/tasks/convertor.go b/plugins/dbt/tasks/convertor.go
index b86a8784..99fae231 100644
--- a/plugins/dbt/tasks/convertor.go
+++ b/plugins/dbt/tasks/convertor.go
@@ -141,7 +141,10 @@ func DbtConverter(taskCtx core.SubTaskContext) error {
return err
}
- cmd.Wait()
+ err = cmd.Wait()
+ if err != nil {
+ return err
+ }
if !cmd.ProcessState.Success() {
log.Error(nil, "dbt run task error, please check!!!")
}
diff --git a/plugins/dora/api/data.go b/plugins/dora/api/data.go
deleted file mode 100644
index 18f72496..00000000
--- a/plugins/dora/api/data.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 (
- "github.com/apache/incubator-devlake/plugins/core"
- "net/http"
-)
-
-const RAW_DEPLOYMENTS_TABLE = `dora_deplyments`
-
-//TODO Please modify the folowing code to adapt to your plugin
-/*
-POST /plugins/dora/deployments
-{
- TODO
-}
-*/
-func PostDeployments(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
- // TODO
- return &core.ApiResourceOutput{Body: nil, Status: http.StatusOK}, nil
-}
-
-const RAW_ISSUES_TABLE = `dora_issues`
-
-//TODO Please modify the folowing code to adapt to your plugin
-/*
-POST /plugins/dora/issues
-{
- TODO
-}
-*/
-func PostIssues(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
- // TODO
- return &core.ApiResourceOutput{Body: nil, Status: http.StatusOK}, nil
-}
-
-//TODO Please modify the folowing code to adapt to your plugin
-/*
-POST /plugins/dora/issues/:id/close
-{
- TODO
-}
-*/
-func CloseIssues(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
- // TODO
- return &core.ApiResourceOutput{Body: nil, Status: http.StatusOK}, nil
-}
diff --git a/plugins/dora/api/init.go b/plugins/dora/api/init.go
deleted file mode 100644
index 6774e148..00000000
--- a/plugins/dora/api/init.go
+++ /dev/null
@@ -1,39 +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/plugins/core"
- "github.com/apache/incubator-devlake/plugins/helper"
- "github.com/go-playground/validator/v10"
- "github.com/spf13/viper"
- "gorm.io/gorm"
-)
-
-var vld *validator.Validate
-var connectionHelper *helper.ConnectionApiHelper
-var basicRes core.BasicRes
-
-func Init(config *viper.Viper, logger core.Logger, database *gorm.DB) {
- basicRes = helper.NewDefaultBasicRes(config, logger, database)
- vld = validator.New()
- connectionHelper = helper.NewConnectionHelper(
- basicRes,
- vld,
- )
-}
diff --git a/plugins/dora/dora.go b/plugins/dora/dora.go
index 9af130a8..fb1f8b0c 100644
--- a/plugins/dora/dora.go
+++ b/plugins/dora/dora.go
@@ -23,7 +23,7 @@ import (
"github.com/spf13/cobra"
)
-// Export a variable named PluginEntry for Framework to search and load
+// PluginEntry exports for Framework to search and load
var PluginEntry impl.Dora //nolint
// standalone mode for debugging
diff --git a/plugins/dora/impl/impl.go b/plugins/dora/impl/impl.go
index 5cb38042..222ec05f 100644
--- a/plugins/dora/impl/impl.go
+++ b/plugins/dora/impl/impl.go
@@ -22,7 +22,6 @@ import (
"github.com/apache/incubator-devlake/errors"
"github.com/apache/incubator-devlake/migration"
"github.com/apache/incubator-devlake/plugins/core"
- "github.com/apache/incubator-devlake/plugins/dora/api"
"github.com/apache/incubator-devlake/plugins/dora/models/migrationscripts"
"github.com/apache/incubator-devlake/plugins/dora/tasks"
"github.com/spf13/viper"
@@ -33,7 +32,6 @@ import (
var _ core.PluginMeta = (*Dora)(nil)
var _ core.PluginInit = (*Dora)(nil)
var _ core.PluginTask = (*Dora)(nil)
-var _ core.PluginApi = (*Dora)(nil)
var _ core.CloseablePluginTask = (*Dora)(nil)
type Dora struct{}
@@ -54,7 +52,6 @@ func (plugin Dora) SvgIcon() string {
}
func (plugin Dora) Init(config *viper.Viper, logger core.Logger, db *gorm.DB) error {
- api.Init(config, logger, db)
return nil
}
@@ -85,20 +82,6 @@ func (plugin Dora) MigrationScripts() []migration.Script {
return migrationscripts.All()
}
-func (plugin Dora) ApiResources() map[string]map[string]core.ApiResourceHandler {
- return map[string]map[string]core.ApiResourceHandler{
- "deployments": {
- "POST": api.PostDeployments,
- },
- "issues": {
- "POST": api.PostIssues,
- },
- "issues/:id/close": {
- "POST": api.CloseIssues,
- },
- }
-}
-
func (plugin Dora) Close(taskCtx core.TaskContext) error {
data, ok := taskCtx.GetData().(*tasks.DoraTaskData)
if !ok {
diff --git a/plugins/dora/tasks/change_lead_time_convertor.go b/plugins/dora/tasks/change_lead_time_convertor.go
index 4f7f3cdc..21b158c1 100644
--- a/plugins/dora/tasks/change_lead_time_convertor.go
+++ b/plugins/dora/tasks/change_lead_time_convertor.go
@@ -19,7 +19,6 @@ package tasks
import (
"github.com/apache/incubator-devlake/plugins/core"
- "github.com/apache/incubator-devlake/plugins/dora/api"
"github.com/apache/incubator-devlake/plugins/helper"
)
@@ -31,6 +30,8 @@ var ConvertChangeLeadTimeMeta = core.SubTaskMeta{
DomainTypes: []string{core.DOMAIN_TYPE_CICD},
}
+const RAW_ISSUES_TABLE = `dora_issues`
+
func ConvertChangeLeadTime(taskCtx core.SubTaskContext) error {
//db := taskCtx.GetDal()
//data := taskCtx.GetData().(*DoraTaskData)
@@ -41,7 +42,7 @@ func ConvertChangeLeadTime(taskCtx core.SubTaskContext) error {
Params: DoraApiParams{
// TODO
},
- Table: api.RAW_ISSUES_TABLE,
+ Table: RAW_ISSUES_TABLE,
},
//InputRowType: reflect.TypeOf(githubModels.GithubJob{}),
//Input: cursor,
diff --git a/plugins/gitee/tasks/commit_stats_collector.go b/plugins/gitee/tasks/commit_stats_collector.go
index c6bcca9c..714917b7 100644
--- a/plugins/gitee/tasks/commit_stats_collector.go
+++ b/plugins/gitee/tasks/commit_stats_collector.go
@@ -21,7 +21,7 @@ import (
"encoding/json"
"fmt"
"github.com/apache/incubator-devlake/errors"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
"reflect"
@@ -105,7 +105,7 @@ func CollectApiCommitStats(taskCtx core.SubTaskContext) error {
},
ResponseParser: func(res *http.Response) ([]json.RawMessage, error) {
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return nil, err
diff --git a/plugins/gitee/tasks/pr_review_collector.go b/plugins/gitee/tasks/pr_review_collector.go
index 6cdba210..ceec15e5 100644
--- a/plugins/gitee/tasks/pr_review_collector.go
+++ b/plugins/gitee/tasks/pr_review_collector.go
@@ -32,7 +32,6 @@ import (
"github.com/apache/incubator-devlake/plugins/gitee/models"
)
-//gitee
const RAW_PULL_REQUEST_REVIEW_TABLE = "gitee_api_pull_request_reviews"
var CollectApiPullRequestReviewsMeta = core.SubTaskMeta{
diff --git a/plugins/gitee/tasks/repo_collector.go b/plugins/gitee/tasks/repo_collector.go
index dab28610..85754f10 100644
--- a/plugins/gitee/tasks/repo_collector.go
+++ b/plugins/gitee/tasks/repo_collector.go
@@ -20,7 +20,7 @@ package tasks
import (
"encoding/json"
"fmt"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
@@ -55,7 +55,7 @@ func CollectApiRepositories(taskCtx core.SubTaskContext) error {
return query, nil
},
ResponseParser: func(res *http.Response) ([]json.RawMessage, error) {
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return nil, err
diff --git a/plugins/gitee/tasks/shared.go b/plugins/gitee/tasks/shared.go
index 59f83485..37971229 100644
--- a/plugins/gitee/tasks/shared.go
+++ b/plugins/gitee/tasks/shared.go
@@ -21,7 +21,7 @@ import (
"encoding/json"
"fmt"
"github.com/apache/incubator-devlake/errors"
- "io/ioutil"
+ "io"
"net/http"
"regexp"
"strconv"
@@ -76,7 +76,7 @@ func GetRawMessageFromResponse(res *http.Response) ([]json.RawMessage, error) {
return nil, errors.Default.New("res is nil")
}
defer res.Body.Close()
- resBody, err := ioutil.ReadAll(res.Body)
+ resBody, err := io.ReadAll(res.Body)
if err != nil {
return nil, errors.Default.Wrap(err, fmt.Sprintf("error reading response from %s", res.Request.URL.String()))
}
diff --git a/plugins/gitextractor/parser/clone.go b/plugins/gitextractor/parser/clone.go
index d5b943f2..d19890fd 100644
--- a/plugins/gitextractor/parser/clone.go
+++ b/plugins/gitextractor/parser/clone.go
@@ -20,7 +20,6 @@ package parser
import (
"encoding/base64"
"fmt"
- "io/ioutil"
"net"
"os"
@@ -86,7 +85,7 @@ func (l *GitRepoCreator) CloneOverSSH(repoId, url, privateKey, passphrase string
}
func withTempDirectory(f func(tempDir string) (*GitRepo, error)) (*GitRepo, error) {
- dir, err := ioutil.TempDir("", "gitextractor")
+ dir, err := os.MkdirTemp("", "gitextractor")
if err != nil {
return nil, err
}
diff --git a/plugins/github/api/blueprint.go b/plugins/github/api/blueprint.go
index a3eef25f..90016c7e 100644
--- a/plugins/github/api/blueprint.go
+++ b/plugins/github/api/blueprint.go
@@ -22,7 +22,7 @@ import (
"encoding/json"
"fmt"
"github.com/apache/incubator-devlake/errors"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
"strings"
@@ -122,7 +122,7 @@ func MakePipelinePlan(subtaskMetas []core.SubTaskMeta, connectionId uint64, scop
return nil, errors.HttpStatus(res.StatusCode).New(fmt.Sprintf(
"unexpected status code when requesting repo detail from %s", res.Request.URL.String()))
}
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
diff --git a/plugins/github/api/connection.go b/plugins/github/api/connection.go
index 41b1c4cf..dfb32c32 100644
--- a/plugins/github/api/connection.go
+++ b/plugins/github/api/connection.go
@@ -174,7 +174,7 @@ func DeleteConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, er
return nil, err
}
err = connectionHelper.Delete(connection)
- return &core.ApiResourceOutput{Body: connection}, nil
+ return &core.ApiResourceOutput{Body: connection}, err
}
// @Summary get all github connections
diff --git a/plugins/github/tasks/account_collector.go b/plugins/github/tasks/account_collector.go
index 829a4917..bb2bd038 100644
--- a/plugins/github/tasks/account_collector.go
+++ b/plugins/github/tasks/account_collector.go
@@ -19,7 +19,7 @@ package tasks
import (
"encoding/json"
- "io/ioutil"
+ "io"
"net/http"
"reflect"
@@ -67,7 +67,7 @@ func CollectAccounts(taskCtx core.SubTaskContext) error {
Input: iterator,
UrlTemplate: "/users/{{ .Input.Login }}",
ResponseParser: func(res *http.Response) ([]json.RawMessage, error) {
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
diff --git a/plugins/github/tasks/account_org_collector.go b/plugins/github/tasks/account_org_collector.go
index d7296d81..fe9cf353 100644
--- a/plugins/github/tasks/account_org_collector.go
+++ b/plugins/github/tasks/account_org_collector.go
@@ -19,7 +19,7 @@ package tasks
import (
"encoding/json"
- "io/ioutil"
+ "io"
"net/http"
"reflect"
@@ -74,7 +74,7 @@ func CollectAccountOrg(taskCtx core.SubTaskContext) error {
Input: iterator,
UrlTemplate: "/users/{{ .Input.Login }}/orgs",
ResponseParser: func(res *http.Response) ([]json.RawMessage, error) {
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
diff --git a/plugins/github/tasks/account_org_extractor.go b/plugins/github/tasks/account_org_extractor.go
index dc43c373..dc1ff507 100644
--- a/plugins/github/tasks/account_org_extractor.go
+++ b/plugins/github/tasks/account_org_extractor.go
@@ -55,6 +55,9 @@ func ExtractAccountOrg(taskCtx core.SubTaskContext) error {
Extract: func(row *helper.RawData) ([]interface{}, error) {
apiAccountOrgs := &[]GithubAccountOrgsResponse{}
err := json.Unmarshal(row.Data, apiAccountOrgs)
+ if err != nil {
+ return nil, err
+ }
simpleAccount := &SimpleAccountWithId{}
err = json.Unmarshal(row.Input, simpleAccount)
if err != nil {
diff --git a/plugins/github/tasks/comment_collector.go b/plugins/github/tasks/comment_collector.go
index b9cf7f50..7ce32ad9 100644
--- a/plugins/github/tasks/comment_collector.go
+++ b/plugins/github/tasks/comment_collector.go
@@ -44,6 +44,9 @@ func CollectApiComments(taskCtx core.SubTaskContext) error {
var err error
if since == nil {
since, incremental, err = calculateSince(data, db)
+ if err != nil {
+ return err
+ }
}
collector, err := helper.NewApiCollector(helper.ApiCollectorArgs{
diff --git a/plugins/github/tasks/commit_stats_collector.go b/plugins/github/tasks/commit_stats_collector.go
index b9541762..4c30441c 100644
--- a/plugins/github/tasks/commit_stats_collector.go
+++ b/plugins/github/tasks/commit_stats_collector.go
@@ -22,7 +22,7 @@ import (
"fmt"
"github.com/apache/incubator-devlake/errors"
"gorm.io/gorm"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
"reflect"
@@ -117,7 +117,7 @@ func CollectApiCommitStats(taskCtx core.SubTaskContext) error {
},
ResponseParser: func(res *http.Response) ([]json.RawMessage, error) {
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return nil, err
diff --git a/plugins/github/tasks/repo_collector.go b/plugins/github/tasks/repo_collector.go
index 9f70cff6..4aeb1cd5 100644
--- a/plugins/github/tasks/repo_collector.go
+++ b/plugins/github/tasks/repo_collector.go
@@ -20,7 +20,7 @@ package tasks
import (
"encoding/json"
"fmt"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
@@ -65,7 +65,7 @@ func CollectApiRepositories(taskCtx core.SubTaskContext) error {
return query, nil
},
ResponseParser: func(res *http.Response) ([]json.RawMessage, error) {
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return nil, err
diff --git a/plugins/github_graphql/plugin_main.go b/plugins/github_graphql/plugin_main.go
old mode 100755
new mode 100644
index fc582d03..2e4e7050
--- a/plugins/github_graphql/plugin_main.go
+++ b/plugins/github_graphql/plugin_main.go
@@ -43,7 +43,7 @@ var _ core.PluginInit = (*GithubGraphql)(nil)
var _ core.PluginTask = (*GithubGraphql)(nil)
var _ core.PluginApi = (*GithubGraphql)(nil)
-// Export a variable named PluginEntry for Framework to search and load
+// PluginEntry exports a symbol for Framework to load
var PluginEntry GithubGraphql //nolint
type GithubGraphql struct{}
diff --git a/plugins/github_graphql/tasks/account_collector.go b/plugins/github_graphql/tasks/account_collector.go
old mode 100755
new mode 100644
diff --git a/plugins/github_graphql/tasks/account_rest_pre_extractor.go b/plugins/github_graphql/tasks/account_rest_pre_extractor.go
deleted file mode 100644
index 54a9c772..00000000
--- a/plugins/github_graphql/tasks/account_rest_pre_extractor.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/plugins/github/models"
-)
-
-type GithubAccountResponse struct {
- Login string `json:"login"`
- Id int `json:"id"`
- NodeId string `json:"node_id"`
- AvatarUrl string `json:"avatar_url"`
- GravatarId string `json:"gravatar_id"`
- Url string `json:"url"`
- HtmlUrl string `json:"html_url"`
- FollowersUrl string `json:"followers_url"`
- FollowingUrl string `json:"following_url"`
- GistsUrl string `json:"gists_url"`
- StarredUrl string `json:"starred_url"`
- SubscriptionsUrl string `json:"subscriptions_url"`
- OrganizationsUrl string `json:"organizations_url"`
- ReposUrl string `json:"repos_url"`
- EventsUrl string `json:"events_url"`
- ReceivedEventsUrl string `json:"received_events_url"`
- Type string `json:"type"`
- SiteAdmin bool `json:"site_admin"`
-}
-
-func convertRestPreAccount(res *GithubAccountResponse, repoId int, connId uint64) ([]interface{}, error) {
- if res.Type != `User` {
- return nil, nil
- }
- githubAccount := &models.GithubRepoAccount{
- ConnectionId: connId,
- RepoGithubId: repoId,
- Login: res.Login,
- AccountId: res.Id,
- }
- return []interface{}{githubAccount}, nil
-}
diff --git a/plugins/github_graphql/tasks/issue_collector.go b/plugins/github_graphql/tasks/issue_collector.go
old mode 100755
new mode 100644
diff --git a/plugins/github_graphql/tasks/pr_collector.go b/plugins/github_graphql/tasks/pr_collector.go
old mode 100755
new mode 100644
diff --git a/plugins/github_graphql/tasks/repo_collector.go b/plugins/github_graphql/tasks/repo_collector.go
old mode 100755
new mode 100644
diff --git a/plugins/gitlab/api/blueprint.go b/plugins/gitlab/api/blueprint.go
index 0bd266a5..e0019610 100644
--- a/plugins/gitlab/api/blueprint.go
+++ b/plugins/gitlab/api/blueprint.go
@@ -22,7 +22,7 @@ import (
"encoding/json"
"fmt"
"github.com/apache/incubator-devlake/errors"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
"strings"
@@ -121,7 +121,7 @@ func MakePipelinePlan(subtaskMetas []core.SubTaskMeta, connectionId uint64, scop
if res.StatusCode != http.StatusOK {
return nil, errors.HttpStatus(res.StatusCode).New(fmt.Sprintf("unexpected status code when requesting repo detail from %s", res.Request.URL.String()))
}
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
diff --git a/plugins/gitlab/api/proxy.go b/plugins/gitlab/api/proxy.go
index 6271fd9e..ae56772f 100644
--- a/plugins/gitlab/api/proxy.go
+++ b/plugins/gitlab/api/proxy.go
@@ -21,7 +21,7 @@ import (
"context"
"encoding/json"
"fmt"
- "io/ioutil"
+ "io"
"time"
"github.com/apache/incubator-devlake/plugins/core"
@@ -59,7 +59,7 @@ func Proxy(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
}
defer resp.Body.Close()
- body, err := ioutil.ReadAll(resp.Body)
+ body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
diff --git a/plugins/gitlab/models/migrationscripts/20220906_fix_duration_to_float8.go b/plugins/gitlab/models/migrationscripts/20220906_fix_duration_to_float8.go
index dab8c632..903b0073 100644
--- a/plugins/gitlab/models/migrationscripts/20220906_fix_duration_to_float8.go
+++ b/plugins/gitlab/models/migrationscripts/20220906_fix_duration_to_float8.go
@@ -43,6 +43,9 @@ func (*fixDurationToFloat8) Up(ctx context.Context, db *gorm.DB) error {
}
cursor, err := db.Model(&GitlabJob20220906{}).Select([]string{"connection_id", "gitlab_id", "duration"}).Rows()
+ if err != nil {
+ return err
+ }
for cursor.Next() {
job := GitlabJob20220906{}
err = db.ScanRows(cursor, &job)
diff --git a/plugins/gitlab/tasks/shared.go b/plugins/gitlab/tasks/shared.go
index 9258889c..921a1701 100644
--- a/plugins/gitlab/tasks/shared.go
+++ b/plugins/gitlab/tasks/shared.go
@@ -22,7 +22,7 @@ import (
"fmt"
"github.com/apache/incubator-devlake/errors"
"github.com/apache/incubator-devlake/plugins/core/dal"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
"reflect"
@@ -61,7 +61,7 @@ func GetRawMessageFromResponse(res *http.Response) ([]json.RawMessage, error) {
return nil, errors.Default.New("res is nil")
}
defer res.Body.Close()
- resBody, err := ioutil.ReadAll(res.Body)
+ resBody, err := io.ReadAll(res.Body)
if err != nil {
return nil, errors.Default.Wrap(err, fmt.Sprintf("error reading response from %s", res.Request.URL.String()))
}
diff --git a/plugins/helper/api_async_client.go b/plugins/helper/api_async_client.go
index bdcb527d..a8d8e85a 100644
--- a/plugins/helper/api_async_client.go
+++ b/plugins/helper/api_async_client.go
@@ -23,7 +23,6 @@ import (
"fmt"
"github.com/apache/incubator-devlake/errors"
"io"
- "io/ioutil"
"net/http"
"net/url"
"time"
@@ -46,7 +45,7 @@ type ApiAsyncClient struct {
numOfWorkers int
}
-const DEFAULT_TIMEOUT = 10 * time.Second
+const defaultTimeout = 10 * time.Second
// CreateAsyncApiClient creates a new ApiAsyncClient
func CreateAsyncApiClient(
@@ -70,7 +69,7 @@ func CreateAsyncApiClient(
apiClient.SetTimeout(timeout)
} else if apiClient.GetTimeout() == 0 {
// Use DEFAULT_TIMEOUT when API_TIMEOUT is empty and ApiClient has no timeout set
- apiClient.SetTimeout(DEFAULT_TIMEOUT)
+ apiClient.SetTimeout(defaultTimeout)
}
apiClient.SetLogger(taskCtx.GetLogger())
@@ -163,14 +162,14 @@ func (apiClient *ApiAsyncClient) DoAsync(
// make sure response.Body stream will be closed to avoid running out of file handle
defer func(body io.ReadCloser) { body.Close() }(res.Body)
// replace NetworkStream with MemoryBuffer
- body, err = ioutil.ReadAll(res.Body)
+ body, err = io.ReadAll(res.Body)
if err == nil {
res.Body = io.NopCloser(bytes.NewBuffer(body))
}
}
if err == ErrIgnoreAndContinue {
// make sure defer func got be executed
- err = nil
+ err = nil //nolint:all
return nil
}
diff --git a/plugins/helper/api_client.go b/plugins/helper/api_client.go
index b908b731..68a6eaa3 100644
--- a/plugins/helper/api_client.go
+++ b/plugins/helper/api_client.go
@@ -25,7 +25,6 @@ import (
"fmt"
"github.com/apache/incubator-devlake/errors"
"io"
- "io/ioutil"
"net/http"
"net/url"
"regexp"
@@ -299,7 +298,7 @@ func (apiClient *ApiClient) Post(
// UnmarshalResponse FIXME ...
func UnmarshalResponse(res *http.Response, v interface{}) error {
defer res.Body.Close()
- resBody, err := ioutil.ReadAll(res.Body)
+ resBody, err := io.ReadAll(res.Body)
if err != nil {
return errors.Default.Wrap(err, fmt.Sprintf("error reading response from %s", res.Request.URL.String()), errors.AsUserMessage())
}
diff --git a/plugins/helper/api_collector.go b/plugins/helper/api_collector.go
index e4b7513f..85a5ab25 100644
--- a/plugins/helper/api_collector.go
+++ b/plugins/helper/api_collector.go
@@ -21,7 +21,7 @@ import (
"bytes"
"encoding/json"
"github.com/apache/incubator-devlake/errors"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
"text/template"
@@ -157,7 +157,10 @@ func (collector *ApiCollector) Execute() error {
}
for {
if !iterator.HasNext() || apiClient.HasError() {
- collector.args.ApiClient.WaitAsync()
+ err = collector.args.ApiClient.WaitAsync()
+ if err != nil {
+ return err
+ }
if !iterator.HasNext() || apiClient.HasError() {
break
}
@@ -345,12 +348,12 @@ func (collector *ApiCollector) fetchAsync(reqData *RequestData, handler func(int
defer logger.Debug("fetchAsync >>> done for %s %v", apiUrl, apiQuery)
logger := collector.args.Ctx.GetLogger()
// read body to buffer
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
if err != nil {
return err
}
res.Body.Close()
- res.Body = ioutil.NopCloser(bytes.NewBuffer(body))
+ res.Body = io.NopCloser(bytes.NewBuffer(body))
// convert body to array of RawJSON
items, err := collector.args.ResponseParser(res)
if err != nil {
@@ -381,7 +384,7 @@ func (collector *ApiCollector) fetchAsync(reqData *RequestData, handler func(int
// increase progress only when it was not nested
collector.args.Ctx.IncProgress(1)
if handler != nil {
- res.Body = ioutil.NopCloser(bytes.NewBuffer(body))
+ res.Body = io.NopCloser(bytes.NewBuffer(body))
return handler(count, body, res)
}
return nil
diff --git a/plugins/helper/api_collector_func.go b/plugins/helper/api_collector_func.go
index 34a8343e..5de17138 100644
--- a/plugins/helper/api_collector_func.go
+++ b/plugins/helper/api_collector_func.go
@@ -21,13 +21,13 @@ import (
"encoding/json"
"fmt"
"github.com/apache/incubator-devlake/errors"
- "io/ioutil"
+ "io"
"net/http"
)
// GetRawMessageDirectFromResponse FIXME ...
func GetRawMessageDirectFromResponse(res *http.Response) ([]json.RawMessage, error) {
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return nil, err
@@ -43,7 +43,7 @@ func GetRawMessageArrayFromResponse(res *http.Response) ([]json.RawMessage, erro
return nil, errors.Default.New("res is nil")
}
defer res.Body.Close()
- resBody, err := ioutil.ReadAll(res.Body)
+ resBody, err := io.ReadAll(res.Body)
if err != nil {
return nil, errors.Default.Wrap(err, fmt.Sprintf("error reading response body of %s", res.Request.URL.String()))
}
diff --git a/plugins/helper/graphql_async_client.go b/plugins/helper/graphql_async_client.go
index b51b8a2f..79d14a02 100644
--- a/plugins/helper/graphql_async_client.go
+++ b/plugins/helper/graphql_async_client.go
@@ -78,7 +78,7 @@ func (apiClient *GraphqlAsyncClient) updateRateRemaining(rateRemaining int, rese
go func() {
nextDuring := 3 * time.Minute
if resetAt != nil && resetAt.After(time.Now()) {
- nextDuring = resetAt.Sub(time.Now())
+ nextDuring = time.Until(*resetAt)
}
<-time.After(nextDuring)
newRateRemaining, newResetAt, err := apiClient.getRateRemaining(apiClient.ctx, apiClient.client, apiClient.logger)
@@ -143,7 +143,7 @@ func (apiClient *GraphqlAsyncClient) NextTick(task func() error) {
}()
}
-// WaitAsync blocks until all async requests were done
+// Wait blocks until all async requests were done
func (apiClient *GraphqlAsyncClient) Wait() error {
apiClient.waitGroup.Wait()
if len(apiClient.workerErrors) > 0 {
diff --git a/plugins/helper/graphql_collector.go b/plugins/helper/graphql_collector.go
index 990aad7a..789182a3 100644
--- a/plugins/helper/graphql_collector.go
+++ b/plugins/helper/graphql_collector.go
@@ -42,13 +42,16 @@ type GraphqlRequestData struct {
InputJSON []byte
}
+// GraphqlQueryPageInfo contains the pagination data
type GraphqlQueryPageInfo struct {
EndCursor string `json:"endCursor"`
HasNextPage bool `json:"hasNextPage"`
}
+// GraphqlAsyncResponseHandler callback function to handle the Response asynchronously
type GraphqlAsyncResponseHandler func(res *http.Response) error
+// GraphqlCollectorArgs arguments needed by GraphqlCollector
type GraphqlCollectorArgs struct {
RawDataSubTaskArgs
// BuildQuery would be sent out as part of the request URL
@@ -70,6 +73,7 @@ type GraphqlCollectorArgs struct {
ResponseParser func(query interface{}, variables map[string]interface{}) ([]interface{}, error)
}
+// GraphqlCollector help you collect data from Graphql services
type GraphqlCollector struct {
*RawDataSubTask
args *GraphqlCollectorArgs
@@ -116,7 +120,7 @@ func NewGraphqlCollector(args GraphqlCollectorArgs) (*GraphqlCollector, error) {
return apicllector, nil
}
-// Start collection
+// Execute api collection
func (collector *GraphqlCollector) Execute() error {
logger := collector.args.Ctx.GetLogger()
logger.Info("start graphql collection")
@@ -170,7 +174,6 @@ func (collector *GraphqlCollector) Execute() error {
if err != nil {
err = errors.Default.Wrap(err, "ended API collector execution with error", errors.UserMessage("Internal GraphQL Collector execution error"))
logger.Error(err, "")
-
} else {
logger.Info("ended api collection without error")
}
diff --git a/plugins/helper/iterator.go b/plugins/helper/iterator.go
index 873b9adf..01ef57ca 100644
--- a/plugins/helper/iterator.go
+++ b/plugins/helper/iterator.go
@@ -144,27 +144,33 @@ func NewDateIterator(days int) (*DateIterator, error) {
}, nil
}
+// QueueIterator implements Iterator based on Queue
type QueueIterator struct {
queue *Queue
}
+// HasNext increments the row curser. If we're at the end, it'll return false.
func (q *QueueIterator) HasNext() bool {
return q.queue.GetCount() > 0
}
+// Fetch current item
func (q *QueueIterator) Fetch() (interface{}, error) {
return q.queue.PullWithOutLock(), nil
}
+// Push a data into queue
func (q *QueueIterator) Push(data QueueNode) {
q.queue.PushWithoutLock(data)
}
+// Close releases resources
func (q *QueueIterator) Close() error {
q.queue.CleanWithOutLock()
return nil
}
+// NewQueueIterator creates a new QueueIterator
func NewQueueIterator() *QueueIterator {
return &QueueIterator{
queue: NewQueue(),
diff --git a/plugins/helper/list.go b/plugins/helper/list.go
index c0f507e5..e38e74d6 100644
--- a/plugins/helper/list.go
+++ b/plugins/helper/list.go
@@ -22,11 +22,13 @@ type ListBaseNode struct {
next QueueNode
}
+// Data returns data of the node
func (l *ListBaseNode) Data() interface{} {
// default implementation
return nil
}
+// Next return the next node
func (l *ListBaseNode) Next() interface{} {
if l.next == nil {
return nil
@@ -34,6 +36,7 @@ func (l *ListBaseNode) Next() interface{} {
return l.next
}
+// SetNext updates the next pointer of the node
func (l *ListBaseNode) SetNext(next interface{}) {
if next == nil {
l.next = nil
diff --git a/plugins/helper/queue.go b/plugins/helper/queue.go
index 4dd18e92..f41053e3 100644
--- a/plugins/helper/queue.go
+++ b/plugins/helper/queue.go
@@ -22,12 +22,14 @@ import (
"sync/atomic"
)
+// QueueNode represents a node in the queue
type QueueNode interface {
Next() interface{}
SetNext(next interface{})
Data() interface{}
}
+// Queue represetns a queue
type Queue struct {
count int64
head QueueNode
@@ -73,7 +75,7 @@ func (q *Queue) PushWithoutLock(node QueueNode) {
// PullWithOutLock is no lock mode of Pull
func (q *Queue) PullWithOutLock() QueueNode {
- var node QueueNode = nil
+ var node QueueNode
if q.head != nil {
node = q.head
@@ -127,11 +129,13 @@ func NewQueue() *Queue {
}
}
+// QueueIteratorNode implements the helper.Iterator interface with ability to accept new item when being iterated
type QueueIteratorNode struct {
next QueueNode
data interface{}
}
+// Next return the next node
func (q *QueueIteratorNode) Next() interface{} {
if q.next == nil {
return nil
@@ -139,6 +143,7 @@ func (q *QueueIteratorNode) Next() interface{} {
return q.next
}
+// SetNext updates the next pointer of the node
func (q *QueueIteratorNode) SetNext(next interface{}) {
if next == nil {
q.next = nil
@@ -147,10 +152,12 @@ func (q *QueueIteratorNode) SetNext(next interface{}) {
}
}
+// Data returns data of the node
func (q *QueueIteratorNode) Data() interface{} {
return q.data
}
+// NewQueueIteratorNode creates a new QueueIteratorNode
func NewQueueIteratorNode(data interface{}) *QueueIteratorNode {
return &QueueIteratorNode{
data: data,
diff --git a/plugins/icla/api/swagger.go b/plugins/icla/api/swagger.go
index 21d3f3f3..8f9a0f60 100644
--- a/plugins/icla/api/swagger.go
+++ b/plugins/icla/api/swagger.go
@@ -25,6 +25,7 @@ package api
// @Router /blueprints/icla/blueprint-setting [post]
func _() {}
+//nolint:unused,deadcode
type iclaBlueprintSetting []struct {
Version string `json:"version" example:"1.0.0"`
Connections []struct {
@@ -40,6 +41,7 @@ type iclaBlueprintSetting []struct {
// @Router /pipelines/icla/pipeline-plan [post]
func _() {}
+//nolint:unused,deadcode
type iclaPipelinePlan [][]struct {
Plugin string `json:"plugin" example:"icla"`
}
diff --git a/plugins/jenkins/models/build_repo.go b/plugins/jenkins/models/build_repo.go
index 104fa3f7..2a03e873 100644
--- a/plugins/jenkins/models/build_repo.go
+++ b/plugins/jenkins/models/build_repo.go
@@ -1,3 +1,20 @@
+/*
+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/models/common"
diff --git a/plugins/jenkins/models/job_dag.go b/plugins/jenkins/models/job_dag.go
index dcbe7253..a02416d1 100644
--- a/plugins/jenkins/models/job_dag.go
+++ b/plugins/jenkins/models/job_dag.go
@@ -1,3 +1,20 @@
+/*
+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/models/common"
diff --git a/plugins/jenkins/models/pipeline.go b/plugins/jenkins/models/pipeline.go
index 4b5b21ad..557f1092 100644
--- a/plugins/jenkins/models/pipeline.go
+++ b/plugins/jenkins/models/pipeline.go
@@ -1,3 +1,20 @@
+/*
+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 (
diff --git a/plugins/jenkins/models/task.go b/plugins/jenkins/models/task.go
index 4d35b501..999e135c 100644
--- a/plugins/jenkins/models/task.go
+++ b/plugins/jenkins/models/task.go
@@ -1,3 +1,20 @@
+/*
+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 (
diff --git a/plugins/jenkins/tasks/build_stages_enricher.go b/plugins/jenkins/tasks/build_stages_enricher.go
index e0af3128..c321249e 100644
--- a/plugins/jenkins/tasks/build_stages_enricher.go
+++ b/plugins/jenkins/tasks/build_stages_enricher.go
@@ -45,6 +45,9 @@ func EnrichApiBuildWithStages(taskCtx core.SubTaskContext) error {
dal.Groupby("build_name"),
}
cursor, err := db.Cursor(clauses...)
+ if err != nil {
+ return err
+ }
defer cursor.Close()
taskCtx.SetProgress(0, -1)
diff --git a/plugins/jira/api/proxy.go b/plugins/jira/api/proxy.go
index 65ec132b..5dcf4646 100644
--- a/plugins/jira/api/proxy.go
+++ b/plugins/jira/api/proxy.go
@@ -21,7 +21,7 @@ import (
"context"
"encoding/json"
"fmt"
- "io/ioutil"
+ "io"
"time"
"github.com/apache/incubator-devlake/plugins/core"
@@ -58,7 +58,7 @@ func Proxy(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
}
defer resp.Body.Close()
- body, err := ioutil.ReadAll(resp.Body)
+ body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
diff --git a/plugins/jira/models/migrationscripts/20220407_add_source_table.go b/plugins/jira/models/migrationscripts/20220407_add_source_table.go
index 7dceb0df..8d431298 100644
--- a/plugins/jira/models/migrationscripts/20220407_add_source_table.go
+++ b/plugins/jira/models/migrationscripts/20220407_add_source_table.go
@@ -1,3 +1,20 @@
+/*
+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 (
diff --git a/plugins/jira/models/migrationscripts/20220505_rename_source_table.go b/plugins/jira/models/migrationscripts/20220505_rename_source_table.go
index 269d2377..afbd8305 100644
--- a/plugins/jira/models/migrationscripts/20220505_rename_source_table.go
+++ b/plugins/jira/models/migrationscripts/20220505_rename_source_table.go
@@ -5,7 +5,9 @@ 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.
diff --git a/plugins/jira/models/migrationscripts/20220716_add_init_tables.go b/plugins/jira/models/migrationscripts/20220716_add_init_tables.go
index 65affff8..a42e6235 100644
--- a/plugins/jira/models/migrationscripts/20220716_add_init_tables.go
+++ b/plugins/jira/models/migrationscripts/20220716_add_init_tables.go
@@ -107,6 +107,7 @@ func (*addInitTables) Up(ctx context.Context, db *gorm.DB) (err error) {
if err != nil {
return err
}
+ //nolint:errcheck
defer db.Migrator().DropTable(&JiraConnectionNew{})
// step2
diff --git a/plugins/jira/models/migrationscripts/archived/source.go b/plugins/jira/models/migrationscripts/archived/source.go
index 39244699..e941e701 100644
--- a/plugins/jira/models/migrationscripts/archived/source.go
+++ b/plugins/jira/models/migrationscripts/archived/source.go
@@ -5,7 +5,9 @@ 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.
diff --git a/plugins/jira/tasks/board_collector.go b/plugins/jira/tasks/board_collector.go
index 8b6646d8..d35adb43 100644
--- a/plugins/jira/tasks/board_collector.go
+++ b/plugins/jira/tasks/board_collector.go
@@ -19,7 +19,7 @@ package tasks
import (
"encoding/json"
- "io/ioutil"
+ "io"
"net/http"
"github.com/apache/incubator-devlake/plugins/core"
@@ -56,7 +56,7 @@ func CollectBoard(taskCtx core.SubTaskContext) error {
GetTotalPages: GetTotalPagesFromResponse,
Concurrency: 10,
ResponseParser: func(res *http.Response) ([]json.RawMessage, error) {
- blob, err := ioutil.ReadAll(res.Body)
+ blob, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
diff --git a/plugins/jira/tasks/epic_collector.go b/plugins/jira/tasks/epic_collector.go
index e24a957d..30f3b499 100644
--- a/plugins/jira/tasks/epic_collector.go
+++ b/plugins/jira/tasks/epic_collector.go
@@ -27,7 +27,7 @@ import (
"encoding/json"
"github.com/apache/incubator-devlake/plugins/helper"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
)
@@ -90,7 +90,7 @@ func CollectEpics(taskCtx core.SubTaskContext) error {
var data struct {
Issues []json.RawMessage `json:"issues"`
}
- blob, err := ioutil.ReadAll(res.Body)
+ blob, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
diff --git a/plugins/jira/tasks/issue_collector.go b/plugins/jira/tasks/issue_collector.go
index 85958642..4ce5b416 100644
--- a/plugins/jira/tasks/issue_collector.go
+++ b/plugins/jira/tasks/issue_collector.go
@@ -21,7 +21,7 @@ import (
"encoding/json"
"fmt"
"github.com/apache/incubator-devlake/errors"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
@@ -147,7 +147,7 @@ func CollectIssues(taskCtx core.SubTaskContext) error {
var data struct {
Issues []json.RawMessage `json:"issues"`
}
- blob, err := ioutil.ReadAll(res.Body)
+ blob, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
diff --git a/plugins/jira/tasks/issue_extractor.go b/plugins/jira/tasks/issue_extractor.go
index 47a101e5..bb6e77a3 100644
--- a/plugins/jira/tasks/issue_extractor.go
+++ b/plugins/jira/tasks/issue_extractor.go
@@ -111,11 +111,10 @@ func extractIssues(data *JiraTaskData, mappings *typeMappings, ignoreBoard bool,
}
if data.Options.TransformationRules.StoryPointField != "" {
unknownStoryPoint := apiIssue.Fields.AllFields[data.Options.TransformationRules.StoryPointField]
- switch unknownStoryPoint.(type) {
+ switch sp := unknownStoryPoint.(type) {
case string:
// string, try to parse
- strStoryPoint, _ := unknownStoryPoint.(string)
- issue.StoryPoint, _ = strconv.ParseFloat(strStoryPoint, 32)
+ issue.StoryPoint, _ = strconv.ParseFloat(sp, 32)
case nil:
default:
// not string, convert to float64, ignore it if failed
diff --git a/plugins/org/api/types.go b/plugins/org/api/types.go
index d0559001..052ea448 100644
--- a/plugins/org/api/types.go
+++ b/plugins/org/api/types.go
@@ -180,16 +180,16 @@ type userAccount struct {
UserId string
}
-func (au *userAccount) toDomainLayer(accountUsers []userAccount) []*crossdomain.UserAccount {
- result := make([]*crossdomain.UserAccount, 0, len(accountUsers))
- for _, ac := range accountUsers {
- result = append(result, &crossdomain.UserAccount{
- UserId: ac.UserId,
- AccountId: ac.AccountId,
- })
- }
- return result
-}
+// func (au *userAccount) toDomainLayer(accountUsers []userAccount) []*crossdomain.UserAccount {
+// result := make([]*crossdomain.UserAccount, 0, len(accountUsers))
+// for _, ac := range accountUsers {
+// result = append(result, &crossdomain.UserAccount{
+// UserId: ac.UserId,
+// AccountId: ac.AccountId,
+// })
+// }
+// return result
+// }
func (au *userAccount) fromDomainLayer(accountUsers []crossdomain.UserAccount) []userAccount {
result := make([]userAccount, 0, len(accountUsers))
@@ -272,6 +272,6 @@ func (*projectMapping) toDomainLayer(tt []projectMapping) []*crossdomain.Project
return result
}
-func (m *projectMapping) fakeData() []projectMapping {
- return fakeProjectMapping
-}
+// func (m *projectMapping) fakeData() []projectMapping {
+// return fakeProjectMapping
+// }
diff --git a/plugins/org/tasks/user_account.go b/plugins/org/tasks/user_account.go
index 0d69207d..c4424b24 100644
--- a/plugins/org/tasks/user_account.go
+++ b/plugins/org/tasks/user_account.go
@@ -18,7 +18,6 @@ limitations under the License.
package tasks
import (
- "github.com/apache/incubator-devlake/models/common"
"reflect"
"github.com/apache/incubator-devlake/models/domainlayer/crossdomain"
@@ -38,11 +37,6 @@ var ConnectUserAccountsExactMeta = core.SubTaskMeta{
func ConnectUserAccountsExact(taskCtx core.SubTaskContext) error {
db := taskCtx.GetDal()
data := taskCtx.GetData().(*TaskData)
- type input struct {
- UserId string
- AccountId string
- common.NoPKModel
- }
var users []crossdomain.User
err := db.All(&users)
if err != nil {
diff --git a/plugins/refdiff/api/swagger.go b/plugins/refdiff/api/swagger.go
index 9d703df3..f7e88963 100644
--- a/plugins/refdiff/api/swagger.go
+++ b/plugins/refdiff/api/swagger.go
@@ -23,8 +23,9 @@ package api
// @Accept application/json
// @Param blueprint body RefdiffBlueprintPlan true "json"
// @Router /blueprints/refdiff/blueprint-plan [post]
-func _func() {}
+func _() {}
+//nolint:unused
type RefdiffBlueprintPlan [][]struct {
Plugin string `json:"plugin"`
Options struct {
diff --git a/plugins/starrocks/starrocks.go b/plugins/starrocks/starrocks.go
index 40dd8b8d..9fc81db6 100644
--- a/plugins/starrocks/starrocks.go
+++ b/plugins/starrocks/starrocks.go
@@ -6,7 +6,7 @@ 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
+ 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,
@@ -14,6 +14,7 @@ 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 (
@@ -43,7 +44,7 @@ func (s StarRocks) PrepareTaskData(taskCtx core.TaskContext, options map[string]
return &op, nil
}
-func (plugin StarRocks) GetTablesInfo() []core.Tabler {
+func (s StarRocks) GetTablesInfo() []core.Tabler {
return []core.Tabler{}
}
diff --git a/plugins/starrocks/task_data.go b/plugins/starrocks/task_data.go
index bb0879b8..49e24e7d 100644
--- a/plugins/starrocks/task_data.go
+++ b/plugins/starrocks/task_data.go
@@ -6,7 +6,7 @@ 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
+ 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,
@@ -14,6 +14,7 @@ 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
type StarRocksConfig struct {
diff --git a/plugins/starrocks/tasks.go b/plugins/starrocks/tasks.go
index dba0ebd5..a374ec77 100644
--- a/plugins/starrocks/tasks.go
+++ b/plugins/starrocks/tasks.go
@@ -6,7 +6,7 @@ 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
+ 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,
@@ -14,6 +14,7 @@ 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 (
@@ -226,6 +227,9 @@ func loadData(starrocks *sql.DB, c core.SubTaskContext, starrocksTable string, t
if resp.StatusCode == 307 {
var location *url.URL
location, err = resp.Location()
+ if err != nil {
+ return err
+ }
req, err = http.NewRequest(http.MethodPut, location.String(), bytes.NewBuffer(jsonData))
if err != nil {
return err
diff --git a/plugins/starrocks/utils.go b/plugins/starrocks/utils.go
index a68c79e5..ace195ff 100644
--- a/plugins/starrocks/utils.go
+++ b/plugins/starrocks/utils.go
@@ -6,7 +6,7 @@ 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
+ 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,
@@ -14,6 +14,7 @@ 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 "strings"
diff --git a/plugins/tapd/tasks/shared.go b/plugins/tapd/tasks/shared.go
index 67c92ac2..c1e500fc 100644
--- a/plugins/tapd/tasks/shared.go
+++ b/plugins/tapd/tasks/shared.go
@@ -21,7 +21,7 @@ import (
"encoding/json"
"fmt"
"gorm.io/gorm"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
@@ -93,7 +93,7 @@ func parseIterationChangelog(taskCtx core.SubTaskContext, old string, new string
return iterationFrom.Id, iterationTo.Id, nil
}
func GetRawMessageDirectFromResponse(res *http.Response) ([]json.RawMessage, error) {
- body, err := ioutil.ReadAll(res.Body)
+ body, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return nil, err
diff --git a/plugins/tapd/tasks/task_changelog_collector.go b/plugins/tapd/tasks/task_changelog_collector.go
index 66f79fa1..b61d7d81 100644
--- a/plugins/tapd/tasks/task_changelog_collector.go
+++ b/plugins/tapd/tasks/task_changelog_collector.go
@@ -50,7 +50,7 @@ func CollectTaskChangelogs(taskCtx core.SubTaskContext) error {
}
err := db.First(&latestUpdated, clauses...)
if err != nil && err != gorm.ErrRecordNotFound {
- return errors.NotFound.Wrap(err, fmt.Sprintf("failed to get latest tapd changelog record"))
+ return errors.NotFound.Wrap(err, "failed to get latest tapd changelog record")
}
if latestUpdated.Id > 0 {
since = (*time.Time)(latestUpdated.Created)
diff --git a/runner/directrun.go b/runner/directrun.go
index c8acc1bf..7c67c9f1 100644
--- a/runner/directrun.go
+++ b/runner/directrun.go
@@ -81,7 +81,7 @@ func DirectRun(cmd *cobra.Command, args []string, pluginTask core.PluginTask, op
panic(err)
}
ctx := createContext()
- var parentTaskID uint64 = 0
+ var parentTaskID uint64
err = RunPluginSubTasks(
ctx,
cfg,
diff --git a/runner/run_task.go b/runner/run_task.go
index 6d6f6026..8f341f0f 100644
--- a/runner/run_task.go
+++ b/runner/run_task.go
@@ -68,9 +68,7 @@ func RunTask(
if err != nil {
lakeErr := errors.AsLakeErrorType(err)
subTaskName := "unknown"
- if lakeErr == nil {
- //skip
- } else if lakeErr = lakeErr.As(errors.SubtaskErr); lakeErr != nil {
+ if lakeErr = lakeErr.As(errors.SubtaskErr); lakeErr != nil {
if meta, ok := lakeErr.GetData().(*core.SubTaskMeta); ok {
subTaskName = meta.Name
}
@@ -135,7 +133,7 @@ func RunTask(
func RunPluginTask(
ctx context.Context,
cfg *viper.Viper,
- logger core.Logger,
+ log core.Logger,
db *gorm.DB,
taskID uint64,
name string,
@@ -154,7 +152,7 @@ func RunPluginTask(
return RunPluginSubTasks(
ctx,
cfg,
- logger,
+ log,
db,
taskID,
name,
@@ -169,7 +167,7 @@ func RunPluginTask(
func RunPluginSubTasks(
ctx context.Context,
cfg *viper.Viper,
- logger core.Logger,
+ log core.Logger,
db *gorm.DB,
taskID uint64,
name string,
@@ -178,7 +176,7 @@ func RunPluginSubTasks(
pluginTask core.PluginTask,
progress chan core.RunningProgress,
) errors.Error {
- logger.Info("start plugin")
+ log.Info("start plugin")
// find out all possible subtasks this plugin can offer
subtaskMetas := pluginTask.SubTaskMetas()
subtasksFlag := make(map[string]bool)
@@ -232,7 +230,7 @@ func RunPluginSubTasks(
}
}
- taskCtx := helper.NewDefaultTaskContext(ctx, cfg, logger, db, name, subtasksFlag, progress)
+ taskCtx := helper.NewDefaultTaskContext(ctx, cfg, log, db, name, subtasksFlag, progress)
if closeablePlugin, ok := pluginTask.(core.CloseablePluginTask); ok {
defer closeablePlugin.Close(taskCtx)
}
@@ -257,7 +255,7 @@ func RunPluginSubTasks(
}
// run subtask
- logger.Info("executing subtask %s", subtaskMeta.Name)
+ log.Info("executing subtask %s", subtaskMeta.Name)
subtaskNumber++
if progress != nil {
progress <- core.RunningProgress{
@@ -266,7 +264,7 @@ func RunPluginSubTasks(
SubTaskNumber: subtaskNumber,
}
}
- err = runSubtask(logger, db, taskID, subtaskNumber, subtaskCtx, subtaskMeta.EntryPoint)
+ err = runSubtask(log, db, taskID, subtaskNumber, subtaskCtx, subtaskMeta.EntryPoint)
if err != nil {
return errors.SubtaskErr.Wrap(err, fmt.Sprintf("subtask %s ended unexpectedly", subtaskMeta.Name), errors.WithData(&subtaskMeta))
}
@@ -277,7 +275,7 @@ func RunPluginSubTasks(
}
// UpdateProgressDetail FIXME ...
-func UpdateProgressDetail(db *gorm.DB, logger core.Logger, taskId uint64, progressDetail *models.TaskProgressDetail, p *core.RunningProgress) {
+func UpdateProgressDetail(db *gorm.DB, log core.Logger, taskId uint64, progressDetail *models.TaskProgressDetail, p *core.RunningProgress) {
task := &models.Task{}
task.ID = taskId
switch p.Type {
@@ -290,7 +288,7 @@ func UpdateProgressDetail(db *gorm.DB, logger core.Logger, taskId uint64, progre
pct := float32(p.Current) / float32(p.Total)
err := db.Model(task).Update("progress", pct).Error
if err != nil {
- logger.Error(err, "failed to update progress: %w")
+ log.Error(err, "failed to update progress: %w")
}
case core.SubTaskSetProgress:
progressDetail.TotalRecords = p.Total
@@ -304,7 +302,7 @@ func UpdateProgressDetail(db *gorm.DB, logger core.Logger, taskId uint64, progre
}
func runSubtask(
- logger core.Logger,
+ log core.Logger,
db *gorm.DB,
parentID uint64,
subtaskNumber int,
@@ -322,14 +320,14 @@ func runSubtask(
finishedAt := time.Now()
subtask.FinishedAt = &finishedAt
subtask.SpentSeconds = finishedAt.Unix() - beginAt.Unix()
- recordSubtask(logger, db, subtask)
+ recordSubtask(log, db, subtask)
}()
return entryPoint(ctx)
}
-func recordSubtask(logger core.Logger, db *gorm.DB, subtask *models.Subtask) {
+func recordSubtask(log core.Logger, db *gorm.DB, subtask *models.Subtask) {
if err := db.Create(&subtask).Error; err != nil {
- logger.Error(err, "error writing subtask %d status to DB: %v", subtask.ID)
+ log.Error(err, "error writing subtask %d status to DB: %v", subtask.ID)
}
}
diff --git a/services/blueprint_helper.go b/services/blueprint_helper.go
index bbb9c5ba..7e299c2e 100644
--- a/services/blueprint_helper.go
+++ b/services/blueprint_helper.go
@@ -24,7 +24,7 @@ import (
"gorm.io/gorm"
)
-// CreateBlueprint accepts a Blueprint instance and insert it to database
+// CreateDbBlueprint accepts a Blueprint instance and insert it to database
func CreateDbBlueprint(dbBlueprint *models.DbBlueprint) error {
err := db.Create(&dbBlueprint).Error
if err != nil {
@@ -33,7 +33,7 @@ func CreateDbBlueprint(dbBlueprint *models.DbBlueprint) error {
return nil
}
-// GetBlueprints returns a paginated list of Blueprints based on `query`
+// GetDbBlueprints returns a paginated list of Blueprints based on `query`
func GetDbBlueprints(query *BlueprintQuery) ([]*models.DbBlueprint, int64, error) {
dbBlueprints := make([]*models.DbBlueprint, 0)
db := db.Model(dbBlueprints).Order("id DESC")
@@ -58,7 +58,7 @@ func GetDbBlueprints(query *BlueprintQuery) ([]*models.DbBlueprint, int64, error
return dbBlueprints, count, nil
}
-// GetBlueprint returns the detail of a given Blueprint ID
+// GetDbBlueprint returns the detail of a given Blueprint ID
func GetDbBlueprint(dbBlueprintId uint64) (*models.DbBlueprint, error) {
dbBlueprint := &models.DbBlueprint{}
err := db.First(dbBlueprint, dbBlueprintId).Error
@@ -71,7 +71,7 @@ func GetDbBlueprint(dbBlueprintId uint64) (*models.DbBlueprint, error) {
return dbBlueprint, nil
}
-// DeleteBlueprint FIXME ...
+// DeleteDbBlueprint deletes blueprint by id
func DeleteDbBlueprint(id uint64) error {
err := db.Delete(&models.DbBlueprint{}, "id = ?", id).Error
if err != nil {
diff --git a/services/init.go b/services/init.go
index f0690e03..cb1370a4 100644
--- a/services/init.go
+++ b/services/init.go
@@ -75,6 +75,7 @@ func Init() {
log.Info("Db migration confirmation needed: %v", migrationRequireConfirmation)
}
+// ExecuteMigration executes all pending migration scripts and initialize services module
func ExecuteMigration() error {
err := migration.Execute(context.Background())
if err != nil {
@@ -86,6 +87,7 @@ func ExecuteMigration() error {
return nil
}
+// MigrationRequireConfirmation returns if there were migration scripts waiting to be executed
func MigrationRequireConfirmation() bool {
return migrationRequireConfirmation
}
diff --git a/services/notification.go b/services/notification.go
index d68ad30d..b76faa2a 100644
--- a/services/notification.go
+++ b/services/notification.go
@@ -22,7 +22,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
- "io/ioutil"
+ "io"
"math/rand"
"net/http"
"strings"
@@ -91,7 +91,7 @@ func (n *NotificationService) sendNotification(notificationType models.Notificat
}
notification.ResponseCode = resp.StatusCode
- respBody, err := ioutil.ReadAll(resp.Body)
+ respBody, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
diff --git a/services/pipeline_helper.go b/services/pipeline_helper.go
index c59fc50a..1aac6665 100644
--- a/services/pipeline_helper.go
+++ b/services/pipeline_helper.go
@@ -27,7 +27,7 @@ import (
"gorm.io/gorm"
)
-// CreatePipeline and return the model
+// CreateDbPipeline returns a NewPipeline
func CreateDbPipeline(newPipeline *models.NewPipeline) (*models.DbPipeline, error) {
// create pipeline object from posted data
dbPipeline := &models.DbPipeline{
@@ -100,7 +100,7 @@ func CreateDbPipeline(newPipeline *models.NewPipeline) (*models.DbPipeline, erro
return dbPipeline, nil
}
-// GetPipelines by query
+// GetDbPipelines by query
func GetDbPipelines(query *PipelineQuery) ([]*models.DbPipeline, int64, error) {
dbPipelines := make([]*models.DbPipeline, 0)
db := db.Model(dbPipelines).Order("id DESC")
@@ -129,7 +129,7 @@ func GetDbPipelines(query *PipelineQuery) ([]*models.DbPipeline, int64, error) {
return dbPipelines, count, nil
}
-// GetPipeline by id
+// GetDbPipeline by id
func GetDbPipeline(pipelineId uint64) (*models.DbPipeline, error) {
dbPipeline := &models.DbPipeline{}
err := db.First(dbPipeline, pipelineId).Error
@@ -142,7 +142,7 @@ func GetDbPipeline(pipelineId uint64) (*models.DbPipeline, error) {
return dbPipeline, nil
}
-// parsePipeline
+// parsePipeline converts DbPipeline to Pipeline
func parsePipeline(dbPipeline *models.DbPipeline) *models.Pipeline {
pipeline := models.Pipeline{
Model: dbPipeline.Model,
@@ -161,7 +161,7 @@ func parsePipeline(dbPipeline *models.DbPipeline) *models.Pipeline {
return &pipeline
}
-// parseDbPipeline
+// parseDbPipeline converts Pipeline to DbPipeline
func parseDbPipeline(pipeline *models.Pipeline) *models.DbPipeline {
dbPipeline := models.DbPipeline{
Model: pipeline.Model,
@@ -180,7 +180,7 @@ func parseDbPipeline(pipeline *models.Pipeline) *models.DbPipeline {
return &dbPipeline
}
-// encryptDbPipeline
+// encryptDbPipeline encrypts dbPipeline.Plan
func encryptDbPipeline(dbPipeline *models.DbPipeline) (*models.DbPipeline, error) {
encKey := config.GetConfig().GetString(core.EncodeKeyEnvStr)
planEncrypt, err := core.Encrypt(encKey, dbPipeline.Plan)
@@ -191,7 +191,7 @@ func encryptDbPipeline(dbPipeline *models.DbPipeline) (*models.DbPipeline, error
return dbPipeline, nil
}
-// encryptDbPipeline
+// encryptDbPipeline decrypts dbPipeline.Plan
func decryptDbPipeline(dbPipeline *models.DbPipeline) (*models.DbPipeline, error) {
encKey := config.GetConfig().GetString(core.EncodeKeyEnvStr)
plan, err := core.Decrypt(encKey, dbPipeline.Plan)
diff --git a/services/pluginapi.go b/services/pluginapi.go
index ead35d8c..379aa7e3 100644
--- a/services/pluginapi.go
+++ b/services/pluginapi.go
@@ -31,6 +31,7 @@ GetPluginsApiResources return value
}
}
*/
+// GetPluginsApiResources returns all APIs of all plugins
func GetPluginsApiResources() (map[string]map[string]map[string]core.ApiResourceHandler, error) {
res := make(map[string]map[string]map[string]core.ApiResourceHandler)
for pluginName, pluginEntry := range core.AllPlugins() {