Skip to content
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

Prevent main Caddy module from upgrading from adding a plugin #93

Merged
merged 2 commits into from
Apr 7, 2022

Conversation

francislavoie
Copy link
Member

Fixes #54

For example:

$ xcaddy build v2.3.0 --with github.com/caddy-dns/cloudflare
...
2022/04/06 01:54:25 [INFO] Initializing Go module
2022/04/06 01:54:25 [INFO] exec (timeout=10s): go mod init caddy
2022/04/06 01:54:26 [INFO] Pinning versions
2022/04/06 01:54:26 [INFO] exec (timeout=0s): go get -d -v github.com/caddyserver/caddy/v2@v2.3.0
...

2022/04/06 01:54:27 [INFO] exec (timeout=0s): go get -d -v github.com/caddy-dns/cloudflare github.com/caddyserver/caddy/v2@v2.3.0
go: github.com/caddy-dns/cloudflare@upgrade (v0.0.0-20210607183747-91cf700356a1) requires github.com/caddyserver/caddy/v2@v2.4.0, not github.com/caddyserver/caddy/v2@v2.3.0
2022/04/06 01:54:28 [FATAL] exit status 1

The key being that the go get to add the cloudflare plugin also specifies the Caddy module, which puts a constraint that the Caddy module should not upgrade past that version from pulling in the plugin.

This means that some builds that would have previously worked might fail now, but I think this is least-surprise, because it's weird that if you specify a version of Caddy that it would get upgraded higher because of a plugin.

This can be solved by specifying a version of the plugin that does build with the older version of Caddy specified:

$ xcaddy build v2.3.0 --with github.com/caddy-dns/cloudflare@eda8e5aa22232e9c279b0df7531f20c331b331c6
...
2022/04/06 02:12:26 [INFO] Initializing Go module
2022/04/06 02:12:26 [INFO] exec (timeout=10s): go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2022/04/06 02:12:26 [INFO] Pinning versions
2022/04/06 02:12:26 [INFO] exec (timeout=0s): go get -d -v github.com/caddyserver/caddy/v2@v2.3.0
...

2022/04/06 02:12:27 [INFO] exec (timeout=0s): go get -d -v github.com/caddy-dns/cloudflare@eda8e5aa22232e9c279b0df7531f20c331b331c6 github.com/caddyserver/caddy/v2@v2.3.0
go: added github.com/caddy-dns/cloudflare v0.0.0-20210105070211-eda8e5aa2223
go: added github.com/libdns/cloudflare v0.0.0-20200528144945-97886e7873b1
2022/04/06 02:12:29 [INFO] exec (timeout=0s): go get -d -v
2022/04/06 02:12:31 [INFO] Build environment ready
2022/04/06 02:12:31 [INFO] Building Caddy
2022/04/06 02:12:31 [INFO] exec (timeout=0s): go mod tidy
2022/04/06 02:12:31 [INFO] exec (timeout=0s): go build -o ./caddy -ldflags -w -s -trimpath
2022/04/06 02:12:34 [INFO] Build complete: ./caddy

environment.go Outdated Show resolved Hide resolved
environment.go Outdated Show resolved Hide resolved
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's clever (and unfortunate, oh well) -- thanks for the patch!

I think this looks good, except maybe we need a link to this PR or the related issue (#54) for future readers/maintainers.

environment.go Show resolved Hide resolved
@mholt mholt merged commit 71ce25d into caddyserver:master Apr 7, 2022
@mholt
Copy link
Member

mholt commented Apr 7, 2022

Thanks for the efforts into investigating this. As unfortunate as the situation is, the fix seems good.

@francislavoie francislavoie deleted the prevent-upgrade branch April 7, 2022 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xcaddy doesn't build specified version
3 participants