Lint code using staticcheck (#4471)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-08-23 12:08:40 -04:00 committed by GitHub
parent 8f09acac2b
commit fcd3054f13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 32 additions and 41 deletions

View file

@ -432,7 +432,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Auth", func() {
err := f.DeleteDeployment("httpbin")
Expect(err).NotTo(HaveOccurred())
resp, _, errs = gorequest.New().
_, _, errs = gorequest.New().
Get(f.GetURL(framework.HTTP)+fooPath).
Retry(10, 1*time.Second, http.StatusNotFound).
Set("Host", thisHost).

View file

@ -27,8 +27,6 @@ import (
"k8s.io/ingress-nginx/test/e2e/framework"
)
const defaultBackend = "default backend - 404"
var _ = framework.IngressNginxDescribe("Default backend", func() {
f := framework.NewDefaultFramework("default-backend")

View file

@ -93,7 +93,7 @@ func (f *Framework) NewIngressController(namespace string, namespaceOverlay stri
cmd := exec.Command("./wait-for-nginx.sh", namespace, namespaceOverlay)
out, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("Unexpected error waiting for ingress controller deployment: %v.\nLogs:\n%v", err, string(out))
return fmt.Errorf("unexpected error waiting for ingress controller deployment: %v.\nLogs:\n%v", err, string(out))
}
return nil
@ -117,7 +117,7 @@ func (f *Framework) KubectlProxy(port int) (int, *exec.Cmd, error) {
buf := make([]byte, 128)
var n int
if n, err = stdout.Read(buf); err != nil {
return -1, cmd, fmt.Errorf("Failed to read from kubectl proxy stdout: %v", err)
return -1, cmd, fmt.Errorf("failed to read from kubectl proxy stdout: %v", err)
}
output := string(buf[:n])
@ -128,7 +128,7 @@ func (f *Framework) KubectlProxy(port int) (int, *exec.Cmd, error) {
}
}
return -1, cmd, fmt.Errorf("Failed to parse port from proxy stdout: %s", output)
return -1, cmd, fmt.Errorf("failed to parse port from proxy stdout: %s", output)
}
func startCmdAndStreamOutput(cmd *exec.Cmd) (stdout, stderr io.ReadCloser, err error) {

View file

@ -211,7 +211,7 @@ func getIngressNGINXPod(ns string, kubeClientSet kubernetes.Interface) (*core.Po
}
if len(l.Items) == 0 {
return nil, fmt.Errorf("There is no ingress-nginx pods running in namespace %v", ns)
return nil, fmt.Errorf("there is no ingress-nginx pods running in namespace %v", ns)
}
var pod *core.Pod
@ -226,7 +226,7 @@ func getIngressNGINXPod(ns string, kubeClientSet kubernetes.Interface) (*core.Po
}
if pod == nil {
return nil, fmt.Errorf("There is no ingress-nginx pods running in namespace %v", ns)
return nil, fmt.Errorf("there is no ingress-nginx pods running in namespace %v", ns)
}
return pod, nil

View file

@ -277,12 +277,3 @@ func ensureHTTPSRequest(url string, host string, expectedDNSName string) {
Expect(len(resp.TLS.PeerCertificates)).Should(BeNumerically("==", 1))
Expect(resp.TLS.PeerCertificates[0].DNSNames[0]).Should(Equal(expectedDNSName))
}
func getCookie(name string, cookies []*http.Cookie) (*http.Cookie, error) {
for _, cookie := range cookies {
if cookie.Name == name {
return cookie, nil
}
}
return &http.Cookie{}, fmt.Errorf("Cookie does not exist")
}

View file

@ -49,7 +49,7 @@ var _ = framework.IngressNginxDescribe("Configmap change", func() {
f.UpdateNginxConfigMapData(wlKey, wlValue)
checksumRegex := regexp.MustCompile("Configuration checksum:\\s+(\\d+)")
checksumRegex := regexp.MustCompile(`Configuration checksum:\s+(\d+)`)
checksum := ""
f.WaitForNginxConfiguration(

View file

@ -181,7 +181,7 @@ var _ = framework.IngressNginxDescribe("Global External Auth", func() {
err := f.DeleteDeployment("httpbin")
Expect(err).NotTo(HaveOccurred())
resp, _, errs = gorequest.New().
_, _, errs = gorequest.New().
Get(f.GetURL(framework.HTTP)).
Retry(10, 1*time.Second, http.StatusNotFound).
Set("Host", host).

View file

@ -142,7 +142,7 @@ var _ = framework.IngressNginxDescribe("Ingress class", func() {
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
delete(ing.Annotations, "kubernetes.io/ingress.class")
ing = f.EnsureIngress(ing)
f.EnsureIngress(ing)
f.WaitForNginxConfiguration(func(cfg string) bool {
return !strings.Contains(cfg, "server_name foo")

View file

@ -182,7 +182,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() {
framework.WaitForTLS(f.GetURL(framework.HTTPS), tlsConfig)
resp, _, errs := gorequest.New().
Get(fmt.Sprintf(f.GetURL(framework.HTTP))).
Get(f.GetURL(framework.HTTP)).
Retry(10, 1*time.Second, http.StatusNotFound).
RedirectPolicy(noRedirectPolicyFunc).
Set("Host", host).
@ -206,7 +206,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() {
framework.WaitForTLS(f.GetURL(framework.HTTPS), tlsConfig)
resp, _, errs := gorequest.New().
Get(fmt.Sprintf(f.GetURL(framework.HTTP))).
Get(f.GetURL(framework.HTTP)).
Retry(10, 1*time.Second, http.StatusNotFound).
RedirectPolicy(noRedirectPolicyFunc).
Set("Host", host).

View file

@ -57,7 +57,7 @@ var _ = framework.IngressNginxDescribe("Status Update [Status]", func() {
// flags --publish-service and --publish-status-address are mutually exclusive
var index int
for k, v := range args {
if strings.Index(v, "--publish-service") != -1 {
if strings.Contains(v, "--publish-service") {
index = k
break
}