Skip to content

Commit 85eaee7

Browse files
authored
[Maintenance] Unify References via golangci-linter (#1861)
1 parent 5ee5f26 commit 85eaee7

File tree

168 files changed

+752
-745
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+752
-745
lines changed

.golangci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ linters-settings:
163163
pkg: k8s.io/client-go/kubernetes/typed/core/v1
164164
- alias: ugrpc
165165
pkg: github.com/arangodb/kube-arangodb/pkg/util/grpc
166+
- alias: goStrings
167+
pkg: strings
168+
- alias: goHttp
169+
pkg: net/http
166170
gci:
167171
sections:
168172
- standard

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- (Maintenance) Extend Documentation
55
- (Bugfix) (Platform) Cover NoAuth Case for Identity Service
66
- (Feature) Add ArangoMember Args
7+
- (Maintenance) Unify References via golangci-linter
78

89
## [1.2.47](https://github.com/arangodb/kube-arangodb/tree/1.2.47) (2025-03-28)
910
- (Bugfix) Use Profile Annotations

cmd/admin.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import (
2727
"fmt"
2828
"io"
2929
"net"
30-
"net/http"
30+
goHttp "net/http"
3131
"os"
3232
"os/signal"
3333
"strconv"
@@ -169,11 +169,11 @@ func cmdGetAgencyDump(cmd *cobra.Command, _ []string) {
169169
func getAgencyState(ctx context.Context, conn connection.Connection) (io.ReadCloser, error) {
170170
url := connection.NewUrl("_api", "agency", "read")
171171
data := []byte(`[["/"]]`)
172-
resp, body, err := connection.CallStream(ctx, conn, http.MethodPost, url, connection.WithBody(data))
172+
resp, body, err := connection.CallStream(ctx, conn, goHttp.MethodPost, url, connection.WithBody(data))
173173
if err != nil {
174174
return nil, err
175175
}
176-
if resp.Code() != http.StatusOK {
176+
if resp.Code() != goHttp.StatusOK {
177177
return nil, errors.New(fmt.Sprintf("unexpected HTTP status from \"%s\" endpoint", url))
178178
}
179179

@@ -241,7 +241,7 @@ func getAgencyLeader(ctx context.Context, conn connection.Connection) (string, e
241241
if err != nil {
242242
return "", err
243243
}
244-
if resp.Code() != http.StatusOK {
244+
if resp.Code() != goHttp.StatusOK {
245245
return "", errors.New("unexpected HTTP status from agency-dump endpoint")
246246
}
247247

@@ -257,11 +257,11 @@ func getAgencyLeader(ctx context.Context, conn connection.Connection) (string, e
257257
// getAgencyDump returns dump of the agency.
258258
func getAgencyDump(ctx context.Context, conn connection.Connection) (io.ReadCloser, error) {
259259
url := connection.NewUrl("_api", "cluster", "agency-dump")
260-
resp, body, err := connection.CallStream(ctx, conn, http.MethodGet, url)
260+
resp, body, err := connection.CallStream(ctx, conn, goHttp.MethodGet, url)
261261
if err != nil {
262262
return nil, err
263263
}
264-
if resp.Code() != http.StatusOK {
264+
if resp.Code() != goHttp.StatusOK {
265265
return nil, errors.New("unexpected HTTP status from agency-dump endpoint")
266266
}
267267

@@ -285,7 +285,7 @@ func createClient(endpoints []string, certCA *x509.CertPool, auth connection.Aut
285285
Authentication: auth,
286286
ContentType: contentType,
287287
Endpoint: connection.NewRoundRobinEndpoints(endpoints),
288-
Transport: &http.Transport{
288+
Transport: &goHttp.Transport{
289289
TLSClientConfig: &tls.Config{
290290
RootCAs: certCA,
291291
},

cmd/cmd.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import (
2525
goflag "flag"
2626
"fmt"
2727
"net"
28-
"net/http"
28+
goHttp "net/http"
2929
"os"
3030
"reflect"
3131
"strconv"
32-
"strings"
32+
goStrings "strings"
3333
"time"
3434

3535
"github.com/gin-gonic/gin"
@@ -335,7 +335,7 @@ func executeMain(cmd *cobra.Command, args []string) {
335335
logger.Err(err).Fatal("Unable to enable logger")
336336
}
337337

338-
podNameParts := strings.Split(name, "-")
338+
podNameParts := goStrings.Split(name, "-")
339339
operatorID := podNameParts[len(podNameParts)-1]
340340

341341
if operatorID != "" {
@@ -565,7 +565,7 @@ func startVersionProcess() error {
565565
r.GET("/_api/version", gin.WrapF(versionV1Responser.ServeHTTP))
566566
r.GET("/api/v1/version", gin.WrapF(versionV1Responser.ServeHTTP))
567567

568-
s := http.Server{
568+
s := goHttp.Server{
569569
Addr: listenAddr,
570570
Handler: r,
571571
}

cmd/crd.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import (
2525
"fmt"
2626
"os"
2727
"strconv"
28-
"strings"
28+
goStrings "strings"
2929
"time"
3030

3131
"github.com/spf13/cobra"
@@ -92,7 +92,7 @@ func prepareCRDOptions(schemaEnabledArgs []string, preserveUnknownFieldsArgs []s
9292
preserveUnknownFields := map[string]bool{}
9393

9494
for _, arg := range schemaEnabledArgs {
95-
parts := strings.SplitN(arg, "=", 2)
95+
parts := goStrings.SplitN(arg, "=", 2)
9696

9797
var enabled bool
9898

@@ -108,7 +108,7 @@ func prepareCRDOptions(schemaEnabledArgs []string, preserveUnknownFieldsArgs []s
108108
}
109109

110110
for _, arg := range preserveUnknownFieldsArgs {
111-
parts := strings.SplitN(arg, "=", 2)
111+
parts := goStrings.SplitN(arg, "=", 2)
112112

113113
var enabled bool
114114

cmd/exporter.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ package cmd
2222

2323
import (
2424
"context"
25-
"net/http"
25+
goHttp "net/http"
2626
"os"
2727
"time"
2828

@@ -111,10 +111,10 @@ func cmdExporterCheckE() error {
111111

112112
server, err := operatorHTTP.NewServer(ctx,
113113
operatorHTTP.DefaultHTTPServerSettings,
114-
operatorHTTP.WithServeMux(func(in *http.ServeMux) {
114+
operatorHTTP.WithServeMux(func(in *goHttp.ServeMux) {
115115
in.Handle("/metrics", p)
116-
}, func(in *http.ServeMux) {
117-
in.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
116+
}, func(in *goHttp.ServeMux) {
117+
in.HandleFunc("/", func(w goHttp.ResponseWriter, r *goHttp.Request) {
118118
w.Write([]byte(`<html>
119119
<head><title>ArangoDB Exporter</title></head>
120120
<body>

cmd/lifecycle_probes.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import (
2525
"encoding/json"
2626
"fmt"
2727
"io"
28-
"net/http"
28+
goHttp "net/http"
2929
"os"
3030
"path"
3131
"strconv"
@@ -103,14 +103,14 @@ func init() {
103103
f.BoolVar(&probeInput.Enterprise, "enterprise", enterprise, "Determines if ArangoDB is enterprise")
104104
}
105105

106-
func probeClient() *http.Client {
107-
tr := &http.Transport{}
106+
func probeClient() *goHttp.Client {
107+
tr := &goHttp.Transport{}
108108

109109
if probeInput.SSL {
110110
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
111111
}
112112

113-
client := &http.Client{
113+
client := &goHttp.Client{
114114
Transport: tr,
115115
}
116116

@@ -171,7 +171,7 @@ func getJWTToken() ([]byte, error) {
171171
return nil, errors.Errorf("Unable to find any token")
172172
}
173173

174-
func addAuthHeader(req *http.Request) error {
174+
func addAuthHeader(req *goHttp.Request) error {
175175
if !probeInput.Auth {
176176
return nil
177177
}
@@ -190,10 +190,10 @@ func addAuthHeader(req *http.Request) error {
190190
return nil
191191
}
192192

193-
func doRequest(endpoint string) (*http.Response, error) {
193+
func doRequest(endpoint string) (*goHttp.Response, error) {
194194
client := probeClient()
195195

196-
req, err := http.NewRequest(http.MethodGet, probeEndpoint(endpoint), nil)
196+
req, err := goHttp.NewRequest(goHttp.MethodGet, probeEndpoint(endpoint), nil)
197197
if err != nil {
198198
return nil, err
199199
}
@@ -222,7 +222,7 @@ func cmdLifecycleProbeRunE(cmd *cobra.Command) error {
222222
defer resp.Body.Close()
223223
}
224224

225-
if resp.StatusCode != http.StatusOK {
225+
if resp.StatusCode != goHttp.StatusOK {
226226
if resp.Body != nil {
227227
if data, err := io.ReadAll(resp.Body); err == nil {
228228
return errors.Errorf("Unexpected code: %d - %s", resp.StatusCode, string(data))

cmd/lifecycle_startup.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ package cmd
2222

2323
import (
2424
"fmt"
25-
"net/http"
25+
goHttp "net/http"
2626
"time"
2727

2828
"github.com/spf13/cobra"
@@ -42,14 +42,14 @@ func cmdLifecycleStartupFunc(cmd *cobra.Command, args []string) error {
4242

4343
port := ProbePort.GetOrDefault(fmt.Sprintf("%d", shared.ArangoPort))
4444

45-
server := &http.Server{
45+
server := &goHttp.Server{
4646
Addr: fmt.Sprintf(":%s", port),
4747
}
4848

49-
handlers := http.NewServeMux()
49+
handlers := goHttp.NewServeMux()
5050

51-
handlers.HandleFunc("/stop", func(writer http.ResponseWriter, request *http.Request) {
52-
writer.WriteHeader(http.StatusOK)
51+
handlers.HandleFunc("/stop", func(writer goHttp.ResponseWriter, request *goHttp.Request) {
52+
writer.WriteHeader(goHttp.StatusOK)
5353
close = true
5454
})
5555

@@ -66,7 +66,7 @@ func cmdLifecycleStartupFunc(cmd *cobra.Command, args []string) error {
6666
}()
6767

6868
if err := server.ListenAndServe(); err != nil {
69-
if errors.Is(err, http.ErrServerClosed) {
69+
if errors.Is(err, goHttp.ErrServerClosed) {
7070
return nil
7171
}
7272

cmd/uuid.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2025 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ package cmd
2323
import (
2424
"fmt"
2525
"os"
26-
"strings"
26+
goStrings "strings"
2727

2828
"github.com/rs/zerolog/log"
2929
"github.com/spf13/cobra"
@@ -156,7 +156,7 @@ func checkFileContent(path, expected string) (bool, string, error) {
156156
return false, "", err
157157
}
158158

159-
contentString := strings.TrimSuffix(string(content), "\n")
159+
contentString := goStrings.TrimSuffix(string(content), "\n")
160160

161161
return contentString == expected, contentString, nil
162162
}

0 commit comments

Comments
 (0)