Skip to content

Commit 5940233

Browse files
authoredApr 8, 2024··
Improve code (#22)
* Fix formatting * Remove unnecessary code block * Remove unused const * Remove prints * Generate coverage report and badge * Remove coverage reporting * Add contribution guidelines and license notice * Remove obvious comment
1 parent a56141b commit 5940233

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed
 

‎.github/workflows/test.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,10 @@ jobs:
4747
install-mode: "goinstall"
4848

4949
- name: Run tests 🧪
50-
run: make test
50+
run: go test -p 1 -cover -covermode atomic -coverprofile=profile.cov -v ./...
51+
52+
# Uncomment the following lines to upload the coverage report to Coveralls
53+
# - name: Upload coverage report 📈
54+
# uses: shogo82148/actions-goveralls@v1
55+
# with:
56+
# path-to-profile: profile.cov

‎README.md

+8
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,11 @@ Running the above command causes the `go mod tidy` and `go build` to run for com
3232
## Sentry
3333
3434
This plugin uses [Sentry](https://sentry.io) for error tracking. Sentry can be configured using the `SENTRY_DSN` environment variable. If `SENTRY_DSN` is not set, Sentry will not be used. -->
35+
36+
## Contributing
37+
38+
We welcome contributions from everyone.<!-- Please read our [contributing guide](https://gatewayd-io.github.io/CONTIBUTING.md) for more details.--> Just open an [issue](https://github.com/gatewayd-io/gatewayd-plugin-sql-ids-ips/issues) or send us a [pull request](https://github.com/gatewayd-io/gatewayd-plugin-sql-ids-ips/pulls).
39+
40+
## License
41+
42+
This plugin is licensed under the [Affero General Public License v3.0](https://github.com/gatewayd-io/gatewayd-plugin-sql-ids-ips/blob/main/LICENSE).

‎gatewayd_plugin.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ reloadOnCrash: True
88
timeout: 30s
99

1010
plugins:
11-
# Plugin name
1211
- name: gatewayd-plugin-sql-ids-ips
1312
# whether to enable or disable the plugin on the next run
1413
enabled: True

‎plugin/plugin.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const (
2929
ResponseField string = "response"
3030
OutputsField string = "outputs"
3131
TokensField string = "tokens"
32-
RequestField string = "request"
3332
StringField string = "String"
3433

3534
DeepLearningModel string = "deep_learning_model"
@@ -102,13 +101,7 @@ func (p *Plugin) OnTrafficFromClient(ctx context.Context, req *v1.Struct) (*v1.S
102101
req, err := postgres.HandleClientMessage(req, p.Logger)
103102
if err != nil {
104103
p.Logger.Debug("Failed to handle client message", ErrorField, err)
105-
return req, err
106-
}
107-
108-
// Get the client request from the GatewayD request.
109-
request := cast.ToString(sdkPlugin.GetAttr(req, RequestField, ""))
110-
if request == "" {
111-
return req, nil
104+
return req, err
112105
}
113106

114107
// Get the query from the request.

‎plugin/plugin_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ func Test_OnTrafficFromClinet(t *testing.T) {
7878

7979
server := httptest.NewServer(
8080
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
81-
fmt.Println(r.URL.Path)
8281
switch r.URL.Path {
8382
case TokenizeAndSequencePath:
8483
w.WriteHeader(http.StatusOK)
@@ -156,7 +155,6 @@ func Test_OnTrafficFromClinetFailedTokenization(t *testing.T) {
156155

157156
server := httptest.NewServer(
158157
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
159-
fmt.Println(r.URL.Path)
160158
switch r.URL.Path {
161159
case TokenizeAndSequencePath:
162160
w.WriteHeader(http.StatusInternalServerError)
@@ -228,7 +226,6 @@ func Test_OnTrafficFromClinetFailedPrediction(t *testing.T) {
228226

229227
server := httptest.NewServer(
230228
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
231-
fmt.Println(r.URL.Path)
232229
switch r.URL.Path {
233230
case TokenizeAndSequencePath:
234231
w.WriteHeader(http.StatusOK)

0 commit comments

Comments
 (0)
Please sign in to comment.