From 56118faebfdbf7f128be2bc1f26e1747ae175107 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 13:31:54 +0000 Subject: [PATCH 1/3] Update golangci/golangci-lint Docker tag to v1.55.0 --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index c5e8a977..c17bdc01 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,4 +1,4 @@ -# v1.54.2 +# v1.55.0 # Please don't remove the first line. It is used in CI to determine the golangci version run: deadline: 5m From 0372a1c37b428a54e0f26a076c4fb0a734f82a3a Mon Sep 17 00:00:00 2001 From: Roberto Santalla Date: Tue, 24 Oct 2023 13:27:18 +0200 Subject: [PATCH 2/3] golangci: disable new linters we do not want --- .golangci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index c17bdc01..52b4d7d0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -104,4 +104,8 @@ linters: - ifshort - nosnakecase - depguard # Dependency whitelist, needs to be configured + - goconst # Fails if the same strings used in several places but is not a constant. Not very useful. + - inamedparam # Fails if interfaces do not have named params. Not in our code style. + - perfsprint # Suggests using strconv.* instead of fmt.* for printing numbers. Not very practical. + - protogetter # Complains when code reads var.Something if var.GetSomething() exists. Not useful. fast: false From 6cf13796dcbba15962704e07dae3914aa098b6ec Mon Sep 17 00:00:00 2001 From: Roberto Santalla Date: Wed, 25 Oct 2023 11:32:33 +0200 Subject: [PATCH 3/3] ci: re-enable goconst, fix goconst messages --- .golangci.yml | 1 - pkg/iptables/iptables.go | 1 + pkg/runtime/executor_test.go | 3 +-- pkg/runtime/fake_test.go | 21 +++++++-------------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 52b4d7d0..c971fb0c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -104,7 +104,6 @@ linters: - ifshort - nosnakecase - depguard # Dependency whitelist, needs to be configured - - goconst # Fails if the same strings used in several places but is not a constant. Not very useful. - inamedparam # Fails if interfaces do not have named params. Not in our code style. - perfsprint # Suggests using strconv.* instead of fmt.* for printing numbers. Not very practical. - protogetter # Complains when code reads var.Something if var.GetSomething() exists. Not useful. diff --git a/pkg/iptables/iptables.go b/pkg/iptables/iptables.go index c954a954..5bb72372 100644 --- a/pkg/iptables/iptables.go +++ b/pkg/iptables/iptables.go @@ -43,6 +43,7 @@ import ( const redirectLocalRule = "OUTPUT " + // For local traffic "-t nat " + // Traversing the nat table "-s 127.0.0.0/8 -d 127.0.0.1/32 " + // Coming from and directed to localhost, i.e. not the pod IP. + //nolint:goconst "-p tcp --dport %d " + // Sent to the upstream application's port "-j REDIRECT --to-port %d" // Forward it to the proxy address diff --git a/pkg/runtime/executor_test.go b/pkg/runtime/executor_test.go index b80a8145..d10676ec 100644 --- a/pkg/runtime/executor_test.go +++ b/pkg/runtime/executor_test.go @@ -68,8 +68,7 @@ func Test_Exec(t *testing.T) { if string(out) != tc.expectOutput { t.Errorf( - "returned output does not match expected value.\n"+ - "Expected: %s\nActual: %s\n", + "returned output does not match expected value.\nExpected: %s\nActual: %s", tc.expectOutput, string(out), ) diff --git a/pkg/runtime/fake_test.go b/pkg/runtime/fake_test.go index b6af8f19..873f8d43 100644 --- a/pkg/runtime/fake_test.go +++ b/pkg/runtime/fake_test.go @@ -54,8 +54,7 @@ func Test_FakeExecutor(t *testing.T) { if !errors.Is(err, tc.err) { t.Errorf( - "returned error does not match expected value.\n"+ - "Expected: %v\nActual: %v\n", + "returned error does not match expected value.\nExpected: %v\nActual: %v", tc.err, err, ) @@ -64,8 +63,7 @@ func Test_FakeExecutor(t *testing.T) { if string(out) != string(tc.out) { t.Errorf( - "returned output does not match expected value.\n"+ - "Expected: %s\nActual: %s\n", + "returned output does not match expected value.\nExpected: %s\nActual: %s", string(tc.out), string(out), ) @@ -107,8 +105,7 @@ func Test_MultipleExecutions(t *testing.T) { if !errors.Is(err, tc.err) { t.Errorf( - "returned error does not match expected value.\n"+ - "Expected: %v\nActual: %v\n", + "returned error does not match expected value.\nExpected: %v\nActual: %v", tc.err, err, ) @@ -117,8 +114,7 @@ func Test_MultipleExecutions(t *testing.T) { if string(out) != string(tc.out) { t.Errorf( - "returned output does not match expected value.\n"+ - "Expected: %s\nActual: %s\n", + "returned output does not match expected value.\nExpected: %s\nActual: %s", string(tc.out), string(out), ) @@ -130,8 +126,7 @@ func Test_MultipleExecutions(t *testing.T) { actual := strings.Join(fake.CmdHistory(), "\n") if actual != expected { t.Errorf( - "command history does not match expected value.\n"+ - "Expected: %v\nActual: %v\n", + "command history does not match expected value.\nExpected: %v\nActual: %v", expected, actual, ) @@ -190,8 +185,7 @@ func Test_Callbacks(t *testing.T) { if !errors.Is(err, tc.err) { t.Errorf( - "returned error does not match expected value.\n"+ - "Expected: %v\nActual: %v\n", + "returned error does not match expected value.\nExpected: %v\nActual: %v", tc.err, err, ) @@ -200,8 +194,7 @@ func Test_Callbacks(t *testing.T) { if string(out) != string(tc.out) { t.Errorf( - "returned output does not match expected value.\n"+ - "Expected: %s\nActual: %s\n", + "returned output does not match expected value.\nExpected: %s\nActual: %s", string(tc.out), string(out), )