fix: empty ingress path (#2244)
If the origin ingress rule has no field `path`, the default value will be an empty string which will cause issues when rendering template as other place will use `/` as the default value. Set the default value of path to `/` when retrieve ingress rules from api-server. Thie will fix https://github.com/kubernetes/ingress-nginx/issues/1980
This commit is contained in:
parent
935a5ef2c8
commit
1f93a1ccad
1 changed files with 9 additions and 2 deletions
|
@ -111,6 +111,7 @@ const (
|
||||||
DeleteEvent EventType = "DELETE"
|
DeleteEvent EventType = "DELETE"
|
||||||
// ConfigurationEvent event associated when a configuration object is created or updated
|
// ConfigurationEvent event associated when a configuration object is created or updated
|
||||||
ConfigurationEvent EventType = "CONFIGURATION"
|
ConfigurationEvent EventType = "CONFIGURATION"
|
||||||
|
slash = "/"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Event holds the context of an event
|
// Event holds the context of an event
|
||||||
|
@ -516,7 +517,7 @@ func (s k8sStore) GetService(key string) (*apiv1.Service, error) {
|
||||||
return s.listers.Service.ByKey(key)
|
return s.listers.Service.ByKey(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSecret returns an Ingress using the namespace and name as key
|
// GetIngress returns an Ingress using the namespace and name as key
|
||||||
func (s k8sStore) GetIngress(key string) (*extensions.Ingress, error) {
|
func (s k8sStore) GetIngress(key string) (*extensions.Ingress, error) {
|
||||||
return s.listers.Ingress.ByKey(key)
|
return s.listers.Ingress.ByKey(key)
|
||||||
}
|
}
|
||||||
|
@ -530,7 +531,13 @@ func (s k8sStore) ListIngresses() []*extensions.Ingress {
|
||||||
if !class.IsValid(ing) {
|
if !class.IsValid(ing) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
for ri, rule := range ing.Spec.Rules {
|
||||||
|
for pi, path := range rule.HTTP.Paths {
|
||||||
|
if path.Path == "" {
|
||||||
|
ing.Spec.Rules[ri].HTTP.Paths[pi].Path = slash
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
ingresses = append(ingresses, ing)
|
ingresses = append(ingresses, ing)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue