Ensure webhook validation ingress has a PathTypePrefix
This commit is contained in:
parent
bae9043171
commit
dbaefc8ee9
3 changed files with 25 additions and 17 deletions
|
|
@ -149,3 +149,22 @@ func NetworkingIngressAvailable(client clientset.Interface) (bool, bool) {
|
|||
|
||||
return runningVersion.AtLeast(version114), runningVersion.AtLeast(version118)
|
||||
}
|
||||
|
||||
// Default path type is Prefix to not break existing definitions
|
||||
var defaultPathType = networkingv1beta1.PathTypePrefix
|
||||
|
||||
// SetDefaultPathTypeIfEmpty sets a default PathType when is not defined.
|
||||
func SetDefaultPathTypeIfEmpty(ing *networkingv1beta1.Ingress) {
|
||||
for _, rule := range ing.Spec.Rules {
|
||||
if rule.IngressRuleValue.HTTP == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for idx := range rule.IngressRuleValue.HTTP.Paths {
|
||||
p := &rule.IngressRuleValue.HTTP.Paths[idx]
|
||||
if p.PathType == nil {
|
||||
p.PathType = &defaultPathType
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue