Skip to content

Commit c1a980e

Browse files
committed
BUILD/MAJOR: ci: apply new linting rules
1 parent 892052b commit c1a980e

File tree

16 files changed

+35
-37
lines changed

16 files changed

+35
-37
lines changed

crs/generated/clientset/versioned/fake/register.go

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crs/generated/clientset/versioned/scheme/register.go

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/tests/e2e/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"context"
2121
"crypto/tls"
2222
"fmt"
23-
"io/ioutil"
23+
"io"
2424
"net"
2525
"net/http"
2626
"os"
@@ -177,7 +177,7 @@ func ProxyProtoConn() (result []byte, err error) {
177177
return
178178
}
179179

180-
return ioutil.ReadAll(conn)
180+
return io.ReadAll(conn)
181181
}
182182

183183
func runtimeCommand(command string) (result []byte, err error) {

deploy/tests/e2e/haproxy-files/patternfiles_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
package haproxyfiles
1818

1919
import (
20-
"github.com/haproxytech/kubernetes-ingress/deploy/tests/e2e"
2120
"strconv"
21+
22+
"github.com/haproxytech/kubernetes-ingress/deploy/tests/e2e"
2223
)
2324

2425
var tests1 = []string{

deploy/tests/e2e/ingress-match/ingress_match_path_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ var ingressRules = []IngressRule{
4444
{Service: "http-echo-9", Host: "*.haproxy", PathType: "ImplementationSpecific"},
4545
{Service: "http-echo-10", Path: "/test", PathType: "ImplementationSpecific"},
4646
}
47+
4748
var tests = []test{
4849
{ingressRules[0].Service, "app.haproxy", []string{"/", "/test", "/exact/", "/exactslash", "/exactslash/foo", "/prefixxx"}},
4950
{ingressRules[1].Service, "app.haproxy", []string{"/a"}},

deploy/tests/e2e/service-discovery/port_discovery.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,4 @@ func (suite *ServiceDiscoverySuite) testServicePort(serviceName, servicePort, po
5050
}
5151
return strings.HasPrefix(string(body), serviceName)
5252
}, e2e.WaitDuration, e2e.TickDuration)
53-
5453
}

deploy/tests/e2e/utils.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"flag"
66
"fmt"
7-
"io/ioutil"
87
"os"
98
"os/exec"
109
"path/filepath"
@@ -54,7 +53,7 @@ func NewTest() (test Test, err error) {
5453
return nil
5554
}}
5655
// TemplateDir
57-
test.templateDir, err = ioutil.TempDir("/tmp/", "haproxy-ic-test-tmpl")
56+
test.templateDir, err = os.MkdirTemp("/tmp/", "haproxy-ic-test-tmpl")
5857
if err != nil {
5958
return test, fmt.Errorf("error creating template dir: %w ", err)
6059
}
@@ -73,7 +72,7 @@ func (t *Test) Apply(path string, namespace string, tmplData interface{}) error
7372
return err
7473
}
7574
}
76-
if file, err = ioutil.ReadFile(path); err != nil {
75+
if file, err = os.ReadFile(path); err != nil {
7776
return fmt.Errorf("error reading yaml file: %w", err)
7877
}
7978
// kubectl -n $NS apply -f -
@@ -84,7 +83,7 @@ func (t *Test) Apply(path string, namespace string, tmplData interface{}) error
8483
}
8584

8685
func (t *Test) processTemplate(path string, tmplData interface{}) (string, error) {
87-
file, err := ioutil.ReadFile(path)
86+
file, err := os.ReadFile(path)
8887
if err != nil {
8988
return "", fmt.Errorf("error reading yaml template: %w", err)
9089
}
@@ -95,13 +94,13 @@ func (t *Test) processTemplate(path string, tmplData interface{}) (string, error
9594
return "", fmt.Errorf("error parsing yaml template: %w", err)
9695
}
9796
yaml := filepath.Join(t.templateDir, t.namespace+time.Now().Format("2006-01-02-1504051111")+".yaml")
98-
return yaml, ioutil.WriteFile(yaml, result.Bytes(), 0o600)
97+
return yaml, os.WriteFile(yaml, result.Bytes(), 0o600)
9998
}
10099

101100
func (t *Test) Delete(path string) error {
102101
var err error
103102
var file []byte
104-
if file, err = ioutil.ReadFile(path); err != nil {
103+
if file, err = os.ReadFile(path); err != nil {
105104
return fmt.Errorf("error reading yaml file: %w", err)
106105
}
107106
if out, errApply := t.execute(string(file), "kubectl", "delete", "-f", "-"); errApply != nil {

deploy/tests/images/http-echo/handlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func (c context) echoHostname(writer http.ResponseWriter, request *http.Request)
1515
fmt.Fprintln(writer, c.hostname)
1616
}
1717

18-
// echoAll echos back request in response
18+
// echoAll echos back request in response
1919
func (c context) echoAll(writer http.ResponseWriter, request *http.Request) {
2020
log.Println("Echoing back request made to " + request.URL.Path + " to client (" + request.RemoteAddr + ")")
2121
attr := make(map[string]interface{})

deploy/tests/integration/customresources/suite_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package customresources
1616

1717
import (
18-
"io/ioutil"
1918
"os"
2019
"path/filepath"
2120
"testing"
@@ -48,7 +47,7 @@ type Test struct {
4847
}
4948

5049
func (suite *CustomResourceSuite) BeforeTest(suiteName, testName string) {
51-
tempDir, err := ioutil.TempDir("", "ut-"+testName+"-*")
50+
tempDir, err := os.MkdirTemp("", "ut-"+testName+"-*")
5251
if err != nil {
5352
suite.T().Fatalf("Suite '%s': Test '%s' : error : %s", suiteName, testName, err)
5453
}

deploy/tests/tnr/routeacl/suite_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package routeacl
1616

1717
import (
18-
"io/ioutil"
1918
"os"
2019
"testing"
2120

@@ -46,7 +45,7 @@ type Test struct {
4645
}
4746

4847
func (suite *UseBackendSuite) BeforeTest(suiteName, testName string) {
49-
tempDir, err := ioutil.TempDir("", "tnr-"+testName+"-*")
48+
tempDir, err := os.MkdirTemp("", "tnr-"+testName+"-*")
5049
if err != nil {
5150
suite.T().Fatalf("Suite '%s': Test '%s' : error : %s", suiteName, testName, err)
5251
}

deploy/tests/tnr/routeacl/usebackend_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package routeacl
1616

1717
import (
18-
"io/ioutil"
18+
"os"
1919
"path/filepath"
2020
"strings"
2121
)
@@ -24,7 +24,7 @@ func (suite *UseBackendSuite) TestUseBackend() {
2424
// This test addresses https://github.com/haproxytech/kubernetes-ingress/issues/476
2525
suite.UseBackendFixture()
2626
suite.Run("Modifying service annotations should not duplicate use_backend clause", func() {
27-
contents, err := ioutil.ReadFile(filepath.Join(suite.test.TempDir, "haproxy.cfg"))
27+
contents, err := os.ReadFile(filepath.Join(suite.test.TempDir, "haproxy.cfg"))
2828
if err != nil {
2929
suite.T().Error(err.Error())
3030
}

documentation/gen/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (c *Conf) generateReadmeController() {
7575
buff.WriteString("<p align='right'><a href='#haproxy-kubernetes-ingress-controller'>:arrow_up_small: back to top</a></p>\n\n***\n\n")
7676
}
7777

78-
err := renameio.WriteFile("../controller.md", []byte(buff.String()), 0644)
78+
err := renameio.WriteFile("../controller.md", []byte(buff.String()), 0o644)
7979
if err != nil {
8080
log.Println(err)
8181
}

pkg/handler/refresh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
type Refresh struct{}
2424

2525
func (handler Refresh) Update(k store.K8s, h haproxy.HAProxy, a annotations.Annotations) (reload bool, err error) {
26-
var cleanCrts = true
26+
cleanCrts := true
2727
cleanCrtsAnn, _ := annotations.ParseBool("clean-certs", k.ConfigMaps.Main.Annotations)
2828
// cleanCrtsAnn is empty if clean-certs not set or set with a non boolean value => error
2929
if cleanCrtsAnn == "false" {

pkg/haproxy/certs/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package certs
33
import (
44
"errors"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"path"
98
"strings"
@@ -183,7 +182,7 @@ func (c *certs) CertsUpdated() (reload bool) {
183182
}
184183

185184
func refreshCerts(certs map[string]*cert, certDir string) (removed bool) {
186-
files, err := ioutil.ReadDir(certDir)
185+
files, err := os.ReadDir(certDir)
187186
if err != nil {
188187
logger.Error(err)
189188
return false

pkg/ingress/ingress.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (i *Ingress) handlePath(k store.K8s, h haproxy.HAProxy, host string, path *
143143
// without the need to map Rule IDs to specific ingress traffic.
144144
func (i *Ingress) handleAnnotations(k store.K8s, h haproxy.HAProxy) {
145145
var err error
146-
var result = rules.List{}
146+
result := rules.List{}
147147
for _, a := range i.annotations.Frontend(i.resource, &result, h.Maps) {
148148
err = a.Process(k, i.resource.Annotations, k.ConfigMaps.Main.Annotations)
149149
if err != nil {
@@ -155,7 +155,7 @@ func (i *Ingress) handleAnnotations(k store.K8s, h haproxy.HAProxy) {
155155

156156
func HandleCfgMapAnnotations(k store.K8s, h haproxy.HAProxy, a annotations.Annotations) {
157157
var err error
158-
var result = rules.List{}
158+
result := rules.List{}
159159
logger.Tracef("Processing Ingress annotations in ConfigMap")
160160
for _, a := range a.Frontend(nil, &result, h.Maps) {
161161
err = a.Process(k, k.ConfigMaps.Main.Annotations)

pkg/utils/logging.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const (
4444
//
4545
// if nil is sent, it won't be printed. This is useful for printing errors only
4646
// if they exist.
47+
//
4748
// ```
4849
//
4950
// if err != nil {

0 commit comments

Comments
 (0)