Address comments about consistency in the code

This commit is contained in:
Manuel de Brito Fontes 2017-01-12 19:00:42 -03:00
parent 8191245eee
commit 4a2146b8dc
2 changed files with 17 additions and 8 deletions

View file

@ -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
}

View file

@ -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)
}