Skip to content

Commit 3e8e40b

Browse files
authored
Merge branch 'master' into add_ttl_parameter_to_pushover
2 parents 3d8b3da + 53b785b commit 3e8e40b

File tree

6 files changed

+51
-51
lines changed

6 files changed

+51
-51
lines changed

Diff for: .github/workflows/labeler.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ jobs:
2222
GH_REPO: ${{ github.repository }}
2323
NUMBER: ${{ github.event.issue.number }}${{ github.event.pull_request.number }}
2424
run: |
25-
if [[ $TITLE == *"feat:"* || $TITLE == *"feat("* ]]; then
25+
if [[ $TITLE == "feat"* ]]; then
2626
gh issue edit "$NUMBER" --add-label "feature"
27-
elif [[ $TITLE == *"fix:"* || $TITLE == *"fix("* ]]; then
27+
elif [[ $TITLE == "fix"* ]]; then
2828
gh issue edit "$NUMBER" --add-label "bug"
2929
fi
3030
if [[ $TITLE == *"alerting"* || $TITLE == *"provider"* || $TITLE == *"alert"* ]]; then

Diff for: .github/workflows/publish-custom.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ jobs:
1616
- name: Set up Docker Buildx
1717
uses: docker/setup-buildx-action@v3
1818
- name: Get image repository
19-
run: echo IMAGE_REPOSITORY=$(echo ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
20-
- name: Login to Docker Registry
19+
run: echo GHCR_IMAGE_REPOSITORY=$(echo ghcr.io/${{ github.actor }}/${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
20+
- name: Login to GitHub Container Registry
2121
uses: docker/login-action@v3
2222
with:
23-
username: ${{ secrets.DOCKER_USERNAME }}
24-
password: ${{ secrets.DOCKER_PASSWORD }}
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
2526
- name: Docker meta
2627
id: meta
2728
uses: docker/metadata-action@v5
2829
with:
29-
images: ${{ env.IMAGE_REPOSITORY }}
30+
images: ${{ env.GHCR_IMAGE_REPOSITORY }}
3031
tags: |
3132
type=raw,value=${{ inputs.tag }}
3233
- name: Build and push Docker image

Diff for: Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Build the go application into a binary
22
FROM golang:alpine AS builder
3-
RUN apk --update add ca-certificates
3+
RUN apk --update add ca-certificates libcap-setcap
44
WORKDIR /app
55
COPY . ./
66
RUN go mod tidy
77
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gatus .
8+
RUN setcap CAP_NET_RAW+ep gatus
89

910
# Run Tests inside docker image if you don't have a configured go environment
1011
#RUN apk update && apk add --virtual build-dependencies build-base gcc

Diff for: config/maintenance/maintenance_test.go

+32-33
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,16 @@ func TestConfig_IsUnderMaintenance(t *testing.T) {
177177
yes, no := true, false
178178
now := time.Now().UTC()
179179
scenarios := []struct {
180-
name string
181-
cfg *Config
182-
expected bool
180+
name string
181+
cfg *Config
182+
expectedUnderMaintenance bool
183183
}{
184184
{
185185
name: "disabled",
186186
cfg: &Config{
187187
Enabled: &no,
188188
},
189-
expected: false,
189+
expectedUnderMaintenance: false,
190190
},
191191
{
192192
name: "under-maintenance-explicitly-enabled",
@@ -195,23 +195,23 @@ func TestConfig_IsUnderMaintenance(t *testing.T) {
195195
Start: fmt.Sprintf("%02d:00", now.Hour()),
196196
Duration: 2 * time.Hour,
197197
},
198-
expected: true,
198+
expectedUnderMaintenance: true,
199199
},
200200
{
201201
name: "under-maintenance-starting-now-for-2h",
202202
cfg: &Config{
203203
Start: fmt.Sprintf("%02d:00", now.Hour()),
204204
Duration: 2 * time.Hour,
205205
},
206-
expected: true,
206+
expectedUnderMaintenance: true,
207207
},
208208
{
209209
name: "under-maintenance-starting-now-for-8h",
210210
cfg: &Config{
211211
Start: fmt.Sprintf("%02d:00", now.Hour()),
212212
Duration: 8 * time.Hour,
213213
},
214-
expected: true,
214+
expectedUnderMaintenance: true,
215215
},
216216
{
217217
name: "under-maintenance-starting-now-for-8h-explicit-days",
@@ -220,7 +220,7 @@ func TestConfig_IsUnderMaintenance(t *testing.T) {
220220
Duration: 8 * time.Hour,
221221
Every: []string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"},
222222
},
223-
expected: true,
223+
expectedUnderMaintenance: true,
224224
},
225225
{
226226
name: "under-maintenance-starting-now-for-23h-explicit-days",
@@ -229,40 +229,40 @@ func TestConfig_IsUnderMaintenance(t *testing.T) {
229229
Duration: 23 * time.Hour,
230230
Every: []string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"},
231231
},
232-
expected: true,
232+
expectedUnderMaintenance: true,
233233
},
234234
{
235235
name: "under-maintenance-starting-4h-ago-for-8h",
236236
cfg: &Config{
237237
Start: fmt.Sprintf("%02d:00", normalizeHour(now.Hour()-4)),
238238
Duration: 8 * time.Hour,
239239
},
240-
expected: true,
240+
expectedUnderMaintenance: true,
241241
},
242242
{
243243
name: "under-maintenance-starting-22h-ago-for-23h",
244244
cfg: &Config{
245245
Start: fmt.Sprintf("%02d:00", normalizeHour(now.Hour()-22)),
246246
Duration: 23 * time.Hour,
247247
},
248-
expected: true,
248+
expectedUnderMaintenance: true,
249249
},
250250
{
251251
name: "under-maintenance-starting-22h-ago-for-24h",
252252
cfg: &Config{
253253
Start: fmt.Sprintf("%02d:00", normalizeHour(now.Hour()-22)),
254254
Duration: 24 * time.Hour,
255255
},
256-
expected: true,
256+
expectedUnderMaintenance: true,
257257
},
258258
{
259259
name: "under-maintenance-amsterdam-timezone-starting-now-for-2h",
260260
cfg: &Config{
261-
Start: fmt.Sprintf("%02d:00", now.Hour()),
261+
Start: fmt.Sprintf("%02d:00", inTimezone(now, "Europe/Amsterdam", t).Hour()),
262262
Duration: 2 * time.Hour,
263263
Timezone: "Europe/Amsterdam",
264264
},
265-
expected: true,
265+
expectedUnderMaintenance: true,
266266
},
267267
{
268268
name: "under-maintenance-perth-timezone-starting-now-for-2h",
@@ -271,7 +271,17 @@ func TestConfig_IsUnderMaintenance(t *testing.T) {
271271
Duration: 2 * time.Hour,
272272
Timezone: "Australia/Perth",
273273
},
274-
expected: true,
274+
expectedUnderMaintenance: true,
275+
},
276+
{
277+
name: "not-under-maintenance-los-angeles-timezone-starting-now-for-2h-today",
278+
cfg: &Config{
279+
Start: fmt.Sprintf("%02d:00", now.Hour()),
280+
Duration: 2 * time.Hour,
281+
Timezone: "America/Los_Angeles",
282+
Every: []string{now.Weekday().String()},
283+
},
284+
expectedUnderMaintenance: false,
275285
},
276286
{
277287
name: "under-maintenance-utc-timezone-starting-now-for-2h",
@@ -280,23 +290,23 @@ func TestConfig_IsUnderMaintenance(t *testing.T) {
280290
Duration: 2 * time.Hour,
281291
Timezone: "UTC",
282292
},
283-
expected: true,
293+
expectedUnderMaintenance: true,
284294
},
285295
{
286296
name: "not-under-maintenance-starting-4h-ago-for-3h",
287297
cfg: &Config{
288298
Start: fmt.Sprintf("%02d:00", normalizeHour(now.Hour()-4)),
289299
Duration: 3 * time.Hour,
290300
},
291-
expected: false,
301+
expectedUnderMaintenance: false,
292302
},
293303
{
294304
name: "not-under-maintenance-starting-5h-ago-for-1h",
295305
cfg: &Config{
296306
Start: fmt.Sprintf("%02d:00", normalizeHour(now.Hour()-5)),
297307
Duration: time.Hour,
298308
},
299-
expected: false,
309+
expectedUnderMaintenance: false,
300310
},
301311
{
302312
name: "not-under-maintenance-today",
@@ -305,7 +315,7 @@ func TestConfig_IsUnderMaintenance(t *testing.T) {
305315
Duration: time.Hour,
306316
Every: []string{now.Add(48 * time.Hour).Weekday().String()},
307317
},
308-
expected: false,
318+
expectedUnderMaintenance: false,
309319
},
310320
{
311321
name: "not-under-maintenance-today-with-24h-duration",
@@ -314,17 +324,7 @@ func TestConfig_IsUnderMaintenance(t *testing.T) {
314324
Duration: 24 * time.Hour,
315325
Every: []string{now.Add(48 * time.Hour).Weekday().String()},
316326
},
317-
expected: false,
318-
},
319-
{
320-
name: "not-under-maintenance-los-angeles-timezone-starting-now-for-2h-today",
321-
cfg: &Config{
322-
Start: fmt.Sprintf("%02d:00", now.Hour()),
323-
Duration: 2 * time.Hour,
324-
Timezone: "America/Los_Angeles",
325-
Every: []string{now.Weekday().String()},
326-
},
327-
expected: false,
327+
expectedUnderMaintenance: false,
328328
},
329329
}
330330
for _, scenario := range scenarios {
@@ -335,8 +335,8 @@ func TestConfig_IsUnderMaintenance(t *testing.T) {
335335
t.Fatal("validation shouldn't have returned an error, got", err)
336336
}
337337
isUnderMaintenance := scenario.cfg.IsUnderMaintenance()
338-
if isUnderMaintenance != scenario.expected {
339-
t.Errorf("expected %v, got %v", scenario.expected, isUnderMaintenance)
338+
if isUnderMaintenance != scenario.expectedUnderMaintenance {
339+
t.Errorf("expectedUnderMaintenance %v, got %v", scenario.expectedUnderMaintenance, isUnderMaintenance)
340340
t.Logf("start=%v; duration=%v; now=%v", scenario.cfg.Start, scenario.cfg.Duration, time.Now().UTC())
341341
}
342342
})
@@ -352,7 +352,6 @@ func normalizeHour(hour int) int {
352352

353353
func inTimezone(passedTime time.Time, timezone string, t *testing.T) time.Time {
354354
timezoneLocation, err := time.LoadLocation(timezone)
355-
356355
if err != nil {
357356
t.Fatalf("timezone %s did not load", timezone)
358357
}

Diff for: go.mod

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module github.com/TwiN/gatus/v5
22

33
go 1.24.1
4-
54
require (
65
code.gitea.io/sdk/gitea v0.19.0
76
github.com/TwiN/deepmerge v0.2.2
@@ -18,8 +17,8 @@ require (
1817
github.com/ishidawataru/sctp v0.0.0-20230406120618-7ff4192f6ff2
1918
github.com/lib/pq v1.10.9
2019
github.com/miekg/dns v1.1.64
21-
github.com/prometheus-community/pro-bing v0.5.0
22-
github.com/prometheus/client_golang v1.20.5
20+
github.com/prometheus-community/pro-bing v0.6.1
21+
github.com/prometheus/client_golang v1.21.1
2322
github.com/valyala/fasthttp v1.58.0
2423
github.com/wcharczuk/go-chart/v2 v2.1.2
2524
golang.org/x/crypto v0.36.0
@@ -61,7 +60,7 @@ require (
6160
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
6261
github.com/ncruces/go-strftime v0.1.9 // indirect
6362
github.com/prometheus/client_model v0.6.1 // indirect
64-
github.com/prometheus/common v0.55.0 // indirect
63+
github.com/prometheus/common v0.62.0 // indirect
6564
github.com/prometheus/procfs v0.15.1 // indirect
6665
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
6766
github.com/rivo/uniseg v0.4.7 // indirect

Diff for: go.sum

+6-6
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdh
105105
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
106106
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
107107
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
108-
github.com/prometheus-community/pro-bing v0.5.0 h1:Fq+4BUXKIvsPtXUY8K+04ud9dkAuFozqGmRAyNUpffY=
109-
github.com/prometheus-community/pro-bing v0.5.0/go.mod h1:1joR9oXdMEAcAJJvhs+8vNDvTg5thfAZcRFhcUozG2g=
110-
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
111-
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
108+
github.com/prometheus-community/pro-bing v0.6.1 h1:EQukUOma9YFZRPe4DGSscxUf9LH07rpqwisNWjSZrgU=
109+
github.com/prometheus-community/pro-bing v0.6.1/go.mod h1:jNCOI3D7pmTCeaoF41cNS6uaxeFY/Gmc3ffwbuJVzAQ=
110+
github.com/prometheus/client_golang v1.21.1 h1:DOvXXTqVzvkIewV/CDPFdejpMCGeMcbGCQ8YOmu+Ibk=
111+
github.com/prometheus/client_golang v1.21.1/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg=
112112
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
113113
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
114-
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
115-
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
114+
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
115+
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
116116
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
117117
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
118118
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=

0 commit comments

Comments
 (0)