Skip to content

Commit

Permalink
feat: add add path_handling property to KongIngress
Browse files Browse the repository at this point in the history
This was added in kong 2.0.
  • Loading branch information
hbagdi committed Mar 20, 2020
1 parent bec0c00 commit a19f4a0
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 0 deletions.
5 changes: 5 additions & 0 deletions deploy/manifests/base/custom-types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ spec:
type: boolean
preserve_host:
type: boolean
path_handling:
type: string
enum:
- "v0"
- "v1"
protocols:
type: array
items:
Expand Down
5 changes: 5 additions & 0 deletions deploy/single/all-in-one-dbless-k4k8s-enterprise.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ spec:
items:
type: string
type: array
path_handling:
enum:
- v0
- v1
type: string
preserve_host:
type: boolean
protocols:
Expand Down
5 changes: 5 additions & 0 deletions deploy/single/all-in-one-dbless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ spec:
items:
type: string
type: array
path_handling:
enum:
- v0
- v1
type: string
preserve_host:
type: boolean
protocols:
Expand Down
5 changes: 5 additions & 0 deletions deploy/single/all-in-one-postgres-enterprise.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ spec:
items:
type: string
type: array
path_handling:
enum:
- v0
- v1
type: string
preserve_host:
type: boolean
protocols:
Expand Down
5 changes: 5 additions & 0 deletions deploy/single/all-in-one-postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ spec:
items:
type: string
type: array
path_handling:
enum:
- v0
- v1
type: string
preserve_host:
type: boolean
protocols:
Expand Down
5 changes: 5 additions & 0 deletions hack/dev-env/dev-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ spec:
type: boolean
preserve_host:
type: boolean
path_handling:
type: string
enum:
- "v0"
- "v1"
protocols:
type: array
items:
Expand Down
5 changes: 5 additions & 0 deletions internal/ingress/controller/kong.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ func (n *KongController) fillRoute(route *kong.Route) {
route.HTTPSRedirectStatusCode = kong.Int(426)
}
}
if n.cfg.Kong.Version.GTE(kong200version) {
if route.PathHandling == nil {
route.PathHandling = kong.String("v0")
}
}
}

func (n *KongController) fillUpstream(upstream *kong.Upstream) {
Expand Down
3 changes: 3 additions & 0 deletions internal/ingress/controller/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,9 @@ func overrideRouteByKongIngress(route *Route,
if r.HTTPSRedirectStatusCode != nil {
route.HTTPSRedirectStatusCode = kong.Int(*r.HTTPSRedirectStatusCode)
}
if r.PathHandling != nil {
route.PathHandling = kong.String(*r.PathHandling)
}
}

// normalizeProtocols prevents users from mismatching grpc/http
Expand Down
18 changes: 18 additions & 0 deletions internal/ingress/controller/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2635,6 +2635,24 @@ func TestOverrideRoute(t *testing.T) {
},
},
},
{
Route{
Route: kong.Route{
Hosts: kong.StringSlice("foo.com"),
},
},
configurationv1.KongIngress{
Route: &kong.Route{
PathHandling: kong.String("v1"),
},
},
Route{
Route: kong.Route{
Hosts: kong.StringSlice("foo.com"),
PathHandling: kong.String("v1"),
},
},
},
}

for _, testcase := range testTable {
Expand Down

0 comments on commit a19f4a0

Please sign in to comment.