Set new default PathType to prefix
This commit is contained in:
parent
c552a4f3b1
commit
5d6c096466
1 changed files with 21 additions and 0 deletions
|
@ -950,11 +950,15 @@ func toIngress(obj interface{}) (*networkingv1beta1.Ingress, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ing.Spec.IngressClassName = extractClassName(ing)
|
ing.Spec.IngressClassName = extractClassName(ing)
|
||||||
|
setDefaultPathTypeIfEmpty(ing)
|
||||||
|
|
||||||
return ing, true
|
return ing, true
|
||||||
}
|
}
|
||||||
|
|
||||||
if ing, ok := obj.(*networkingv1beta1.Ingress); ok {
|
if ing, ok := obj.(*networkingv1beta1.Ingress); ok {
|
||||||
ing.Spec.IngressClassName = extractClassName(ing)
|
ing.Spec.IngressClassName = extractClassName(ing)
|
||||||
|
setDefaultPathTypeIfEmpty(ing)
|
||||||
|
|
||||||
return ing, true
|
return ing, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -968,3 +972,20 @@ func extractClassName(ing *networkingv1beta1.Ingress) *string {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default path type is Prefix to not break existing definitions
|
||||||
|
var defaultPathType = networkingv1beta1.PathTypePrefix
|
||||||
|
|
||||||
|
func setDefaultPathTypeIfEmpty(ing *networkingv1beta1.Ingress) {
|
||||||
|
for _, rule := range ing.Spec.Rules {
|
||||||
|
if rule.IngressRuleValue.HTTP == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, path := range rule.IngressRuleValue.HTTP.Paths {
|
||||||
|
if path.PathType == nil {
|
||||||
|
path.PathType = &defaultPathType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue