Fix ingress class

This commit is contained in:
Giancarlo Rubio 2017-03-02 16:50:31 +01:00
parent f5f9f5e9c8
commit 2ddba72baa
6 changed files with 65 additions and 23 deletions

View file

@ -88,20 +88,26 @@ func matchHostnames(pattern, host string) bool {
// IsValidClass returns true if the given Ingress either doesn't specify
// the ingress.class annotation, or it's set to the configured in the
// ingress controller.
func IsValidClass(ing *extensions.Ingress, class string) bool {
if class == "" {
return true
}
func IsValidClass(ing *extensions.Ingress, config *Configuration) bool {
currentIngClass := config.IngressClass
cc, err := parser.GetStringAnnotation(ingressClassKey, ing)
if err != nil && !errors.IsMissingAnnotations(err) {
glog.Warningf("unexpected error reading ingress annotation: %v", err)
}
if cc == "" {
// we have 2 valid combinations
// 1 - ingress with default class | blank annotation on ingress
// 2 - ingress with specific class | same annotation on ingress
//
// and 2 invalid combinations
// 3 - ingress with default class | fixed annotation on ingress
// 4 - ingress with specific class | different annotation on ingress
if (cc == "" && currentIngClass == "") || (currentIngClass == config.DefaultIngressClass) {
return true
}
return cc == class
return cc == currentIngClass
}
func mergeLocationAnnotations(loc *ingress.Location, anns map[string]interface{}) {