Skip to content

Commit

Permalink
Updating the ingress wrapper so that it doesn't append paths in case …
Browse files Browse the repository at this point in the history
…the servicePort of ingress is a name like ~> 'servicePort: web' and the path has a wildcard character at the end like ~> 'path: /*'
  • Loading branch information
ChandraPrakash committed Nov 21, 2018
1 parent 835e243 commit 7bc7e9b
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions pkg/kube/wrappers/ingress-wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"log"
"net/url"
"path"
"strings"

"github.com/stakater/IngressMonitorController/pkg/constants"
"k8s.io/api/extensions/v1beta1"
Expand Down Expand Up @@ -59,21 +60,26 @@ func (iw *IngressWrapper) getIngressSubPathWithPort() string {
return port + subPath
}

func (iw *IngressWrapper) getIngressPort() string {
rule := iw.Ingress.Spec.Rules[0]
if rule.HTTP != nil {
if rule.HTTP.Paths != nil && len(rule.HTTP.Paths) > 0 {
return rule.HTTP.Paths[0].Backend.ServicePort.StrVal
}
}
return ""
}
// func (iw *IngressWrapper) getIngressPort() string {
// rule := iw.Ingress.Spec.Rules[0]
// if rule.HTTP != nil {
// if rule.HTTP.Paths != nil && len(rule.HTTP.Paths) > 0 {
// return rule.HTTP.Paths[0].Backend.ServicePort.StrVal
// }
// }
// return ""
// }

func (iw *IngressWrapper) getIngressSubPath() string {
rule := iw.Ingress.Spec.Rules[0]
if rule.HTTP != nil {
if rule.HTTP.Paths != nil && len(rule.HTTP.Paths) > 0 {
return rule.HTTP.Paths[0].Path
if strings.ContainsAny(rule.HTTP.Paths[0].Path, "*") {
return strings.TrimRight(rule.HTTP.Paths[0].Path, "*")
}
else {
return rule.HTTP.Paths[0].Path
}
}
}
return ""
Expand Down

0 comments on commit 7bc7e9b

Please sign in to comment.