Skip to content

Commit 749d39d

Browse files
authored
Merge pull request #46 from Team-MostWanted/feature/INFRA-304-dependency-update-q-2-2025-prometheus-script-exporter
Feature/infra 304 dependency update q 2 2025 prometheus script exporter
2 parents e31cb9b + 9372cfe commit 749d39d

File tree

7 files changed

+45
-40
lines changed

7 files changed

+45
-40
lines changed

config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func configProbes(probesConfig YamlProbeConfig, fileName string) {
177177
log.Fatalf("Config failure probe with name '%s' already exists (%s)", probe.Name, fileName)
178178
}
179179

180-
var argumentOrder []string = make([]string, len(probe.Arguments))
180+
var argumentOrder = make([]string, len(probe.Arguments))
181181

182182
var labelNames []string
183183
var labelValues []string
@@ -201,7 +201,7 @@ func configProbes(probesConfig YamlProbeConfig, fileName string) {
201201

202202
i := 0
203203
for key, argument := range probe.Arguments {
204-
var argName string = fmt.Sprint(key)
204+
var argName = fmt.Sprint(key)
205205

206206
if argument.Param != nil {
207207
if _, exists := config.probes[probe.Name].arguments[*argument.Param]; exists {

go.mod

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module mostwanted.io/prometheus/script_exporter
22

3-
go 1.22
3+
go 1.24
44

55
require (
66
github.com/gorilla/handlers v1.5.2
7-
github.com/prometheus/client_golang v1.20.5
7+
github.com/prometheus/client_golang v1.22.0
88
github.com/sirupsen/logrus v1.9.3
99
github.com/stretchr/testify v1.10.0
1010
gopkg.in/yaml.v3 v3.0.1
@@ -15,13 +15,12 @@ require (
1515
github.com/cespare/xxhash/v2 v2.3.0 // indirect
1616
github.com/davecgh/go-spew v1.1.1 // indirect
1717
github.com/felixge/httpsnoop v1.0.4 // indirect
18-
github.com/klauspost/compress v1.17.11 // indirect
1918
github.com/kr/text v0.2.0 // indirect
2019
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
2120
github.com/pmezard/go-difflib v1.0.0 // indirect
2221
github.com/prometheus/client_model v0.6.1 // indirect
23-
github.com/prometheus/common v0.62.0 // indirect
24-
github.com/prometheus/procfs v0.15.1 // indirect
25-
golang.org/x/sys v0.29.0 // indirect
26-
google.golang.org/protobuf v1.36.4 // indirect
22+
github.com/prometheus/common v0.63.0 // indirect
23+
github.com/prometheus/procfs v0.16.0 // indirect
24+
golang.org/x/sys v0.32.0 // indirect
25+
google.golang.org/protobuf v1.36.6 // indirect
2726
)

go.sum

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
88
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
99
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
1010
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
11-
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
12-
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
11+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
12+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
1313
github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE=
1414
github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=
15-
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
16-
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
15+
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
16+
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
1717
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
1818
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
1919
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -24,14 +24,14 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
2424
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
2525
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2626
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
27-
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
28-
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
27+
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
28+
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
2929
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
3030
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
31-
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
32-
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
33-
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
34-
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
31+
github.com/prometheus/common v0.63.0 h1:YR/EIY1o3mEFP/kZCD7iDMnLPlGyuU2Gb3HIcXnA98k=
32+
github.com/prometheus/common v0.63.0/go.mod h1:VVFF/fBIoToEnWRVkYoXEkq3R3paCoxG9PXP74SnV18=
33+
github.com/prometheus/procfs v0.16.0 h1:xh6oHhKwnOJKMYiYBDWmkHqQPyiY40sny36Cmx2bbsM=
34+
github.com/prometheus/procfs v0.16.0/go.mod h1:8veyXUu3nGP7oaCxhX6yeaM5u4stL2FeMXnCqhDthZg=
3535
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
3636
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
3737
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
@@ -41,10 +41,10 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
4141
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
4242
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4343
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
44-
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
45-
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
46-
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
47-
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
44+
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
45+
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
46+
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
47+
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
4848
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
4949
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
5050
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func main() {
3030

3131
r := http.NewServeMux()
3232

33-
r.HandleFunc("/", landingpage)
33+
r.HandleFunc("/", landingPage)
3434
r.Handle("/metrics", promhttp.Handler())
3535
r.HandleFunc("/probe", probe)
3636

pages.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"net/http"
66
)
77

8-
func landingpage(w http.ResponseWriter, r *http.Request) {
8+
func landingPage(w http.ResponseWriter, r *http.Request) {
99
if r.URL.Path != "/" {
1010
http.NotFound(w, r)
1111
return
@@ -24,7 +24,7 @@ func landingpage(w http.ResponseWriter, r *http.Request) {
2424
)
2525
}
2626

27-
fmt.Fprintf(
27+
_, err := fmt.Fprintf(
2828
w,
2929
`<html>
3030
<head><title>%s</title></head>
@@ -38,12 +38,15 @@ func landingpage(w http.ResponseWriter, r *http.Request) {
3838
title,
3939
probesString,
4040
)
41+
if err != nil {
42+
return
43+
}
4144
}
4245

4346
func debugProbe(w http.ResponseWriter, probeName string, result runResult) {
4447
title := "Debug Probe " + probeName
4548

46-
fmt.Fprintf(
49+
_, err := fmt.Fprintf(
4750
w,
4851
`<html>
4952
<head><title>%s</title></head>
@@ -81,4 +84,7 @@ func debugProbe(w http.ResponseWriter, probeName string, result runResult) {
8184
result.stdout,
8285
result.stderr,
8386
)
87+
if err != nil {
88+
return
89+
}
8490
}

probe.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ func probe(w http.ResponseWriter, r *http.Request) {
5050

5151
func run(cmd *exec.Cmd) runResult {
5252
var result runResult
53-
var outbuf, errbuf bytes.Buffer
54-
cmd.Stdout = &outbuf
55-
cmd.Stderr = &errbuf
53+
var outBuf, errBuf bytes.Buffer
54+
cmd.Stdout = &outBuf
55+
cmd.Stderr = &errBuf
5656

5757
log.Debug("[Run] Start cmd", cmd)
5858
start := time.Now()
@@ -62,8 +62,8 @@ func run(cmd *exec.Cmd) runResult {
6262
result.duration = time.Since(start)
6363
log.Debug("[Run] End cmd duration: ", result.duration)
6464

65-
result.stdout = outbuf.String()
66-
result.stderr = errbuf.String()
65+
result.stdout = outBuf.String()
66+
result.stderr = errBuf.String()
6767

6868
result.exitCode = 0
6969
if err != nil {

probe_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ var commandTests = []struct {
2323

2424
func TestRun(t *testing.T) {
2525
for _, tt := range commandTests {
26-
assert := assert.New(t)
26+
newAssert := assert.New(t)
2727

2828
result := run(tt.program)
2929

30-
assert.Equalf(tt.expectedExitCode, result.exitCode, "Exit code incorrect for `%s`", tt.program)
31-
assert.Equalf(tt.expectedStdOut, result.stdout, "StdOut has content check failed for `%s`", tt.program)
32-
assert.Equalf(tt.expectedStdErr, result.stderr, "StdErr has content check failed for `%s`", tt.program)
30+
newAssert.Equalf(tt.expectedExitCode, result.exitCode, "Exit code incorrect for `%s`", tt.program)
31+
newAssert.Equalf(tt.expectedStdOut, result.stdout, "StdOut has content check failed for `%s`", tt.program)
32+
newAssert.Equalf(tt.expectedStdErr, result.stderr, "StdErr has content check failed for `%s`", tt.program)
3333
}
3434
}
3535

3636
func TestRunDuration(t *testing.T) {
37-
assert := assert.New(t)
37+
newAssert := assert.New(t)
3838

3939
duration := 2.0
4040
program := exec.Command("test/resources/sleeping.py", fmt.Sprintf("%f", duration))
4141
result := run(program)
4242

43-
assert.Equal(0, result.exitCode, "Exit code incorrect for `%s`", program)
44-
assert.GreaterOrEqual(result.duration.Seconds(), duration, "Duration incorrect `%s`", program)
45-
assert.LessOrEqual(result.duration.Seconds(), duration+1, "Duration incorrect `%s`", program)
43+
newAssert.Equal(0, result.exitCode, "Exit code incorrect for `%s`", program)
44+
newAssert.GreaterOrEqual(result.duration.Seconds(), duration, "Duration incorrect `%s`", program)
45+
newAssert.LessOrEqual(result.duration.Seconds(), duration+1, "Duration incorrect `%s`", program)
4646
}

0 commit comments

Comments
 (0)