Refactor ingress validation in webhook

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-04-28 11:14:27 -04:00
parent c8eb914d8a
commit af910a16d4
7 changed files with 96 additions and 86 deletions

View file

@ -662,20 +662,11 @@ func (s *k8sStore) syncIngress(ing *networkingv1beta1.Ingress) {
if path.Path == "" {
copyIng.Spec.Rules[ri].HTTP.Paths[pi].Path = "/"
}
if path.PathType == nil {
copyIng.Spec.Rules[ri].HTTP.Paths[pi].PathType = &defaultPathType
continue
}
// PathType ImplementationSpecific is not supported.
// Set type to PathTypePrefix.
if *path.PathType == networkingv1beta1.PathTypeImplementationSpecific {
copyIng.Spec.Rules[ri].HTTP.Paths[pi].PathType = &defaultPathType
}
}
}
k8s.SetDefaultNGINXPathType(copyIng)
err := s.listers.IngressWithAnnotation.Update(&ingress.Ingress{
Ingress: *copyIng,
ParsedAnnotations: s.annotations.Extract(ing),
@ -963,12 +954,12 @@ func toIngress(obj interface{}) (*networkingv1beta1.Ingress, bool) {
return nil, false
}
k8s.SetDefaultPathTypeIfEmpty(ing)
k8s.SetDefaultNGINXPathType(ing)
return ing, true
}
if ing, ok := obj.(*networkingv1beta1.Ingress); ok {
k8s.SetDefaultPathTypeIfEmpty(ing)
k8s.SetDefaultNGINXPathType(ing)
return ing, true
}