Skip to content

Commit

Permalink
fix: Traefik does not allow go modules; use structure impose by GOPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
ducdetronquito committed Jul 28, 2023
1 parent 8967c57 commit fc8d0b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/i
# Install Yaegi (go interpreter used by Traefik)
RUN curl -sfL https://raw.githubusercontent.com/traefik/yaegi/master/install.sh | bash -s -- -b $(go env GOPATH)/bin ${YAEGI_VERSION}

WORKDIR /home/traefik_request_id
WORKDIR /go/src/github.com/ZeroGachis/traefik-request-id

COPY ./ ./

RUN \
go env -w GOPATH=/home/traefik_request_id/go && \
go env -w GOPATH=/go && \
go mod tidy && \
go mod download && \
go mod vendor
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ services:
build:
context: .
tty: true
working_dir: /home/traefik_request_id
working_dir: /go/src/github.com/ZeroGachis/traefik-request-id
volumes:
- .:/home/traefik_request_id
- .:/go/src/github.com/ZeroGachis/traefik-request-id
12 changes: 7 additions & 5 deletions requestid_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package requestid
package requestid_test

import (
"context"
"net/http"
"net/http/httptest"
"testing"

plugin "github.com/ZeroGachis/traefik-request-id"
)

func TestAddRequestIdInHeaderIfNoneExist(t *testing.T) {
cfg := CreateConfig()
cfg := plugin.CreateConfig()

ctx := context.Background()
next := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {})

handler, err := New(ctx, next, cfg, "sw-request-id-plugin")
handler, err := plugin.New(ctx, next, cfg, "sw-request-id-plugin")
if err != nil {
t.Fatal(err)
}
Expand All @@ -34,12 +36,12 @@ func TestAddRequestIdInHeaderIfNoneExist(t *testing.T) {
}

func TestKeepRequestIdInHeaderIfOneExist(t *testing.T) {
cfg := CreateConfig()
cfg := plugin.CreateConfig()

ctx := context.Background()
next := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {})

handler, err := New(ctx, next, cfg, "sw-request-id-plugin")
handler, err := plugin.New(ctx, next, cfg, "sw-request-id-plugin")
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit fc8d0b2

Please sign in to comment.