You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2023/08/22 08:49:10 UTC
[incubator-devlake] branch main updated: refactor: remove deprecated singer tap (#5933)
This is an automated email from the ASF dual-hosted git repository.
abeizn 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 6338a0f5e refactor: remove deprecated singer tap (#5933)
6338a0f5e is described below
commit 6338a0f5e21564e200ac7dfd1c5168314758f4f6
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Tue Aug 22 16:49:05 2023 +0800
refactor: remove deprecated singer tap (#5933)
---
backend/Makefile | 4 -
backend/core/config/config_viper.go | 1 -
.../migrationscripts/20230822_drop_tap_state.go} | 27 ++++--
backend/core/models/migrationscripts/register.go | 1 +
backend/scripts/singer-model-generator.sh | 97 ----------------------
5 files changed, 22 insertions(+), 108 deletions(-)
diff --git a/backend/Makefile b/backend/Makefile
index b7fb4569b..cccecdd88 100644
--- a/backend/Makefile
+++ b/backend/Makefile
@@ -80,10 +80,6 @@ build: build-plugin build-server
all: build build-worker
-tap-models:
- chmod +x ./scripts/singer-model-generator.sh
- @sh scripts/singer-model-generator.sh resources/tap/pagerduty.json plugins/pagerduty --all
-
run:
go run server/main.go
diff --git a/backend/core/config/config_viper.go b/backend/core/config/config_viper.go
index d718506e1..80d1dd85d 100644
--- a/backend/core/config/config_viper.go
+++ b/backend/core/config/config_viper.go
@@ -103,7 +103,6 @@ func setDefaultValue(v *viper.Viper) {
v.SetDefault("PORT", "8080")
v.SetDefault("PLUGIN_DIR", "bin/plugins")
v.SetDefault("TEMPORAL_TASK_QUEUE", "DEVLAKE_TASK_QUEUE")
- v.SetDefault("TAP_PROPERTIES_DIR", "resources/tap")
v.SetDefault("REMOTE_PLUGIN_DIR", "python/plugins")
v.SetDefault("SWAGGER_DOCS_DIR", "resources/swagger")
}
diff --git a/backend/plugins/pagerduty/models/consts.go b/backend/core/models/migrationscripts/20230822_drop_tap_state.go
similarity index 56%
rename from backend/plugins/pagerduty/models/consts.go
rename to backend/core/models/migrationscripts/20230822_drop_tap_state.go
index 2d2c658c5..55d953719 100644
--- a/backend/plugins/pagerduty/models/consts.go
+++ b/backend/core/models/migrationscripts/20230822_drop_tap_state.go
@@ -15,11 +15,26 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package models
+package migrationscripts
-// The consts that this plugin needs
-const (
- TapExecutable = "tap-pagerduty"
- StreamPropertiesFile = "pagerduty.json"
- IncidentStream = "incidents"
+import (
+ "github.com/apache/incubator-devlake/core/context"
+ "github.com/apache/incubator-devlake/core/errors"
+ "github.com/apache/incubator-devlake/core/plugin"
)
+
+var _ plugin.MigrationScript = (*dropTapStateTable)(nil)
+
+type dropTapStateTable struct{}
+
+func (script *dropTapStateTable) Up(basicRes context.BasicRes) errors.Error {
+ return basicRes.GetDal().DropTables("_devlake_collector_tap_state")
+}
+
+func (*dropTapStateTable) Version() uint64 {
+ return 20230822145125
+}
+
+func (*dropTapStateTable) Name() string {
+ return "drop _devlake_collector_tap_state table"
+}
diff --git a/backend/core/models/migrationscripts/register.go b/backend/core/models/migrationscripts/register.go
index a7e325ca8..eee037c60 100644
--- a/backend/core/models/migrationscripts/register.go
+++ b/backend/core/models/migrationscripts/register.go
@@ -90,5 +90,6 @@ func All() []plugin.MigrationScript {
new(addIssueRelationship),
new(tasksUsesJSON),
new(modifyCicdPipelinesToText),
+ new(dropTapStateTable),
}
}
diff --git a/backend/scripts/singer-model-generator.sh b/backend/scripts/singer-model-generator.sh
deleted file mode 100644
index f5d91938c..000000000
--- a/backend/scripts/singer-model-generator.sh
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/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.
-#
-
-#===================================== constants =======================================
-
-time_format='
- {
- "type": "time.Time",
- "imports": ["time"]
- }
-'
-
-#===================================== functions =======================================
-
-json_path=$1 # e.g. "./config/singer/github.json"
-plugin_path=$2 # e.g. "./plugins/github_singer"
-tap_stream=$3 # e.g. "issues" or "--all" to generate all streams
-
-print_json() {
- jq -r < "$1" # for debugging
-}
-
-handle_error() {
- exitcode=$1
- if [ "$exitcode" != 0 ]; then
- exit "$exitcode"
- fi
-}
-
-generate() {
- tap_stream=$1
- package="generated"
- file_name="$tap_stream".go
- output_path="$plugin_path/models/generated/$file_name"
- tmp_dir=$(mktemp -d -t schema-XXXXX)
- json_schema_path="$tmp_dir"/"$tap_stream"
- # add, as necessary, more elif blocks for additional transformations
- modified_schema=$(jq --argjson tf "$time_format" '
- .streams[] |
- select(.stream=="'"$tap_stream"'").schema |
- . += { "$schema": "http://json-schema.org/draft-07/schema#" } |
- walk(
- if type == "object" and .format == "date-time" then
- . += { "goJSONSchema": ($tf) }
- elif "place_holder" == "" then
- empty
- else . end
- )
- ' < "$json_path")
- handle_error $?
- # additional cleanup
- modified_schema=$(echo "$modified_schema" | sed -r "/\"null\",/d")
- modified_schema=$(echo "$modified_schema" | sed -r "/.*additionalProperties.*/d")
- echo "$modified_schema" > "$json_schema_path" &&\
- gojsonschema -v -p "$package" "$json_schema_path" -o "$output_path"
- handle_error $?
- echo "$output_path"
- # prepend the license text to the generated files
- cp "$output_path" "$output_path".bak
- license_header="$(printf "/*\n%s\n*/\n" "$(cat .golangci-goheader.template)")"
- echo "$license_header" > "$output_path"
- cat "$output_path".bak >> "$output_path"
- rm "$output_path".bak
-}
-
-#======================================================================================
-
-if [ $# != 3 ]; then
- printf "not enough args. Usage: <json_path> <tap_stream> <output_path>: e.g.\n \"./config/singer/github.json\" \"issues\" \"./plugins/github_singer\"\n"
- exit 1
-fi
-
-if [ "$tap_stream" = "--all" ]; then
- for stream in $(jq -r '.streams[].stream' < "$json_path"); do
- generate "$stream"
- handle_error $?
- done
-else
- generate "$tap_stream"
- handle_error $?
-fi
-