Skip to content

Commit

Permalink
Adjusting error messages for emergent linting issues (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrnt30 committed Jan 25, 2019
1 parent 060b30b commit 42bea98
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion iam/arn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mappings/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion mappings/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 42bea98

Please sign in to comment.