Fix golang-ci linter errors (#10128)
* Fix golang-ci linter errors Signed-off-by: z1cheng <imchench@gmail.com> * Fix gofmt errors Signed-off-by: z1cheng <imchench@gmail.com> * Add nolint comment to defaults.Backend in Configuration Signed-off-by: z1cheng <imchench@gmail.com> * Add #nosec comment to rand.New func Signed-off-by: z1cheng <imchench@gmail.com> * Fix errcheck warnings Signed-off-by: z1cheng <imchench@gmail.com> * Fix gofmt check Signed-off-by: z1cheng <imchench@gmail.com> * Fix unit tests and comments Signed-off-by: z1cheng <imchench@gmail.com> --------- Signed-off-by: z1cheng <imchench@gmail.com>
This commit is contained in:
parent
f50431a9f9
commit
d44a8e0045
37 changed files with 206 additions and 162 deletions
|
|
@ -125,7 +125,7 @@ var _ = framework.DescribeAnnotation("affinitymode", func() {
|
|||
framework.Sleep()
|
||||
|
||||
// validate, there is no backend to serve the request
|
||||
response = request.WithCookies(cookies).Expect().Status(http.StatusServiceUnavailable)
|
||||
request.WithCookies(cookies).Expect().Status(http.StatusServiceUnavailable)
|
||||
|
||||
// create brand new backends
|
||||
replicas = 2
|
||||
|
|
|
|||
|
|
@ -76,7 +76,9 @@ var _ = framework.IngressNginxDescribeSerial("[TopologyHints] topology aware rou
|
|||
status, err := f.ExecIngressPod(curlCmd)
|
||||
assert.Nil(ginkgo.GinkgoT(), err)
|
||||
var backends []map[string]interface{}
|
||||
json.Unmarshal([]byte(status), &backends)
|
||||
if err := json.Unmarshal([]byte(status), &backends); err != nil {
|
||||
assert.Nil(ginkgo.GinkgoT(), err)
|
||||
}
|
||||
gotBackends := 0
|
||||
for _, bck := range backends {
|
||||
if strings.Contains(bck["name"].(string), "topology") {
|
||||
|
|
|
|||
|
|
@ -56,15 +56,8 @@ type deploymentOptions struct {
|
|||
name string
|
||||
namespace string
|
||||
image string
|
||||
port int32
|
||||
replicas int
|
||||
command []string
|
||||
args []string
|
||||
env []corev1.EnvVar
|
||||
volumeMounts []corev1.VolumeMount
|
||||
volumes []corev1.Volume
|
||||
svcAnnotations map[string]string
|
||||
setProbe bool
|
||||
}
|
||||
|
||||
// WithDeploymentNamespace allows configuring the deployment's namespace
|
||||
|
|
|
|||
|
|
@ -36,19 +36,3 @@ func (c *chain) fail(message string, args ...interface{}) {
|
|||
c.failbit = true
|
||||
c.reporter.Errorf(message, args...)
|
||||
}
|
||||
|
||||
func (c *chain) reset() {
|
||||
c.failbit = false
|
||||
}
|
||||
|
||||
func (c *chain) assertFailed(r Reporter) {
|
||||
if !c.failbit {
|
||||
r.Errorf("expected chain is failed, but it's ok")
|
||||
}
|
||||
}
|
||||
|
||||
func (c *chain) assertOK(r Reporter) {
|
||||
if c.failbit {
|
||||
r.Errorf("expected chain is ok, but it's failed")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,9 @@ func smugglingRequest(host, addr string, port int) (string, error) {
|
|||
|
||||
defer conn.Close()
|
||||
|
||||
conn.SetDeadline(time.Now().Add(time.Second * 10))
|
||||
if err := conn.SetDeadline(time.Now().Add(time.Second * 10)); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
_, err = fmt.Fprintf(conn, "GET /echo HTTP/1.1\r\nHost: %v\r\nContent-Length: 56\r\n\r\nGET /_hidden/index.html HTTP/1.1\r\nHost: notlocalhost\r\n\r\n", host)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -63,8 +63,12 @@ var _ = framework.DescribeSetting("use-proxy-protocol", func() {
|
|||
defer conn.Close()
|
||||
|
||||
header := "PROXY TCP4 192.168.0.1 192.168.0.11 56324 1234\r\n"
|
||||
conn.Write([]byte(header))
|
||||
conn.Write([]byte("GET / HTTP/1.1\r\nHost: proxy-protocol\r\n\r\n"))
|
||||
if _, err := conn.Write([]byte(header)); err != nil {
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error writing header")
|
||||
}
|
||||
if _, err := conn.Write([]byte("GET / HTTP/1.1\r\nHost: proxy-protocol\r\n\r\n")); err != nil {
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error writing request")
|
||||
}
|
||||
|
||||
data, err := io.ReadAll(conn)
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error reading connection data")
|
||||
|
|
@ -96,8 +100,12 @@ var _ = framework.DescribeSetting("use-proxy-protocol", func() {
|
|||
defer conn.Close()
|
||||
|
||||
header := "PROXY TCP4 192.168.0.1 192.168.0.11 56324 443\r\n"
|
||||
conn.Write([]byte(header))
|
||||
conn.Write([]byte("GET / HTTP/1.1\r\nHost: proxy-protocol\r\n\r\n"))
|
||||
if _, err := conn.Write([]byte(header)); err != nil {
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error writing header")
|
||||
}
|
||||
if _, err := conn.Write([]byte("GET / HTTP/1.1\r\nHost: proxy-protocol\r\n\r\n")); err != nil {
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error writing request")
|
||||
}
|
||||
|
||||
data, err := io.ReadAll(conn)
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error reading connection data")
|
||||
|
|
@ -205,9 +213,12 @@ var _ = framework.DescribeSetting("use-proxy-protocol", func() {
|
|||
defer conn.Close()
|
||||
|
||||
header := "PROXY TCP4 192.168.0.1 192.168.0.11 56324 8080\r\n"
|
||||
conn.Write([]byte(header))
|
||||
conn.Write([]byte("GET / HTTP/1.1\r\nHost: proxy-protocol\r\n\r\n"))
|
||||
|
||||
if _, err := conn.Write([]byte(header)); err != nil {
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error writing header")
|
||||
}
|
||||
if _, err := conn.Write([]byte("GET / HTTP/1.1\r\nHost: proxy-protocol\r\n\r\n")); err != nil {
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error writing request")
|
||||
}
|
||||
_, err = io.ReadAll(conn)
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error reading connection data")
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,9 @@ var _ = framework.IngressNginxDescribe("[SSL] secret update", func() {
|
|||
|
||||
dummySecret.Data["some-key"] = []byte("some value")
|
||||
|
||||
f.KubeClientSet.CoreV1().Secrets(f.Namespace).Update(context.TODO(), dummySecret, metav1.UpdateOptions{})
|
||||
if _, err := f.KubeClientSet.CoreV1().Secrets(f.Namespace).Update(context.TODO(), dummySecret, metav1.UpdateOptions{}); err != nil {
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "updating secret")
|
||||
}
|
||||
|
||||
assert.NotContains(ginkgo.GinkgoT(), log, fmt.Sprintf("starting syncing of secret %v/dummy", f.Namespace))
|
||||
assert.NotContains(ginkgo.GinkgoT(), log, fmt.Sprintf("error obtaining PEM from secret %v/dummy", f.Namespace))
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ var _ = framework.IngressNginxDescribe("[Status] status update", func() {
|
|||
|
||||
f.NewEchoDeployment()
|
||||
|
||||
ing := f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil))
|
||||
f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil))
|
||||
|
||||
f.WaitForNginxConfiguration(
|
||||
func(cfg string) bool {
|
||||
|
|
@ -84,7 +84,7 @@ var _ = framework.IngressNginxDescribe("[Status] status update", func() {
|
|||
err = cmd.Process.Kill()
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error terminating kubectl proxy")
|
||||
|
||||
ing, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{})
|
||||
ing, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{})
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "unexpected error getting %s/%v Ingress", f.Namespace, host)
|
||||
|
||||
ing.Status.LoadBalancer.Ingress = []v1.IngressLoadBalancerIngress{}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue