darkweak / souin

An HTTP cache system, RFC compliant, compatible with @tyktechnologies, @traefik, @caddyserver, @go-chi, @bnkamalesh, @beego, @devfeel, @labstack, @gofiber, @go-goyave, @go-kratos, @gin-gonic, @roadrunner-server, @zalando, @zeromicro, @nginx and @apache
https://docs.souin.io
MIT License
683 stars 51 forks source link

Caddy plugin does not build #512

Closed ueffel closed 3 months ago

ueffel commented 4 months ago

I'm getting build errors with the current (d3992886c4dc) version of the caddy plugin. I trying to build with xcaddy:

$ xcaddy build --with github.com/darkweak/souin/plugins/caddy

Errors:

github.com\darkweak\souin\plugins\caddy@v0.0.0-20240423070913-d3992886c4dc\configuration.go:384:11: ck.DisableScheme undefined (type configurationtypes.Key has no field or method DisableScheme)
github.com\darkweak\souin\plugins\caddy@v0.0.0-20240423070913-d3992886c4dc\configuration.go:386:11: ck.Hash undefined (type configurationtypes.Key has no field or method Hash)
github.com\darkweak\souin\plugins\caddy@v0.0.0-20240423070913-d3992886c4dc\configuration.go:470:18: config_key.DisableScheme undefined (type configurationtypes.Key has no field or method DisableScheme)
github.com\darkweak\souin\plugins\caddy@v0.0.0-20240423070913-d3992886c4dc\configuration.go:472:18: config_key.Hash undefined (type configurationtypes.Key has no field or method Hash)
github.com\darkweak\souin\plugins\caddy@v0.0.0-20240423070913-d3992886c4dc\httpcache.go:192:108: dc.Key.DisableScheme undefined (type configurationtypes.Key has no field or method DisableScheme)
github.com\darkweak\souin\plugins\caddy@v0.0.0-20240423070913-d3992886c4dc\httpcache.go:192:133: dc.Key.Hash undefined (type configurationtypes.Key has no field or method Hash)

The previous commit (ddc269daafa99c551913344137e9590b721e7dd5) does build successfully.

$ xcaddy build --with github.com/darkweak/souin/plugins/caddy@ddc269daafa99c551913344137e9590b721e7dd5
complete build log from xcaddy ```sh $ xcaddy build --with github.com/darkweak/souin/plugins/caddy 2024/05/01 11:39:02 [INFO] absolute output file path: R:\tmp\caddy.exe 2024/05/01 11:39:02 [INFO] Temporary folder: r:\temp\buildenv_2024-05-01-1139.3123807730 2024/05/01 11:39:02 [INFO] Writing main module: r:\temp\buildenv_2024-05-01-1139.3123807730\main.go package main import ( caddycmd "github.com/caddyserver/caddy/v2/cmd" // plug in Caddy modules here _ "github.com/caddyserver/caddy/v2/modules/standard" _ "github.com/darkweak/souin/plugins/caddy" ) func main() { caddycmd.Main() } 2024/05/01 11:39:02 [INFO] Initializing Go module 2024/05/01 11:39:02 [INFO] exec (timeout=0s): C:\go\bin\go.exe mod init caddy go: creating new go.mod: module caddy go: to add module requirements and sums: go mod tidy 2024/05/01 11:39:02 [INFO] Pinning versions 2024/05/01 11:39:02 [INFO] exec (timeout=0s): C:\go\bin\go.exe get -d -v -tags nobadger github.com/caddyserver/caddy/v2 go: added github.com/beorn7/perks v1.0.1 go: added github.com/caddyserver/caddy/v2 v2.7.6 go: added github.com/caddyserver/certmagic v0.20.0 go: added github.com/cespare/xxhash/v2 v2.2.0 go: added github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 go: added github.com/golang/protobuf v1.5.3 go: added github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 go: added github.com/google/uuid v1.3.1 go: added github.com/klauspost/cpuid/v2 v2.2.5 go: added github.com/libdns/libdns v0.2.1 go: added github.com/matttproud/golang_protobuf_extensions v1.0.4 go: added github.com/mholt/acmez v1.2.0 go: added github.com/miekg/dns v1.1.55 go: added github.com/onsi/ginkgo/v2 v2.9.5 go: added github.com/prometheus/client_golang v1.15.1 go: added github.com/prometheus/client_model v0.4.0 go: added github.com/prometheus/common v0.42.0 go: added github.com/prometheus/procfs v0.9.0 go: added github.com/quic-go/qpack v0.4.0 go: added github.com/quic-go/qtls-go1-20 v0.4.1 go: added github.com/quic-go/quic-go v0.40.0 go: added github.com/zeebo/blake3 v0.2.3 go: added go.uber.org/mock v0.3.0 go: added go.uber.org/multierr v1.11.0 go: added go.uber.org/zap v1.25.0 go: added golang.org/x/crypto v0.14.0 go: added golang.org/x/exp v0.0.0-20230310171629-522b1b587ee0 go: added golang.org/x/mod v0.11.0 go: added golang.org/x/net v0.17.0 go: added golang.org/x/sys v0.14.0 go: added golang.org/x/term v0.13.0 go: added golang.org/x/text v0.13.0 go: added golang.org/x/tools v0.10.0 go: added google.golang.org/protobuf v1.31.0 2024/05/01 11:39:03 [INFO] exec (timeout=0s): C:\go\bin\go.exe get -d -v -tags nobadger github.com/darkweak/souin/plugins/caddy github.com/caddyserver/caddy/v2 go: accepting indirect upgrade from github.com/google/pprof@v0.0.0-20210720184732-4bb14d4b1be1 to v0.0.0-20230207041349-798e818bf904 go: accepting indirect upgrade from github.com/onsi/ginkgo/v2@v2.9.5 to v2.12.1 go: accepting indirect upgrade from github.com/prometheus/client_golang@v1.15.1 to v1.16.0 go: accepting indirect upgrade from github.com/prometheus/procfs@v0.9.0 to v0.10.1 go: accepting indirect upgrade from go.uber.org/zap@v1.25.0 to v1.26.0 go: accepting indirect upgrade from golang.org/x/crypto@v0.14.0 to v0.16.0 go: accepting indirect upgrade from golang.org/x/exp@v0.0.0-20230310171629-522b1b587ee0 to v0.0.0-20231127185646-65229373498e go: accepting indirect upgrade from golang.org/x/mod@v0.11.0 to v0.14.0 go: accepting indirect upgrade from golang.org/x/net@v0.17.0 to v0.19.0 go: accepting indirect upgrade from golang.org/x/sys@v0.14.0 to v0.17.0 go: accepting indirect upgrade from golang.org/x/term@v0.13.0 to v0.15.0 go: accepting indirect upgrade from golang.org/x/text@v0.13.0 to v0.14.0 go: accepting indirect upgrade from golang.org/x/tools@v0.10.0 to v0.16.0 go: added github.com/RoaringBitmap/roaring v1.2.3 go: added github.com/antlabs/stl v0.0.1 go: added github.com/antlabs/timer v0.0.11 go: added github.com/armon/go-metrics v0.4.1 go: added github.com/bits-and-blooms/bitset v1.5.0 go: added github.com/buraksezer/consistent v0.10.0 go: added github.com/buraksezer/olric v0.5.4 go: added github.com/bwmarrin/snowflake v0.3.0 go: added github.com/coreos/go-semver v0.3.1 go: added github.com/coreos/go-systemd/v22 v22.5.0 go: added github.com/darkweak/go-esi v0.0.5 go: added github.com/darkweak/souin v1.6.47 go: added github.com/darkweak/souin/plugins/caddy v0.0.0-20240423070913-d3992886c4dc go: added github.com/dgraph-io/badger/v3 v3.2103.5 go: upgraded github.com/dgraph-io/ristretto v0.1.0 => v0.1.1 go: added github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f go: added github.com/go-redis/redis/v8 v8.11.5 go: added github.com/gofrs/flock v0.8.1 go: added github.com/gogo/protobuf v1.3.2 go: added github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da go: added github.com/google/btree v1.1.2 go: added github.com/google/flatbuffers v23.1.21+incompatible go: upgraded github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 => v0.0.0-20230207041349-798e818bf904 go: added github.com/hashicorp/errwrap v1.1.0 go: added github.com/hashicorp/go-immutable-radix v1.3.1 go: added github.com/hashicorp/go-msgpack v0.5.5 go: added github.com/hashicorp/go-multierror v1.1.1 go: added github.com/hashicorp/go-sockaddr v1.0.2 go: added github.com/hashicorp/golang-lru v0.5.5-0.20200511160909-eb529947af53 go: added github.com/hashicorp/logutils v1.0.0 go: added github.com/hashicorp/memberlist v0.5.0 go: upgraded github.com/imdario/mergo v0.3.12 => v0.3.13 go: added github.com/mschoch/smat v0.2.0 go: added github.com/nutsdb/nutsdb v0.14.3 go: upgraded github.com/onsi/ginkgo/v2 v2.9.5 => v2.12.1 go: added github.com/pquerna/cachecontrol v0.2.0 go: upgraded github.com/prometheus/client_golang v1.15.1 => v1.16.0 go: upgraded github.com/prometheus/procfs v0.9.0 => v0.10.1 go: added github.com/redis/rueidis v1.0.31 go: added github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 go: added github.com/tidwall/btree v1.6.0 go: added github.com/tidwall/match v1.1.1 go: added github.com/tidwall/redcon v1.6.2 go: added github.com/vmihailenco/msgpack/v5 v5.3.5 go: added github.com/vmihailenco/tagparser/v2 v2.0.0 go: added github.com/xujiajun/mmap-go v1.0.1 go: added github.com/xujiajun/utils v0.0.0-20220904132955-5f7c5b914235 go: added go.etcd.io/etcd/api/v3 v3.5.12 go: added go.etcd.io/etcd/client/pkg/v3 v3.5.12 go: added go.etcd.io/etcd/client/v3 v3.5.12 go: added go.opencensus.io v0.24.0 go: upgraded go.uber.org/zap v1.25.0 => v1.26.0 go: upgraded golang.org/x/crypto v0.14.0 => v0.16.0 go: upgraded golang.org/x/exp v0.0.0-20230310171629-522b1b587ee0 => v0.0.0-20231127185646-65229373498e go: upgraded golang.org/x/mod v0.11.0 => v0.14.0 go: upgraded golang.org/x/net v0.17.0 => v0.19.0 go: upgraded golang.org/x/sync v0.4.0 => v0.5.0 go: upgraded golang.org/x/sys v0.14.0 => v0.17.0 go: upgraded golang.org/x/term v0.13.0 => v0.15.0 go: upgraded golang.org/x/text v0.13.0 => v0.14.0 go: upgraded golang.org/x/tools v0.10.0 => v0.16.0 go: added google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a 2024/05/01 11:39:05 [INFO] exec (timeout=0s): C:\go\bin\go.exe get -d -v -tags nobadger go: downloading github.com/alecthomas/chroma/v2 v2.9.1 go: downloading github.com/yuin/goldmark v1.5.6 2024/05/01 11:39:07 [INFO] Build environment ready 2024/05/01 11:39:07 [INFO] Building Caddy 2024/05/01 11:39:08 [INFO] exec (timeout=0s): C:\go\bin\go.exe mod tidy -e go: downloading gopkg.in/go-playground/assert.v1 v1.2.1 go: downloading github.com/hashicorp/go-uuid v1.0.1 go: downloading github.com/go-stack/stack v1.8.0 2024/05/01 11:39:09 [INFO] exec (timeout=0s): C:\go\bin\go.exe build -o R:\tmp\caddy.exe -tags nobadger # github.com/darkweak/souin/plugins/caddy C:\gomodcache\github.com\darkweak\souin\plugins\caddy@v0.0.0-20240423070913-d3992886c4dc\configuration.go:384:11: ck.DisableScheme undefined (type configurationtypes.Key has no field or method DisableScheme) C:\gomodcache\github.com\darkweak\souin\plugins\caddy@v0.0.0-20240423070913-d3992886c4dc\configuration.go:386:11: ck.Hash undefined (type configurationtypes.Key has no field or method Hash) C:\gomodcache\github.com\darkweak\souin\plugins\caddy@v0.0.0-20240423070913-d3992886c4dc\configuration.go:470:18: config_key.DisableScheme undefined (type configurationtypes.Key has no field or method DisableScheme) C:\gomodcache\github.com\darkweak\souin\plugins\caddy@v0.0.0-20240423070913-d3992886c4dc\configuration.go:472:18: config_key.Hash undefined (type configurationtypes.Key has no field or method Hash) C:\gomodcache\github.com\darkweak\souin\plugins\caddy@v0.0.0-20240423070913-d3992886c4dc\httpcache.go:192:108: dc.Key.DisableScheme undefined (type configurationtypes.Key has no field or method DisableScheme) C:\gomodcache\github.com\darkweak\souin\plugins\caddy@v0.0.0-20240423070913-d3992886c4dc\httpcache.go:192:133: dc.Key.Hash undefined (type configurationtypes.Key has no field or method Hash) 2024/05/01 11:39:19 [INFO] Cleaning up temporary folder: r:\temp\buildenv_2024-05-01-1139.3123807730 2024/05/01 11:39:19 [FATAL] exit status 1 ```
adammakowskidev commented 4 months ago

I have the same problem. I reported it to @darkweak

darkweak commented 4 months ago

Hello, sorry for that. You can build it using xcaddy build --with github.com/darkweak/souin/plugins/caddy@d3992886c4dc227746a071e637e2b01b09b0e2a9 --with github.com/darkweak/souin@d3992886c4dc227746a071e637e2b01b09b0e2a9.

ueffel commented 4 months ago

Still does not build, see the build job: https://github.com/darkweak/souin/actions/runs/8796276967/job/24138843072

darkweak commented 4 months ago

The build job runs the following command: xcaddy build --with github.com/darkweak/souin/plugins/caddy@$(git rev-parse --short "$GITHUB_SHA") so it doesn't refer to the latest commit of the Souin repository and refers to the core v1.6.47.

With the command below you are able to build the caddy module xcaddy build --with github.com/darkweak/souin/plugins/caddy@d3992886c4dc227746a071e637e2b01b09b0e2a9 --with github.com/darkweak/souin@d3992886c4dc227746a071e637e2b01b09b0e2a9

darkweak commented 3 months ago

It should work now @ueffel

sharifm-informatica commented 1 month ago

It is not building again.

15:05:04 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/bin/caddy -ldflags -w -s -trimpath -tags nobadger 
183.8 # github.com/darkweak/souin/plugins/caddy
183.8 /go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20240717102502-b0a36db1b550/configuration.go:367:50: unknown field Found in struct literal of type configurationtypes.CacheProvider
183.8 /go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20240717102502-b0a36db1b550/configuration.go:464:50: unknown field Found in struct literal of type configurationtypes.CacheProvider
183.8 /go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20240717102502-b0a36db1b550/configuration.go:515:50: unknown field Found in struct literal of type configurationtypes.CacheProvider
183.8 /go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20240717102502-b0a36db1b550/configuration.go:530:50: unknown field Found in struct literal of type configurationtypes.CacheProvider
183.8 /go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20240717102502-b0a36db1b550/configuration.go:548:50: unknown field Found in struct literal of type configurationtypes.CacheProvider
183.8 /go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20240717102502-b0a36db1b550/configuration.go:561:50: unknown field Found in struct literal of type configurationtypes.CacheProvider
183.8 /go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20240717102502-b0a36db1b550/configuration.go:580:50: unknown field Found in struct literal of type configurationtypes.CacheProvider
183.8 /go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20240717102502-b0a36db1b550/dispatch.go:11:41: s.Configuration.DefaultCache.Badger.Found undefined (type configurationtypes.CacheProvider has no field or method Found)
183.8 /go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20240717102502-b0a36db1b550/dispatch.go:31:40: s.Configuration.DefaultCache.Badger.Uuid undefined (type configurationtypes.CacheProvider has no field or method Uuid)
183.8 /go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20240717102502-b0a36db1b550/dispatch.go:39:39: s.Configuration.DefaultCache.Etcd.Found undefined (type configurationtypes.CacheProvider has no field or method Found)
183.8 /go/pkg/mod/github.com/darkweak/souin/plugins/caddy@v0.0.0-20240717102502-b0a36db1b550/dispatch.go:39:39: too many errors

The Dockerfile used:

FROM caddy:2-builder-alpine AS builder

RUN xcaddy build --with github.com/darkweak/souin/plugins/caddy --with github.com/darkweak/storages/go-redis/caddy

FROM caddy:2-alpine

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

Does not build without the go-redis storage either. Also, tested the main caddy builder to confirm it is not specific to the Alpine version.

darkweak commented 1 month ago
xcaddy build --with github.com/darkweak/souin/plugins/caddy@b0a36db1b550b66f768a3793701b69358200fed3 --with github.com/darkweak/souin@b0a36db1b550b66f768a3793701b69358200fed3  --with github.com/darkweak/storages/go-redis/caddy

should build without any issues

sharifm-informatica commented 1 month ago

Would this be the normal way to build? Is there a better way? Should we reopen this issue till the build instructions succeed?