Skip to content

Improve code #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ jobs:
install-mode: "goinstall"

- name: Run tests 🧪
run: make test
run: go test -p 1 -cover -covermode atomic -coverprofile=profile.cov -v ./...

# Uncomment the following lines to upload the coverage report to Coveralls
# - name: Upload coverage report 📈
# uses: shogo82148/actions-goveralls@v1
# with:
# path-to-profile: profile.cov
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ Running the above command causes the `go mod tidy` and `go build` to run for com
## Sentry

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. -->

## Contributing

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).

## License

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).
1 change: 0 additions & 1 deletion gatewayd_plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ reloadOnCrash: True
timeout: 30s

plugins:
# Plugin name
- name: gatewayd-plugin-sql-ids-ips
# whether to enable or disable the plugin on the next run
enabled: True
Expand Down
9 changes: 1 addition & 8 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const (
ResponseField string = "response"
OutputsField string = "outputs"
TokensField string = "tokens"
RequestField string = "request"
StringField string = "String"

DeepLearningModel string = "deep_learning_model"
Expand Down Expand Up @@ -102,13 +101,7 @@ func (p *Plugin) OnTrafficFromClient(ctx context.Context, req *v1.Struct) (*v1.S
req, err := postgres.HandleClientMessage(req, p.Logger)
if err != nil {
p.Logger.Debug("Failed to handle client message", ErrorField, err)
return req, err
}

// Get the client request from the GatewayD request.
request := cast.ToString(sdkPlugin.GetAttr(req, RequestField, ""))
if request == "" {
return req, nil
return req, err
}

// Get the query from the request.
Expand Down
3 changes: 0 additions & 3 deletions plugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func Test_OnTrafficFromClinet(t *testing.T) {

server := httptest.NewServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.Path)
switch r.URL.Path {
case TokenizeAndSequencePath:
w.WriteHeader(http.StatusOK)
Expand Down Expand Up @@ -156,7 +155,6 @@ func Test_OnTrafficFromClinetFailedTokenization(t *testing.T) {

server := httptest.NewServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.Path)
switch r.URL.Path {
case TokenizeAndSequencePath:
w.WriteHeader(http.StatusInternalServerError)
Expand Down Expand Up @@ -228,7 +226,6 @@ func Test_OnTrafficFromClinetFailedPrediction(t *testing.T) {

server := httptest.NewServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.Path)
switch r.URL.Path {
case TokenizeAndSequencePath:
w.WriteHeader(http.StatusOK)
Expand Down