Fix ingress class
This commit is contained in:
parent
f5f9f5e9c8
commit
2ddba72baa
6 changed files with 65 additions and 23 deletions
|
|
@ -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{}) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue