Skip to content

Commit 4a3c6c1

Browse files
authored
upgrade caddy version to 2.4.1 (#42)
1 parent ad54c2d commit 4a3c6c1

File tree

9 files changed

+310
-465
lines changed

9 files changed

+310
-465
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ jobs:
1919
- name: set up go 1.x
2020
uses: actions/setup-go@v2
2121
with:
22-
go-version: '1.14.4'
22+
go-version: '1.16.4'
2323
id: go
2424

2525
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26-
- name: checkt out
26+
- name: checkt out
2727
uses: actions/checkout@v2
2828

2929
# Runs test
@@ -62,6 +62,3 @@ jobs:
6262
username: sillygod
6363
password: ${{ secrets.GITHUB_TOKEN }}
6464
tags: latest
65-
66-
67-

.github/workflows/pull_request.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ jobs:
1919
- name: set up go 1.x
2020
uses: actions/setup-go@v2
2121
with:
22-
go-version: '1.14.4'
22+
go-version: '1.16.4'
2323
id: go
2424

2525
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26-
- name: checkt out
26+
- name: checkt out
2727
uses: actions/checkout@v2
2828

2929
# Runs test
@@ -45,5 +45,3 @@ jobs:
4545
- name: build
4646
run: |
4747
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o caddy cmd/main.go
48-
49-

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: set up go 1.x
1515
uses: actions/setup-go@v2
1616
with:
17-
go-version: '1.14.4'
17+
go-version: '1.16.4'
1818
id: go
1919

2020
- name: checkout

cmd/Caddyfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
log {
2323
output file /tmp/logs/caddy/access.log
24-
format logfmt
24+
format console
2525
level debug
2626
}
2727

@@ -36,5 +36,3 @@
3636
level info
3737
}
3838
}
39-
40-

endpoint.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ func (c cachePurge) handleShowCache(w http.ResponseWriter, r *http.Request) erro
138138

139139
if r.Method != http.MethodGet {
140140
return caddy.APIError{
141-
Code: http.StatusMethodNotAllowed,
142-
Err: fmt.Errorf("method not allowed"),
141+
HTTPStatus: http.StatusMethodNotAllowed,
142+
Err: fmt.Errorf("method not allowed"),
143143
}
144144
}
145145

@@ -172,8 +172,8 @@ func (c cachePurge) handleListCacheKeys(w http.ResponseWriter, r *http.Request)
172172

173173
if r.Method != http.MethodGet {
174174
return caddy.APIError{
175-
Code: http.StatusMethodNotAllowed,
176-
Err: fmt.Errorf("method not allowed"),
175+
HTTPStatus: http.StatusMethodNotAllowed,
176+
Err: fmt.Errorf("method not allowed"),
177177
}
178178
}
179179

@@ -184,8 +184,8 @@ func (c cachePurge) handleListCacheKeys(w http.ResponseWriter, r *http.Request)
184184
err := json.NewEncoder(w).Encode(keys)
185185
if err != nil {
186186
return caddy.APIError{
187-
Code: http.StatusBadRequest,
188-
Err: err,
187+
HTTPStatus: http.StatusBadRequest,
188+
Err: err,
189189
}
190190
}
191191

@@ -196,8 +196,8 @@ func (c cachePurge) handleListCacheKeys(w http.ResponseWriter, r *http.Request)
196196
func (c cachePurge) handlePurge(w http.ResponseWriter, r *http.Request) error {
197197
if r.Method != http.MethodDelete {
198198
return caddy.APIError{
199-
Code: http.StatusMethodNotAllowed,
200-
Err: fmt.Errorf("method not allowed"),
199+
HTTPStatus: http.StatusMethodNotAllowed,
200+
Err: fmt.Errorf("method not allowed"),
201201
}
202202
}
203203

@@ -208,8 +208,8 @@ func (c cachePurge) handlePurge(w http.ResponseWriter, r *http.Request) error {
208208
_, err := io.Copy(buf, r.Body)
209209
if err != nil {
210210
return caddy.APIError{
211-
Code: http.StatusBadRequest,
212-
Err: fmt.Errorf("reading request body: %s", err.Error()),
211+
HTTPStatus: http.StatusBadRequest,
212+
Err: fmt.Errorf("reading request body: %s", err.Error()),
213213
}
214214
}
215215

endpoint_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type CacheEndpointTestSuite struct {
1717
suite.Suite
1818
caddyTester *caddytest.Tester
1919
url string
20+
admin_url string
2021
}
2122

2223
func (suite *CacheEndpointTestSuite) assertKeyNotIn(key string, keys []string, msgAndArgs ...interface{}) {
@@ -46,10 +47,10 @@ func (suite *CacheEndpointTestSuite) assertKeyIn(key string, keys []string, msgA
4647
func (suite *CacheEndpointTestSuite) SetupSuite() {
4748
suite.caddyTester = caddytest.NewTester(suite.T())
4849
suite.url = "http://localhost:9898/hello"
50+
suite.admin_url = "http://localhost:2019"
4951
suite.caddyTester.InitServer(`
5052
{
5153
order http_cache before reverse_proxy
52-
admin 0.0.0.0:7777
5354
}
5455
5556
:9898 {
@@ -68,9 +69,7 @@ func (suite *CacheEndpointTestSuite) SetupSuite() {
6869
respond /hello 200 {
6970
body "hope anything will be good"
7071
}
71-
}
72-
73-
`, "caddyfile")
72+
}`, "caddyfile")
7473
}
7574

7675
func (suite *CacheEndpointTestSuite) TestListCacheKeys() {
@@ -81,7 +80,7 @@ func (suite *CacheEndpointTestSuite) TestListCacheKeys() {
8180
suite.Assert().NoError(err)
8281
// create the cache first
8382

84-
r, err = http.NewRequest("GET", "http://localhost:7777/caches", nil)
83+
r, err = http.NewRequest("GET", suite.admin_url+"/caches", nil)
8584
suite.Assert().NoError(err)
8685

8786
res, err = suite.caddyTester.Client.Do(r)
@@ -95,7 +94,7 @@ func (suite *CacheEndpointTestSuite) TestListCacheKeys() {
9594
}
9695

9796
func (suite *CacheEndpointTestSuite) TestHealthCheck() {
98-
r, err := http.NewRequest("GET", "http://localhost:7777/health", nil)
97+
r, err := http.NewRequest("GET", suite.admin_url+"/health", nil)
9998
suite.Assert().NoError(err)
10099
_, err = suite.caddyTester.Client.Do(r)
101100
suite.Assert().NoError(err)
@@ -108,7 +107,7 @@ func (suite *CacheEndpointTestSuite) TestShowCache() {
108107
_, err = suite.caddyTester.Client.Do(r)
109108
suite.Assert().NoError(err)
110109
// create the cache first
111-
url := fmt.Sprintf("http://localhost:7777/caches/%s", url.PathEscape("GET localhost/hello?"))
110+
url := fmt.Sprintf("%s/caches/%s", suite.admin_url, url.PathEscape("GET localhost/hello?"))
112111

113112
r, err = http.NewRequest("GET", url, nil)
114113
suite.Assert().NoError(err)
@@ -159,7 +158,7 @@ func (suite *CacheEndpointTestSuite) TestPurgeCache() {
159158
suite.Assert().NoError(err)
160159
// create the cache first
161160

162-
r, err = http.NewRequest("DELETE", "http://localhost:7777/caches/purge", bytes.NewBuffer(data.body))
161+
r, err = http.NewRequest("DELETE", suite.admin_url+"/caches/purge", bytes.NewBuffer(data.body))
163162
suite.Assert().NoError(err)
164163
r.Header.Set("Content-Type", "application/json")
165164

go.mod

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
module github.com/sillygod/cdp-cache
22

3-
go 1.14
3+
go 1.16
44

55
require (
6-
github.com/armon/go-metrics v0.3.3 // indirect
7-
github.com/caddyserver/caddy/v2 v2.1.1
8-
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
9-
github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe // indirect
10-
github.com/go-redis/redis v6.15.8+incompatible
11-
github.com/google/uuid v1.1.1
12-
github.com/hashicorp/consul/api v1.5.0
13-
github.com/hashicorp/go-hclog v0.14.1 // indirect
14-
github.com/hashicorp/go-immutable-radix v1.2.0 // indirect
15-
github.com/hashicorp/go-msgpack v0.5.5 // indirect
16-
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
17-
github.com/hashicorp/golang-lru v0.5.4 // indirect
18-
github.com/hashicorp/serf v0.9.2 // indirect
6+
github.com/caddyserver/caddy/v2 v2.4.1
7+
github.com/go-redis/redis v6.15.9+incompatible
8+
github.com/google/uuid v1.2.0
9+
github.com/hashicorp/consul/api v1.8.1
1910
github.com/influxdata/influxdb-client-go v1.4.0
20-
github.com/mailgun/groupcache/v2 v2.2.0
21-
github.com/mitchellh/go-testing-interface v1.0.3 // indirect
22-
github.com/mitchellh/mapstructure v1.3.1 // indirect
23-
github.com/mitchellh/reflectwalk v1.0.1 // indirect
24-
github.com/opencontainers/go-digest v1.0.0 // indirect
25-
github.com/ory/dockertest/v3 v3.6.0
26-
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35
27-
github.com/stretchr/testify v1.6.1
28-
go.uber.org/zap v1.15.0
29-
golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
30-
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
31-
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d // indirect
11+
github.com/mailgun/groupcache/v2 v2.2.1
12+
github.com/ory/dockertest/v3 v3.6.5
13+
github.com/pquerna/cachecontrol v0.1.0
14+
github.com/stretchr/testify v1.7.0
15+
go.uber.org/zap v1.17.0
3216
)

0 commit comments

Comments
 (0)