Apply gometalinter suggestions

This commit is contained in:
Manuel de Brito Fontes 2018-04-25 18:53:49 -03:00
parent 9533aa45cc
commit 9bf553559c
8 changed files with 19 additions and 32 deletions

View file

@ -135,9 +135,5 @@ func restoreAsset(dir, name string, fs Filesystem) error {
//Missing info.Mode() //Missing info.Mode()
err = fs.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) return fs.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
if err != nil {
return err
}
return nil
} }

View file

@ -37,7 +37,6 @@ var (
annotationPassthrough = parser.GetAnnotationWithPrefix("ssl-passthrough") annotationPassthrough = parser.GetAnnotationWithPrefix("ssl-passthrough")
annotationAffinityType = parser.GetAnnotationWithPrefix("affinity") annotationAffinityType = parser.GetAnnotationWithPrefix("affinity")
annotationCorsEnabled = parser.GetAnnotationWithPrefix("enable-cors") annotationCorsEnabled = parser.GetAnnotationWithPrefix("enable-cors")
annotationCorsAllowOrigin = parser.GetAnnotationWithPrefix("cors-allow-origin")
annotationCorsAllowMethods = parser.GetAnnotationWithPrefix("cors-allow-methods") annotationCorsAllowMethods = parser.GetAnnotationWithPrefix("cors-allow-methods")
annotationCorsAllowHeaders = parser.GetAnnotationWithPrefix("cors-allow-headers") annotationCorsAllowHeaders = parser.GetAnnotationWithPrefix("cors-allow-headers")
annotationCorsAllowCredentials = parser.GetAnnotationWithPrefix("cors-allow-credentials") annotationCorsAllowCredentials = parser.GetAnnotationWithPrefix("cors-allow-credentials")

View file

@ -121,17 +121,17 @@ func (a authReq) Parse(ing *extensions.Ingress) (interface{}, error) {
return nil, ing_errors.NewLocationDenied("an empty string is not a valid URL") return nil, ing_errors.NewLocationDenied("an empty string is not a valid URL")
} }
authUrl, err := url.Parse(urlString) authURL, err := url.Parse(urlString)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if authUrl.Scheme == "" { if authURL.Scheme == "" {
return nil, ing_errors.NewLocationDenied("url scheme is empty") return nil, ing_errors.NewLocationDenied("url scheme is empty")
} }
if authUrl.Host == "" { if authURL.Host == "" {
return nil, ing_errors.NewLocationDenied("url host is empty") return nil, ing_errors.NewLocationDenied("url host is empty")
} }
if strings.Contains(authUrl.Host, "..") { if strings.Contains(authURL.Host, "..") {
return nil, ing_errors.NewLocationDenied("invalid url host") return nil, ing_errors.NewLocationDenied("invalid url host")
} }
@ -162,7 +162,7 @@ func (a authReq) Parse(ing *extensions.Ingress) (interface{}, error) {
return &Config{ return &Config{
URL: urlString, URL: urlString,
Host: authUrl.Hostname(), Host: authURL.Hostname(),
SigninURL: signIn, SigninURL: signIn,
Method: authMethod, Method: authMethod,
ResponseHeaders: responseHeaders, ResponseHeaders: responseHeaders,

View file

@ -73,7 +73,6 @@ const (
var ( var (
tmplPath = "/etc/nginx/template/nginx.tmpl" tmplPath = "/etc/nginx/template/nginx.tmpl"
geoipPath = "/etc/nginx/geoip"
cfgPath = "/etc/nginx/nginx.conf" cfgPath = "/etc/nginx/nginx.conf"
nginxBinary = "/usr/sbin/nginx" nginxBinary = "/usr/sbin/nginx"
) )
@ -158,8 +157,7 @@ func NewNGINXController(config *Configuration, fs file.Filesystem) *NGINXControl
glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)") glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)")
} }
var onTemplateChange func() onTemplateChange := func() {
onTemplateChange = func() {
template, err := ngx_template.NewTemplate(tmplPath, fs) template, err := ngx_template.NewTemplate(tmplPath, fs)
if err != nil { if err != nil {
// this error is different from the rest because it must be clear why nginx is not working // this error is different from the rest because it must be clear why nginx is not working

View file

@ -530,39 +530,39 @@ func TestBuildDenyVariable(t *testing.T) {
func TestBuildClientBodyBufferSize(t *testing.T) { func TestBuildClientBodyBufferSize(t *testing.T) {
a := isValidClientBodyBufferSize("1000") a := isValidClientBodyBufferSize("1000")
if a != true { if !a {
t.Errorf("Expected '%v' but returned '%v'", true, a) t.Errorf("Expected '%v' but returned '%v'", true, a)
} }
b := isValidClientBodyBufferSize("1000k") b := isValidClientBodyBufferSize("1000k")
if b != true { if !b {
t.Errorf("Expected '%v' but returned '%v'", true, b) t.Errorf("Expected '%v' but returned '%v'", true, b)
} }
c := isValidClientBodyBufferSize("1000m") c := isValidClientBodyBufferSize("1000m")
if c != true { if !c {
t.Errorf("Expected '%v' but returned '%v'", true, c) t.Errorf("Expected '%v' but returned '%v'", true, c)
} }
d := isValidClientBodyBufferSize("1000km") d := isValidClientBodyBufferSize("1000km")
if d != false { if d {
t.Errorf("Expected '%v' but returned '%v'", false, d) t.Errorf("Expected '%v' but returned '%v'", false, d)
} }
e := isValidClientBodyBufferSize("1000mk") e := isValidClientBodyBufferSize("1000mk")
if e != false { if e {
t.Errorf("Expected '%v' but returned '%v'", false, e) t.Errorf("Expected '%v' but returned '%v'", false, e)
} }
f := isValidClientBodyBufferSize("1000kk") f := isValidClientBodyBufferSize("1000kk")
if f != false { if f {
t.Errorf("Expected '%v' but returned '%v'", false, f) t.Errorf("Expected '%v' but returned '%v'", false, f)
} }
g := isValidClientBodyBufferSize("1000mm") g := isValidClientBodyBufferSize("1000mm")
if g != false { if g {
t.Errorf("Expected '%v' but returned '%v'", false, g) t.Errorf("Expected '%v' but returned '%v'", false, g)
} }
h := isValidClientBodyBufferSize(nil) h := isValidClientBodyBufferSize(nil)
if h != false { if h {
t.Errorf("Expected '%v' but returned '%v'", false, h) t.Errorf("Expected '%v' but returned '%v'", false, h)
} }
i := isValidClientBodyBufferSize("") i := isValidClientBodyBufferSize("")
if i != false { if i {
t.Errorf("Expected '%v' but returned '%v'", false, i) t.Errorf("Expected '%v' but returned '%v'", false, i)
} }
} }

View file

@ -20,12 +20,6 @@ import (
"testing" "testing"
) )
type fakeError struct{}
func (fe *fakeError) Error() string {
return "fakeError"
}
func TestSysctlFSFileMax(t *testing.T) { func TestSysctlFSFileMax(t *testing.T) {
i := sysctlFSFileMax() i := sysctlFSFileMax()
if i < 1 { if i < 1 {

View file

@ -130,7 +130,7 @@ func DeleteKubeNamespace(c kubernetes.Interface, namespace string) error {
return c.CoreV1().Namespaces().Delete(namespace, metav1.NewDeleteOptions(0)) return c.CoreV1().Namespaces().Delete(namespace, metav1.NewDeleteOptions(0))
} }
// ExpectNoError tests whether an error occured. // ExpectNoError tests whether an error occurred.
func ExpectNoError(err error, explain ...interface{}) { func ExpectNoError(err error, explain ...interface{}) {
if err != nil { if err != nil {
Logf("Unexpected error occurred: %v", err) Logf("Unexpected error occurred: %v", err)