Skip to content

Commit cafb477

Browse files
committed
Merge remote-tracking branch 'upstream/master' into otel-client
2 parents 809b498 + 2028da4 commit cafb477

24 files changed

+309
-98
lines changed

.github/workflows/ci.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ jobs:
2323
- mac
2424
- windows
2525
go:
26-
- '1.21'
2726
- '1.22'
27+
- '1.23'
2828

2929
include:
3030
# Set the minimum Go patch version for the given Go minor
3131
# Usable via ${{ matrix.GO_SEMVER }}
32-
- go: '1.21'
33-
GO_SEMVER: '~1.21.0'
34-
3532
- go: '1.22'
3633
GO_SEMVER: '~1.22.3'
3734

35+
- go: '1.23'
36+
GO_SEMVER: '~1.23.0'
37+
3838
# Set some variables per OS, usable via ${{ matrix.VAR }}
3939
# OS_LABEL: the VM label from GitHub Actions (see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories)
4040
# CADDY_BIN_PATH: the path to the compiled Caddy binary, for artifact publishing
@@ -150,6 +150,7 @@ jobs:
150150
uses: actions/checkout@v4
151151
- name: Run Tests
152152
run: |
153+
set +e
153154
mkdir -p ~/.ssh && echo -e "${SSH_KEY//_/\\n}" > ~/.ssh/id_ecdsa && chmod og-rwx ~/.ssh/id_ecdsa
154155
155156
# short sha is enough?

.github/workflows/cross-build.yml

+4
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ jobs:
2828
- 'netbsd'
2929
go:
3030
- '1.22'
31+
- '1.23'
3132

3233
include:
3334
# Set the minimum Go patch version for the given Go minor
3435
# Usable via ${{ matrix.GO_SEMVER }}
3536
- go: '1.22'
3637
GO_SEMVER: '~1.22.3'
3738

39+
- go: '1.23'
40+
GO_SEMVER: '~1.23.0'
41+
3842
runs-on: ubuntu-latest
3943
continue-on-error: true
4044
steps:

.github/workflows/lint.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ jobs:
4343
- uses: actions/checkout@v4
4444
- uses: actions/setup-go@v5
4545
with:
46-
go-version: '~1.22.3'
46+
go-version: '~1.23'
4747
check-latest: true
4848

4949
- name: golangci-lint
5050
uses: golangci/golangci-lint-action@v6
5151
with:
52-
version: v1.55
52+
version: v1.60
5353

5454
# Windows times out frequently after about 5m50s if we don't set a longer timeout.
5555
args: --timeout 10m
@@ -63,5 +63,5 @@ jobs:
6363
- name: govulncheck
6464
uses: golang/govulncheck-action@v1
6565
with:
66-
go-version-input: '~1.22.3'
66+
go-version-input: '~1.23.0'
6767
check-latest: true

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ jobs:
1313
os:
1414
- ubuntu-latest
1515
go:
16-
- '1.22'
16+
- '1.23'
1717

1818
include:
1919
# Set the minimum Go patch version for the given Go minor
2020
# Usable via ${{ matrix.GO_SEMVER }}
21-
- go: '1.22'
22-
GO_SEMVER: '~1.22.3'
21+
- go: '1.23'
22+
GO_SEMVER: '~1.23.0'
2323

2424
runs-on: ${{ matrix.os }}
2525
# https://github.com/sigstore/cosign/issues/1258#issuecomment-1002251233

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ See [our online documentation](https://caddyserver.com/docs/install) for other i
8787

8888
Requirements:
8989

90-
- [Go 1.21 or newer](https://golang.org/dl/)
90+
- [Go 1.22.3 or newer](https://golang.org/dl/)
9191

9292
### For development
9393

caddyconfig/caddyfile/dispenser.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ func (d *Dispenser) EOFErr() error {
415415

416416
// Err generates a custom parse-time error with a message of msg.
417417
func (d *Dispenser) Err(msg string) error {
418-
return d.Errf(msg)
418+
return d.WrapErr(errors.New(msg))
419419
}
420420

421421
// Errf is like Err, but for formatted error messages

caddytest/caddytest_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ func TestLoadUnorderedJSON(t *testing.T) {
8484
"servers": {
8585
"s_server": {
8686
"listen": [
87-
":9443",
8887
":9080"
8988
],
9089
"routes": [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
:8884
2+
3+
reverse_proxy 127.0.0.1:65535 {
4+
health_uri /health
5+
health_request_body "test body"
6+
}
7+
----------
8+
{
9+
"apps": {
10+
"http": {
11+
"servers": {
12+
"srv0": {
13+
"listen": [
14+
":8884"
15+
],
16+
"routes": [
17+
{
18+
"handle": [
19+
{
20+
"handler": "reverse_proxy",
21+
"health_checks": {
22+
"active": {
23+
"body": "test body",
24+
"uri": "/health"
25+
}
26+
},
27+
"upstreams": [
28+
{
29+
"dial": "127.0.0.1:65535"
30+
}
31+
]
32+
}
33+
]
34+
}
35+
]
36+
}
37+
}
38+
}
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
https://example.com {
2+
reverse_proxy http://localhost:54321 {
3+
transport http {
4+
local_address 192.168.0.1
5+
}
6+
}
7+
}
8+
9+
----------
10+
{
11+
"apps": {
12+
"http": {
13+
"servers": {
14+
"srv0": {
15+
"listen": [
16+
":443"
17+
],
18+
"routes": [
19+
{
20+
"match": [
21+
{
22+
"host": [
23+
"example.com"
24+
]
25+
}
26+
],
27+
"handle": [
28+
{
29+
"handler": "subroute",
30+
"routes": [
31+
{
32+
"handle": [
33+
{
34+
"handler": "reverse_proxy",
35+
"transport": {
36+
"local_address": "192.168.0.1",
37+
"protocol": "http"
38+
},
39+
"upstreams": [
40+
{
41+
"dial": "localhost:54321"
42+
}
43+
]
44+
}
45+
]
46+
}
47+
]
48+
}
49+
],
50+
"terminal": true
51+
}
52+
]
53+
}
54+
}
55+
}
56+
}
57+
}

cmd/cobra.go

+15-11
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import (
88
"github.com/caddyserver/caddy/v2"
99
)
1010

11-
var rootCmd = &cobra.Command{
12-
Use: "caddy",
13-
Long: `Caddy is an extensible server platform written in Go.
11+
var defaultFactory = newRootCommandFactory(func() *cobra.Command {
12+
return &cobra.Command{
13+
Use: "caddy",
14+
Long: `Caddy is an extensible server platform written in Go.
1415
1516
At its core, Caddy merely manages configuration. Modules are plugged
1617
in statically at compile-time to provide useful functionality. Caddy's
@@ -91,23 +92,26 @@ package installers: https://caddyserver.com/docs/install
9192
Instructions for running Caddy in production are also available:
9293
https://caddyserver.com/docs/running
9394
`,
94-
Example: ` $ caddy run
95+
Example: ` $ caddy run
9596
$ caddy run --config caddy.json
9697
$ caddy reload --config caddy.json
9798
$ caddy stop`,
9899

99-
// kind of annoying to have all the help text printed out if
100-
// caddy has an error provisioning its modules, for instance...
101-
SilenceUsage: true,
102-
Version: onlyVersionText(),
103-
}
100+
// kind of annoying to have all the help text printed out if
101+
// caddy has an error provisioning its modules, for instance...
102+
SilenceUsage: true,
103+
Version: onlyVersionText(),
104+
}
105+
})
104106

105107
const fullDocsFooter = `Full documentation is available at:
106108
https://caddyserver.com/docs/command-line`
107109

108110
func init() {
109-
rootCmd.SetVersionTemplate("{{.Version}}\n")
110-
rootCmd.SetHelpTemplate(rootCmd.HelpTemplate() + "\n" + fullDocsFooter + "\n")
111+
defaultFactory.Use(func(rootCmd *cobra.Command) {
112+
rootCmd.SetVersionTemplate("{{.Version}}\n")
113+
rootCmd.SetHelpTemplate(rootCmd.HelpTemplate() + "\n" + fullDocsFooter + "\n")
114+
})
111115
}
112116

113117
func onlyVersionText() string {

cmd/commandfactory.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package caddycmd
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
type rootCommandFactory struct {
8+
constructor func() *cobra.Command
9+
options []func(*cobra.Command)
10+
}
11+
12+
func newRootCommandFactory(fn func() *cobra.Command) *rootCommandFactory {
13+
return &rootCommandFactory{
14+
constructor: fn,
15+
}
16+
}
17+
18+
func (f *rootCommandFactory) Use(fn func(cmd *cobra.Command)) {
19+
f.options = append(f.options, fn)
20+
}
21+
22+
func (f *rootCommandFactory) Build() *cobra.Command {
23+
o := f.constructor()
24+
for _, v := range f.options {
25+
v(o)
26+
}
27+
return o
28+
}

cmd/commandfuncs.go

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ func cmdStart(fl Flags) (int, error) {
7474
// sure by giving it some random bytes and having it echo
7575
// them back to us)
7676
cmd := exec.Command(os.Args[0], "run", "--pingback", ln.Addr().String())
77+
// we should be able to run caddy in relative paths
78+
if errors.Is(cmd.Err, exec.ErrDot) {
79+
cmd.Err = nil
80+
}
7781
if configFlag != "" {
7882
cmd.Args = append(cmd.Args, "--config", configFlag)
7983
}

0 commit comments

Comments
 (0)