chore: CI fixes

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2025-04-06 12:08:43 +02:00
parent aa7157e27c
commit 9ed3769765
4 changed files with 9 additions and 5 deletions

View File

@@ -72,7 +72,7 @@ func TestRun(t *testing.T) {
}, },
} { } {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
ctx, cancel := context.WithCancel(t.Context()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
if tc.config != "" { if tc.config != "" {

View File

@@ -16,6 +16,7 @@
package textfile_test package textfile_test
import ( import (
"context"
"fmt" "fmt"
"io" "io"
"log/slog" "log/slog"
@@ -44,7 +45,7 @@ func TestMultipleDirectories(t *testing.T) {
}) })
collectors := collector.New(map[string]collector.Collector{textfile.Name: textFileCollector}) collectors := collector.New(map[string]collector.Collector{textfile.Name: textFileCollector})
require.NoError(t, collectors.Build(t.Context(), logger)) require.NoError(t, collectors.Build(context.Background(), logger))
metrics := make(chan prometheus.Metric) metrics := make(chan prometheus.Metric)
got := "" got := ""
@@ -81,7 +82,7 @@ func TestDuplicateFileName(t *testing.T) {
}) })
collectors := collector.New(map[string]collector.Collector{textfile.Name: textFileCollector}) collectors := collector.New(map[string]collector.Collector{textfile.Name: textFileCollector})
require.NoError(t, collectors.Build(t.Context(), logger)) require.NoError(t, collectors.Build(context.Background(), logger))
metrics := make(chan prometheus.Metric) metrics := make(chan prometheus.Metric)
got := "" got := ""

View File

@@ -16,6 +16,7 @@
package config package config
import ( import (
"context"
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"io" "io"
@@ -91,6 +92,7 @@ func NewConfigFileResolver(file string) (*Resolver, error) {
) )
if strings.HasPrefix(file, "http://") || strings.HasPrefix(file, "https://") { if strings.HasPrefix(file, "http://") || strings.HasPrefix(file, "https://") {
//nolint:sloglint // we do not have an logger yet
slog.Warn("Loading configuration file from URL is deprecated and will be removed in 0.31.0. Use a local file instead.") slog.Warn("Loading configuration file from URL is deprecated and will be removed in 0.31.0. Use a local file instead.")
fileBytes, err = readFromURL(file) fileBytes, err = readFromURL(file)
@@ -142,7 +144,7 @@ func readFromURL(file string) ([]byte, error) {
client := &http.Client{Transport: tr} client := &http.Client{Transport: tr}
req, err := http.NewRequest(http.MethodGet, file, nil) req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, file, nil)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to create HTTP request: %w", err) return nil, fmt.Errorf("failed to create HTTP request: %w", err)
} }

View File

@@ -16,6 +16,7 @@
package testutils package testutils
import ( import (
"context"
"errors" "errors"
"io" "io"
"log/slog" "log/slog"
@@ -47,7 +48,7 @@ func FuncBenchmarkCollector[C collector.Collector](b *testing.B, name string, co
} }
collectors := collector.New(map[string]collector.Collector{name: c}) collectors := collector.New(map[string]collector.Collector{name: c})
require.NoError(b, collectors.Build(b.Context(), logger)) require.NoError(b, collectors.Build(context.Background(), logger))
metrics := make(chan prometheus.Metric) metrics := make(chan prometheus.Metric)