From 42bea9880c50e88fc9fc544320c64573f66086c8 Mon Sep 17 00:00:00 2001 From: Justin Nauman Date: Fri, 25 Jan 2019 11:05:43 -0600 Subject: [PATCH] Adjusting error messages for emergent linting issues (#185) --- Makefile | 2 ++ iam/arn.go | 2 +- k8s/k8s.go | 4 ++-- mappings/mapper.go | 4 ++-- mappings/mapper_test.go | 2 +- namespace.go | 2 +- server/server.go | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 904ee7cc..eb24f050 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,8 @@ check-all: --linter='vet:govet --no-recurse:PATH:LINE:MESSAGE' --dupl-threshold=50 --dupl-threshold=50 +travis-checks: build test-race check bench-race + watch: CompileDaemon -color=true -build "make test" diff --git a/iam/arn.go b/iam/arn.go index 212c7468..8665ee3f 100644 --- a/iam/arn.go +++ b/iam/arn.go @@ -45,7 +45,7 @@ func GetBaseArn() (string, error) { arn := strings.Replace(iamInfo.InstanceProfileArn, "instance-profile", "role", 1) baseArn := strings.Split(arn, "/") if len(baseArn) < 2 { - return "", fmt.Errorf("Can't determine BaseARN") + return "", fmt.Errorf("can't determine BaseARN") } return fmt.Sprintf("%s/", baseArn[0]), nil } diff --git a/k8s/k8s.go b/k8s/k8s.go index 64d018f0..40320212 100644 --- a/k8s/k8s.go +++ b/k8s/k8s.go @@ -93,7 +93,7 @@ func (k8s *Client) PodByIP(IP string) (*v1.Pod, error) { } if len(pods) == 0 { - return nil, fmt.Errorf("Pod with specificed IP not found") + return nil, fmt.Errorf("pod with specificed IP not found") } if len(pods) == 1 { @@ -117,7 +117,7 @@ func (k8s *Client) NamespaceByName(namespaceName string) (*v1.Namespace, error) } if len(namespace) == 0 { - return nil, fmt.Errorf("Namespace was not found") + return nil, fmt.Errorf("namespace was not found") } return namespace[0].(*v1.Namespace), nil diff --git a/mappings/mapper.go b/mappings/mapper.go index 321e6e2d..a52b234d 100644 --- a/mappings/mapper.go +++ b/mappings/mapper.go @@ -56,7 +56,7 @@ func (r *RoleMapper) GetRoleMapping(IP string) (*RoleMappingResult, error) { return &RoleMappingResult{Role: role, Namespace: pod.GetNamespace(), IP: IP}, nil } - return nil, fmt.Errorf("Role requested %s not valid for namespace of pod at %s with namespace %s", role, IP, pod.GetNamespace()) + return nil, fmt.Errorf("role requested %s not valid for namespace of pod at %s with namespace %s", role, IP, pod.GetNamespace()) } // extractQualifiedRoleName extracts a fully qualified ARN for a given pod, @@ -66,7 +66,7 @@ func (r *RoleMapper) extractRoleARN(pod *v1.Pod) (string, error) { rawRoleName, annotationPresent := pod.GetAnnotations()[r.iamRoleKey] if !annotationPresent && r.defaultRoleARN == "" { - return "", fmt.Errorf("Unable to find role for IP %s", pod.Status.PodIP) + return "", fmt.Errorf("unable to find role for IP %s", pod.Status.PodIP) } if !annotationPresent { diff --git a/mappings/mapper_test.go b/mappings/mapper_test.go index cfda91fc..1d7e9a86 100644 --- a/mappings/mapper_test.go +++ b/mappings/mapper_test.go @@ -392,5 +392,5 @@ func (k *storeMock) NamespaceByName(ns string) (*v1.Namespace, error) { nns.Annotations = k.annotations return nns, nil } - return nil, fmt.Errorf("Namepsace isn't present") + return nil, fmt.Errorf("namespace isn't present") } diff --git a/namespace.go b/namespace.go index 71b90a84..5860d7eb 100644 --- a/namespace.go +++ b/namespace.go @@ -81,7 +81,7 @@ func GetNamespaceRoleAnnotation(ns *v1.Namespace, namespaceKey string) []string func NamespaceIndexFunc(obj interface{}) ([]string, error) { namespace, ok := obj.(*v1.Namespace) if !ok { - return nil, fmt.Errorf("Expected namespace but recieved: %+v", obj) + return nil, fmt.Errorf("expected namespace but received: %+v", obj) } return []string{namespace.GetName()}, nil diff --git a/server/server.go b/server/server.go index 4d13ace6..1300439c 100644 --- a/server/server.go +++ b/server/server.go @@ -129,7 +129,7 @@ func (h *appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { case error: err = t default: - err = errors.New("Unknown error") + err = errors.New("unknown error") } logger.WithField("res.status", http.StatusInternalServerError). Errorf("PANIC error processing request: %+v", err)