From 4a2146b8dc4fa92d5024a314055a6573cc8283ac Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Thu, 12 Jan 2017 19:00:42 -0300 Subject: [PATCH] Address comments about consistency in the code --- core/pkg/ingress/annotations/authtls/main.go | 10 +++++++++- core/pkg/ingress/controller/annotations.go | 15 ++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/core/pkg/ingress/annotations/authtls/main.go b/core/pkg/ingress/annotations/authtls/main.go index 415b079c8..143353249 100644 --- a/core/pkg/ingress/annotations/authtls/main.go +++ b/core/pkg/ingress/annotations/authtls/main.go @@ -17,6 +17,7 @@ limitations under the License. package authtls import ( + "github.com/pkg/errors" "k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/ingress/core/pkg/ingress/annotations/parser" @@ -56,5 +57,12 @@ func (a authTLS) Parse(ing *extensions.Ingress) (interface{}, error) { return nil, ing_errors.NewLocationDenied("an empty string is not a valid secret name") } - return a.certResolver.GetAuthCertificate(str) + authCert, err := a.certResolver.GetAuthCertificate(str) + if err != nil { + return nil, ing_errors.LocationDenied{ + Reason: errors.Wrap(err, "error obtaining certificate"), + } + } + + return authCert, nil } diff --git a/core/pkg/ingress/controller/annotations.go b/core/pkg/ingress/controller/annotations.go index 27c0baf1a..00f62f7f5 100644 --- a/core/pkg/ingress/controller/annotations.go +++ b/core/pkg/ingress/controller/annotations.go @@ -71,16 +71,17 @@ func (e *annotationExtractor) Extract(ing *extensions.Ingress) map[string]interf val, err := annotationParser.Parse(ing) glog.V(5).Infof("annotation %v in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), val) if err != nil { - _, de := anns["Denied"] - if errors.IsLocationDenied(err) && !de { - anns["Denied"] = err - glog.Errorf("error reading %v annotation in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), err) - continue - } - if !errors.IsMissingAnnotations(err) { + if errors.IsMissingAnnotations(err) { + continue + } + + _, alreadyDenied := anns[DeniedKeyName] + if !alreadyDenied { + anns[DeniedKeyName] = err glog.Errorf("error reading %v annotation in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), err) continue } + glog.V(5).Infof("error reading %v annotation in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), err) }