mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 12:58:02 +08:00
chore: update golangci-lint and fix all issues (#3575)
* chore: Update golangci-lint Signed-off-by: Lars Francke <git@lars-francke.de> * chore: fix all golangci-lint issues - Remove deprecated `// +build` tags - Fix godoclint, modernize, wsl_v5, govet, lll, gci, noctx issues - Update linter configuration - Modernize code to use Go 1.22+ features (for range N, slices.Contains, etc.) - Update make check lint the privileged tests Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com> --------- Signed-off-by: Lars Francke <git@lars-francke.de> Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com> Co-authored-by: Lars Francke <git@lars-francke.de>
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
//go:build !metrics
|
||||
// +build !metrics
|
||||
|
||||
package api
|
||||
|
||||
// We export below types in order for cli package to be able to read it from configuration file.
|
||||
// LogConfig and the other types below are exported so the cli package can read them from configuration file.
|
||||
type LogConfig struct {
|
||||
Level string
|
||||
Output string
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build !metrics
|
||||
// +build !metrics
|
||||
|
||||
package api
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build !metrics
|
||||
// +build !metrics
|
||||
|
||||
package api_test
|
||||
|
||||
@@ -53,6 +52,7 @@ func TestNew(t *testing.T) {
|
||||
|
||||
func isChannelDrained(ch chan prometheus.Metric) bool {
|
||||
time.Sleep(SleepTime)
|
||||
|
||||
select {
|
||||
case <-ch:
|
||||
return false
|
||||
@@ -230,7 +230,7 @@ func TestNewExporter(t *testing.T) {
|
||||
}
|
||||
|
||||
reqsSize := int(nBig.Int64())
|
||||
for i := 0; i < reqsSize; i++ {
|
||||
for range reqsSize {
|
||||
monitoring.IncDownloadCounter(serverController.Metrics, "dummyrepo")
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ func TestNewExporter(t *testing.T) {
|
||||
}
|
||||
|
||||
reqsSize := int(nBig.Int64())
|
||||
for i := 0; i < reqsSize; i++ {
|
||||
for range reqsSize {
|
||||
latency := getRandomLatency()
|
||||
latencySum += latency.Seconds()
|
||||
monitoring.ObserveHTTPRepoLatency(serverController.Metrics, "/v2/dummyrepo/manifests/testreference", latency)
|
||||
@@ -505,7 +505,7 @@ func TestNewExporter(t *testing.T) {
|
||||
}
|
||||
|
||||
workersSize := int(nBig.Int64())
|
||||
for i := 0; i < workersSize; i++ {
|
||||
for range workersSize {
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build !metrics
|
||||
// +build !metrics
|
||||
|
||||
//nolint:varnamelen
|
||||
package api
|
||||
@@ -30,14 +29,14 @@ type Collector struct {
|
||||
invalidChars *regexp.Regexp
|
||||
}
|
||||
|
||||
// Implements prometheus.Collector interface.
|
||||
// Describe implements prometheus.Collector interface.
|
||||
func (zc Collector) Describe(ch chan<- *prometheus.Desc) {
|
||||
for _, metricDescription := range zc.MetricsDesc {
|
||||
ch <- metricDescription
|
||||
}
|
||||
}
|
||||
|
||||
// Implements prometheus.Collector interface.
|
||||
// Collect implements prometheus.Collector interface.
|
||||
func (zc Collector) Collect(ch chan<- prometheus.Metric) {
|
||||
metrics, err := zc.Client.GetMetrics()
|
||||
if err != nil {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build !metrics
|
||||
// +build !metrics
|
||||
|
||||
package cli
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build !metrics
|
||||
// +build !metrics
|
||||
|
||||
package cli_test
|
||||
|
||||
|
||||
Reference in New Issue
Block a user