Skip to content

Commit

Permalink
fix: empty ingress path (#2244)
Browse files Browse the repository at this point in the history
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 #1980
  • Loading branch information
oilbeater authored and aledbf committed Mar 23, 2018
1 parent 935a5ef commit 1f93a1c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/ingress/controller/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const (
DeleteEvent EventType = "DELETE"
// ConfigurationEvent event associated when a configuration object is created or updated
ConfigurationEvent EventType = "CONFIGURATION"
slash = "/"
)

// Event holds the context of an event
Expand Down Expand Up @@ -516,7 +517,7 @@ func (s k8sStore) GetService(key string) (*apiv1.Service, error) {
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) {
return s.listers.Ingress.ByKey(key)
}
Expand All @@ -530,7 +531,13 @@ func (s k8sStore) ListIngresses() []*extensions.Ingress {
if !class.IsValid(ing) {
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)
}

Expand Down

0 comments on commit 1f93a1c

Please sign in to comment.