Fix golangci-lint errors (#10196)

* Fix golangci-lint errors

Signed-off-by: z1cheng <imchench@gmail.com>

* Fix dupl errors

Signed-off-by: z1cheng <imchench@gmail.com>

* Fix comments

Signed-off-by: z1cheng <imchench@gmail.com>

* Fix errcheck lint errors

Signed-off-by: z1cheng <imchench@gmail.com>

* Fix assert in e2e test

Signed-off-by: z1cheng <imchench@gmail.com>

* Not interrupt the waitForPodsReady

Signed-off-by: z1cheng <imchench@gmail.com>

* Replace string with constant

Signed-off-by: z1cheng <imchench@gmail.com>

* Fix comments

Signed-off-by: z1cheng <imchench@gmail.com>

* Revert write file permision

Signed-off-by: z1cheng <imchench@gmail.com>

---------

Signed-off-by: z1cheng <imchench@gmail.com>
This commit is contained in:
Chen Chen 2023-08-31 15:36:48 +08:00 committed by GitHub
parent 46d87d3462
commit b3060bfbd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
253 changed files with 2434 additions and 2113 deletions

View file

@ -17,12 +17,11 @@ limitations under the License.
package annotations
import (
"context"
"crypto/tls"
"fmt"
"strings"
"context"
pb "github.com/moul/pb/grpcbin/go-grpc"
"github.com/onsi/ginkgo/v2"
"github.com/stretchr/testify/assert"
@ -36,6 +35,8 @@ import (
"k8s.io/ingress-nginx/test/e2e/framework"
)
const echoHost = "echo"
var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {
f := framework.NewDefaultFramework("grpc", framework.WithHTTPBunEnabled())
@ -67,7 +68,7 @@ var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {
ginkgo.It("should return OK for service with backend protocol GRPC", func() {
f.NewGRPCBinDeployment()
host := "echo"
host := echoHost
svc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
@ -102,14 +103,15 @@ var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {
return strings.Contains(server, "grpc_pass grpc://upstream_balancer;")
})
conn, _ := grpc.Dial(f.GetNginxIP()+":443",
conn, err := grpc.Dial(f.GetNginxIP()+":443",
grpc.WithTransportCredentials(
credentials.NewTLS(&tls.Config{
ServerName: "echo",
InsecureSkipVerify: true,
ServerName: echoHost,
InsecureSkipVerify: true, //nolint:gosec // Ignore certificate validation in testing
}),
),
)
assert.Nil(ginkgo.GinkgoT(), err, "error creating a connection")
defer conn.Close()
client := pb.NewGRPCBinClient(conn)
@ -125,7 +127,7 @@ var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {
ginkgo.It("authorization metadata should be overwritten by external auth response headers", func() {
f.NewGRPCBinDeployment()
host := "echo"
host := echoHost
svc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
@ -162,14 +164,15 @@ var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {
return strings.Contains(server, "grpc_pass grpc://upstream_balancer;")
})
conn, _ := grpc.Dial(f.GetNginxIP()+":443",
conn, err := grpc.Dial(f.GetNginxIP()+":443",
grpc.WithTransportCredentials(
credentials.NewTLS(&tls.Config{
ServerName: "echo",
InsecureSkipVerify: true,
ServerName: echoHost,
InsecureSkipVerify: true, //nolint:gosec // Ignore certificate validation in testing
}),
),
)
assert.Nil(ginkgo.GinkgoT(), err)
defer conn.Close()
client := pb.NewGRPCBinClient(conn)
@ -180,13 +183,13 @@ var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {
assert.Nil(ginkgo.GinkgoT(), err)
metadata := res.GetMetadata()
assert.Equal(ginkgo.GinkgoT(), "foo", metadata["authorization"].Values[0])
assert.Equal(ginkgo.GinkgoT(), fooHost, metadata["authorization"].Values[0])
})
ginkgo.It("should return OK for service with backend protocol GRPCS", func() {
f.NewGRPCBinDeployment()
host := "echo"
host := echoHost
svc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
@ -226,14 +229,15 @@ var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {
return strings.Contains(server, "grpc_pass grpcs://upstream_balancer;")
})
conn, _ := grpc.Dial(f.GetNginxIP()+":443",
conn, err := grpc.Dial(f.GetNginxIP()+":443",
grpc.WithTransportCredentials(
credentials.NewTLS(&tls.Config{
ServerName: "echo",
InsecureSkipVerify: true,
ServerName: echoHost,
InsecureSkipVerify: true, //nolint:gosec // Ignore the gosec error in testing
}),
),
)
assert.Nil(ginkgo.GinkgoT(), err)
defer conn.Close()
client := pb.NewGRPCBinClient(conn)