You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2022/08/03 02:11:07 UTC
[incubator-devlake] branch release-v0.12 created (now a604fb6f)
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a change to branch release-v0.12
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
at a604fb6f fix: patch /blueprints/:id wouldn't handle byte[]
This branch includes the following new commits:
new a604fb6f fix: patch /blueprints/:id wouldn't handle byte[]
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-devlake] 01/01: fix: patch /blueprints/:id wouldn't handle byte[]
Posted by kl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch release-v0.12
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit a604fb6fb96100b5101a1812046d4077f650d2ad
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Tue Aug 2 22:13:13 2022 +0800
fix: patch /blueprints/:id wouldn't handle byte[]
---
.gitignore | 8 +--
models/blueprint.go | 33 ++++++------
plugins/helper/iso8601time.go | 46 -----------------
plugins/helper/mapstructure.go | 76 ++++++++++++++++++++++++++++
plugins/helper/mapstructure_test.go | 58 +++++++++++++++++++++
scripts/pm/framework/blueprint-create.sh | 65 ++++++++++++++++++++++++
scripts/pm/framework/blueprint-update.sh | 68 +++++++++++++++++++++++++
scripts/pm/framework/pipeline-create.sh | 40 +++++++++++++++
scripts/pm/framework/pipeline-get-detail.sh | 23 +++++++++
scripts/pm/framework/pipeline-get-tasks.sh | 23 +++++++++
scripts/pm/framework/proceed-db-migration.sh | 21 ++++++++
scripts/pm/github/trigger-pipline.sh | 37 ++++++++++++++
scripts/pm/github/user.sh | 23 +++++++++
scripts/pm/jira/board-issues.sh | 25 +++++++++
scripts/pm/jira/plugin/connection-create.sh | 32 ++++++++++++
scripts/pm/vars/active-vars.sh | 1 +
scripts/pm/vars/active-vars.sh.example | 22 ++++++++
scripts/pm/vars/local-vars.sh | 9 ++++
services/blueprint.go | 14 ++---
19 files changed, 552 insertions(+), 72 deletions(-)
diff --git a/.gitignore b/.gitignore
index b47c22b6..dda6d767 100644
--- a/.gitignore
+++ b/.gitignore
@@ -73,6 +73,7 @@ web_modules/
.env
.env.*
!.env.example
+scripts/pm/vars/*-vars.sh
# parcel-bundler cache (https://parceljs.org/)
.cache
@@ -151,10 +152,9 @@ bin
libgit2
.air.toml
-# swagger .json and .yaml
-api/docs/swagger.json
-api/docs/swagger.yaml
-
# auto generated code
mocks/
+api/docs/swagger.json
+api/docs/swagger.yaml
api/docs/docs.go
+*.result/
diff --git a/models/blueprint.go b/models/blueprint.go
index adced10e..413bb9aa 100644
--- a/models/blueprint.go
+++ b/models/blueprint.go
@@ -22,20 +22,21 @@ import (
"github.com/apache/incubator-devlake/models/common"
"github.com/apache/incubator-devlake/plugins/core"
- "gorm.io/datatypes"
)
-const BLUEPRINT_MODE_NORMAL = "NORMAL"
-const BLUEPRINT_MODE_ADVANCED = "ADVANCED"
+const (
+ BLUEPRINT_MODE_NORMAL = "NORMAL"
+ BLUEPRINT_MODE_ADVANCED = "ADVANCED"
+)
type Blueprint struct {
- Name string `json:"name" validate:"required"`
- Mode string `json:"mode" gorm:"varchar(20)" validate:"required,oneof=NORMAL ADVANCED"`
- Plan datatypes.JSON `json:"plan"`
- Enable bool `json:"enable"`
- CronConfig string `json:"cronConfig"`
- IsManual bool `json:"isManual"`
- Settings datatypes.JSON `json:"settings"`
+ Name string `json:"name" validate:"required"`
+ Mode string `json:"mode" gorm:"varchar(20)" validate:"required,oneof=NORMAL ADVANCED"`
+ Plan json.RawMessage `json:"plan"`
+ Enable bool `json:"enable"`
+ CronConfig string `json:"cronConfig"`
+ IsManual bool `json:"isManual"`
+ Settings json.RawMessage `json:"settings"`
common.Model
}
@@ -50,10 +51,10 @@ type BlueprintSettings struct {
// UnmarshalPlan unmarshals Plan in JSON to strong-typed core.PipelinePlan
func (bp *Blueprint) UnmarshalPlan() (core.PipelinePlan, error) {
- var plan core.PipelinePlan
- err := json.Unmarshal(bp.Plan, &plan)
- if err != nil {
- return nil, err
- }
- return plan, nil
+ var plan core.PipelinePlan
+ err := json.Unmarshal(bp.Plan, &plan)
+ if err != nil {
+ return nil, err
+ }
+ return plan, nil
}
diff --git a/plugins/helper/iso8601time.go b/plugins/helper/iso8601time.go
index 6232eb83..5b02e9c9 100644
--- a/plugins/helper/iso8601time.go
+++ b/plugins/helper/iso8601time.go
@@ -19,12 +19,9 @@ package helper
import (
"fmt"
- "reflect"
"regexp"
"strings"
"time"
-
- "github.com/mitchellh/mapstructure"
)
/*
@@ -134,46 +131,3 @@ func Iso8601TimeToTime(iso8601Time *Iso8601Time) *time.Time {
t := iso8601Time.ToTime()
return &t
}
-
-// DecodeMapStruct with time.Time and Iso8601Time support
-func DecodeMapStruct(input map[string]interface{}, result interface{}) error {
- decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
- Metadata: nil,
- DecodeHook: mapstructure.ComposeDecodeHookFunc(
- func(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error) {
- if t != reflect.TypeOf(Iso8601Time{}) && t != reflect.TypeOf(time.Time{}) {
- return data, nil
- }
-
- var tt time.Time
- var err error
-
- switch f.Kind() {
- case reflect.String:
- tt, err = ConvertStringToTime(data.(string))
- case reflect.Float64:
- tt = time.Unix(0, int64(data.(float64))*int64(time.Millisecond))
- case reflect.Int64:
- tt = time.Unix(0, data.(int64)*int64(time.Millisecond))
- }
- if err != nil {
- return data, nil
- }
-
- if t == reflect.TypeOf(Iso8601Time{}) {
- return Iso8601Time{time: tt}, nil
- }
- return tt, nil
- },
- ),
- Result: result,
- })
- if err != nil {
- return err
- }
-
- if err := decoder.Decode(input); err != nil {
- return err
- }
- return err
-}
diff --git a/plugins/helper/mapstructure.go b/plugins/helper/mapstructure.go
new file mode 100644
index 00000000..17e74df4
--- /dev/null
+++ b/plugins/helper/mapstructure.go
@@ -0,0 +1,76 @@
+/*
+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 helper
+
+import (
+ "encoding/json"
+ "reflect"
+ "time"
+
+ "github.com/mitchellh/mapstructure"
+)
+
+// DecodeMapStruct with time.Time and Iso8601Time support
+func DecodeMapStruct(input map[string]interface{}, result interface{}) error {
+ decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
+ ZeroFields: true,
+ DecodeHook: mapstructure.ComposeDecodeHookFunc(
+ func(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error) {
+ if data == nil {
+ return nil, nil
+ }
+ if t == reflect.TypeOf(json.RawMessage{}) {
+ return json.Marshal(data)
+ }
+
+ if t != reflect.TypeOf(Iso8601Time{}) && t != reflect.TypeOf(time.Time{}) {
+ return data, nil
+ }
+
+ var tt time.Time
+ var err error
+
+ switch f.Kind() {
+ case reflect.String:
+ tt, err = ConvertStringToTime(data.(string))
+ case reflect.Float64:
+ tt = time.Unix(0, int64(data.(float64))*int64(time.Millisecond))
+ case reflect.Int64:
+ tt = time.Unix(0, data.(int64)*int64(time.Millisecond))
+ }
+ if err != nil {
+ return data, nil
+ }
+
+ if t == reflect.TypeOf(Iso8601Time{}) {
+ return Iso8601Time{time: tt}, nil
+ }
+ return tt, nil
+ },
+ ),
+ Result: result,
+ })
+ if err != nil {
+ return err
+ }
+
+ if err := decoder.Decode(input); err != nil {
+ return err
+ }
+ return err
+}
diff --git a/plugins/helper/mapstructure_test.go b/plugins/helper/mapstructure_test.go
new file mode 100644
index 00000000..34ab85e3
--- /dev/null
+++ b/plugins/helper/mapstructure_test.go
@@ -0,0 +1,58 @@
+/*
+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 helper
+
+import (
+ "encoding/json"
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+type DecodeMapStructJson struct {
+ Id int
+ Settings json.RawMessage
+ Plan json.RawMessage
+ Existing json.RawMessage
+}
+
+func TestDecodeMapStructJsonRawMessage(t *testing.T) {
+ input := map[string]interface{}{
+ "id": 100,
+ "settings": map[string]interface{}{
+ "version": "1.0.0",
+ },
+ }
+
+ decoded := &DecodeMapStructJson{
+ Settings: json.RawMessage(`{"version": "1.0.101"}`),
+ Existing: json.RawMessage(`{"hello", "world"}`),
+ }
+ err := DecodeMapStruct(input, decoded)
+ fmt.Println(string(decoded.Settings))
+ assert.Nil(t, err)
+ assert.Equal(t, decoded.Id, 100)
+ assert.Nil(t, decoded.Plan)
+ assert.NotNil(t, decoded.Settings)
+ settings := make(map[string]string)
+ err = json.Unmarshal(decoded.Settings, &settings)
+ assert.Nil(t, err)
+ assert.Equal(t, settings["version"], "1.0.0")
+ assert.Equal(t, decoded.Existing, json.RawMessage(`{"hello", "world"}`))
+}
diff --git a/scripts/pm/framework/blueprint-create.sh b/scripts/pm/framework/blueprint-create.sh
new file mode 100755
index 00000000..be6cabcd
--- /dev/null
+++ b/scripts/pm/framework/blueprint-create.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+#
+# 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.
+#
+
+. "$(dirname $0)/../vars/active-vars.sh"
+
+curl -sv $LAKE_ENDPOINT/blueprints -H "Content-Type: application/json" --data @- <<JSON | jq
+{
+ "name": "MY BLUEPRINT2",
+ "cronConfig": "0 0 * * *",
+ "settings": {
+ "version": "1.0.0",
+ "connections": [
+ {
+ "plugin": "jira",
+ "connectionId": 1,
+ "scope": [
+ {
+ "transformation": {
+ "epicKeyField": "customfield_10014",
+ "typeMappings": {
+ "缺陷": {
+ "standardType": "Bug"
+ },
+ "线上事故": {
+ "standardType": "Incident"
+ },
+ "故事": {
+ "standardType": "Requirement"
+ }
+ },
+ "storyPointField": "customfield_10024",
+ "remotelinkCommitShaPattern": "/commit/([0-9a-f]{40})$"
+ },
+ "options": {
+ "boardId": 70
+ },
+ "entities": [
+ "TICKET",
+ "CROSS"
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "enable": true,
+ "mode": "NORMAL",
+ "isManual": false
+}
+JSON
diff --git a/scripts/pm/framework/blueprint-update.sh b/scripts/pm/framework/blueprint-update.sh
new file mode 100755
index 00000000..13d8a71c
--- /dev/null
+++ b/scripts/pm/framework/blueprint-update.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# 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.
+#
+
+. "$(dirname $0)/../vars/active-vars.sh"
+
+pipeline_id=${1-8}
+
+curl -sv -XPATCH $LAKE_ENDPOINT/blueprints/$pipeline_id \
+ -H "Content-Type: application/json" --data @- <<JSON | jq
+{
+ "name": "MY BLUEPRINT2",
+ "cronConfig": "0 0 * * *",
+ "settings": {
+ "version": "1.0.0",
+ "connections": [
+ {
+ "plugin": "jira",
+ "connectionId": 1,
+ "scope": [
+ {
+ "transformation": {
+ "epicKeyField": "customfield_10014",
+ "typeMappings": {
+ "缺陷": {
+ "standardType": "Bug"
+ },
+ "线上事故": {
+ "standardType": "Incident"
+ },
+ "故事": {
+ "standardType": "Requirement"
+ }
+ },
+ "storyPointField": "customfield_10024",
+ "remotelinkCommitShaPattern": "/commit/([0-9a-f]{40})$"
+ },
+ "options": {
+ "boardId": 70
+ },
+ "entities": [
+ "TICKET",
+ "CROSS"
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "enable": true,
+ "mode": "NORMAL",
+ "isManual": false
+}
+JSON
diff --git a/scripts/pm/framework/pipeline-create.sh b/scripts/pm/framework/pipeline-create.sh
new file mode 100755
index 00000000..19781374
--- /dev/null
+++ b/scripts/pm/framework/pipeline-create.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# 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.
+#
+
+. "$(dirname $0)/../vars/active-vars.sh"
+
+curl -sv $LAKE_ENDPOINT/pipelines --data @- <<JSON | jq
+{
+ "name": "test-all",
+ "plan": [
+ [
+ {
+ "plugin": "jira",
+ "options": {
+ "connectionId": 1,
+ "boardId": 8
+ }
+ },
+ {
+ "plugin": "jenkins",
+ "options": {}
+ }
+ ]
+ ]
+}
+JSON
diff --git a/scripts/pm/framework/pipeline-get-detail.sh b/scripts/pm/framework/pipeline-get-detail.sh
new file mode 100755
index 00000000..7153c67a
--- /dev/null
+++ b/scripts/pm/framework/pipeline-get-detail.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# 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.
+#
+
+. "$(dirname $0)/../vars/active-vars.sh"
+
+pipeline_id=${1-"2"}
+
+curl -sv $LAKE_ENDPOINT/pipelines/$pipeline_id | jq
diff --git a/scripts/pm/framework/pipeline-get-tasks.sh b/scripts/pm/framework/pipeline-get-tasks.sh
new file mode 100755
index 00000000..ca4437d3
--- /dev/null
+++ b/scripts/pm/framework/pipeline-get-tasks.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# 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.
+#
+
+. "$(dirname $0)/../vars/active-vars.sh"
+
+pipeline_id=${1-"2"}
+
+curl -sv $LAKE_ENDPOINT/pipelines/$pipeline_id/tasks | jq
diff --git a/scripts/pm/framework/proceed-db-migration.sh b/scripts/pm/framework/proceed-db-migration.sh
new file mode 100755
index 00000000..cd574087
--- /dev/null
+++ b/scripts/pm/framework/proceed-db-migration.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# 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.
+#
+
+. "$(dirname $0)/../vars/active-vars.sh"
+
+curl -sv $LAKE_ENDPOINT/proceed-db-migration | jq
diff --git a/scripts/pm/github/trigger-pipline.sh b/scripts/pm/github/trigger-pipline.sh
new file mode 100755
index 00000000..85965697
--- /dev/null
+++ b/scripts/pm/github/trigger-pipline.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# 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.
+#
+
+. "$(dirname $0)/../vars/active-vars.sh"
+
+curl -sv $LAKE_ENDPOINT/pipelines --data @- <<JSON | jq
+{
+ "name": "test-github",
+ "plan": [
+ [
+ {
+ "plugin": "github",
+ "options": {
+ "connectionId": 1,
+ "owner": "apache",
+ "repo": "incubator-devlake"
+ }
+ }
+ ]
+ ]
+}
+JSON
diff --git a/scripts/pm/github/user.sh b/scripts/pm/github/user.sh
new file mode 100755
index 00000000..541ff8ac
--- /dev/null
+++ b/scripts/pm/github/user.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# 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.
+#
+
+. "$(dirname $0)/../vars/active-vars.sh"
+
+curl -sv $GITHUB_ENDPOINT/user \
+ -H "Authorization: Token $GITHUB_TOKEN" \
+ | jq
diff --git a/scripts/pm/jira/board-issues.sh b/scripts/pm/jira/board-issues.sh
new file mode 100755
index 00000000..1dc33eb5
--- /dev/null
+++ b/scripts/pm/jira/board-issues.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# 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.
+#
+
+. "$(dirname $0)/../vars/active-vars.sh"
+
+board_id=${1-"8"}
+
+curl -sv $JIRA_ENDPOINT/agile/1.0/board/$board_id/issue \
+ -H "Authorization: Basic $JIRA_BASIC_AUTH" \
+ | jq
diff --git a/scripts/pm/jira/plugin/connection-create.sh b/scripts/pm/jira/plugin/connection-create.sh
new file mode 100755
index 00000000..381b638b
--- /dev/null
+++ b/scripts/pm/jira/plugin/connection-create.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# 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.
+#
+
+. "$(dirname $0)/../../vars/active-vars.sh"
+
+jira_endpoint=${1-$JIRA_ENDPOINT}
+jira_username=${2-$JIRA_USERNAME}
+jira_password=${3-$JIRA_PASSWORD}
+
+curl -sv $LAKE_ENDPOINT/plugins/jira/connections --data @- <<JSON | jq
+{
+ "name": "testjira",
+ "endpoint": "$jira_endpoint",
+ "username": "$jira_username",
+ "password": "$jira_password"
+}
+JSON
diff --git a/scripts/pm/vars/active-vars.sh b/scripts/pm/vars/active-vars.sh
new file mode 120000
index 00000000..5f173bbd
--- /dev/null
+++ b/scripts/pm/vars/active-vars.sh
@@ -0,0 +1 @@
+local-vars.sh
\ No newline at end of file
diff --git a/scripts/pm/vars/active-vars.sh.example b/scripts/pm/vars/active-vars.sh.example
new file mode 100644
index 00000000..5be19151
--- /dev/null
+++ b/scripts/pm/vars/active-vars.sh.example
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# 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.
+#
+
+# ln -s local-vars.sh active-vars.sh
+LAKE_ENDPOINT=${LAKE_ENDPOINT-'http://localhost:8080'}
+JIRA_ENDPOINT=https://merico.atlassian.net/rest
+JIRA_BASIC_AUTH=
diff --git a/scripts/pm/vars/local-vars.sh b/scripts/pm/vars/local-vars.sh
new file mode 100644
index 00000000..aca9b984
--- /dev/null
+++ b/scripts/pm/vars/local-vars.sh
@@ -0,0 +1,9 @@
+LAKE_ENDPOINT=${LAKE_ENDPOINT-'http://localhost:8080'}
+JIRA_ENDPOINT=https://merico.atlassian.net/rest
+JIRA_USERNAME=zhenmian.huang@merico.dev
+JIRA_PASSWORD=NYWS12VFHDCMrZViVpbkD3AA
+JIRA_BASIC_AUTH=emhlbm1pYW4uaHVhbmdAbWVyaWNvLmRldjpOWVdTMTJWRkhEQ01yWlZpVnBia0QzQUE=
+GITHUB_ENDPOINT=https://api.github.com
+GITHUB_TOKEN=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
+
+
diff --git a/services/blueprint.go b/services/blueprint.go
index 314efc78..03229f3e 100644
--- a/services/blueprint.go
+++ b/services/blueprint.go
@@ -26,10 +26,9 @@ import (
"github.com/apache/incubator-devlake/logger"
"github.com/apache/incubator-devlake/models"
"github.com/apache/incubator-devlake/plugins/core"
+ "github.com/apache/incubator-devlake/plugins/helper"
"github.com/go-playground/validator/v10"
- "github.com/mitchellh/mapstructure"
"github.com/robfig/cron/v3"
- "gorm.io/datatypes"
"gorm.io/gorm"
)
@@ -40,8 +39,10 @@ type BlueprintQuery struct {
PageSize int `form:"pageSize"`
}
-var blueprintLog = logger.Global.Nested("blueprint")
-var vld = validator.New()
+var (
+ blueprintLog = logger.Global.Nested("blueprint")
+ vld = validator.New()
+)
// CreateBlueprint accepts a Blueprint instance and insert it to database
func CreateBlueprint(blueprint *models.Blueprint) error {
@@ -139,7 +140,7 @@ func PatchBlueprint(id uint64, body map[string]interface{}) (*models.Blueprint,
return nil, err
}
originMode := blueprint.Mode
- err = mapstructure.Decode(body, blueprint)
+ err = helper.DecodeMapStruct(body, blueprint)
if err != nil {
return nil, err
}
@@ -235,10 +236,11 @@ func createAndRunPipelineByBlueprint(blueprintId uint64, name string, plan core.
}
// GeneratePlanJson generates pipeline plan by version
-func GeneratePlanJson(settings datatypes.JSON) (datatypes.JSON, error) {
+func GeneratePlanJson(settings json.RawMessage) (json.RawMessage, error) {
bpSettings := new(models.BlueprintSettings)
err := json.Unmarshal(settings, bpSettings)
if err != nil {
+ fmt.Println(string(settings))
return nil, err
}
var plan interface{}