Skip to content

Commit

Permalink
test(unit): groupPaths func tested
Browse files Browse the repository at this point in the history
Signed-off-by: Mattia Lavacca <[email protected]>
  • Loading branch information
mlavacca committed Dec 7, 2023
1 parent 2c89577 commit ba636b0
Show file tree
Hide file tree
Showing 5 changed files with 540 additions and 7 deletions.
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/google/go-cmp v0.6.0
github.com/spf13/cobra v1.8.0
istio.io/api v1.20.0
github.com/stretchr/testify v1.8.4
k8s.io/api v0.28.4
k8s.io/apimachinery v0.28.4
k8s.io/cli-runtime v0.28.4
Expand All @@ -15,6 +15,11 @@ require (
sigs.k8s.io/gateway-api v0.5.0
)

require (
github.com/pmezard/go-difflib v1.0.0 // indirect
istio.io/api v1.20.0 // indirect
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
Expand Down Expand Up @@ -63,7 +68,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
istio.io/client-go v1.19.0-alpha.1.0.20231130185426-9f1859c8ff42 // indirect
istio.io/client-go v1.19.0-alpha.1.0.20231130185426-9f1859c8ff42
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231113174909-778a5567bc1e // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
5 changes: 0 additions & 5 deletions pkg/i2gw/providers/common/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,6 @@ func (a *ingressAggregator) toHTTPRoutesAndGateways(options i2gw.ProviderImpleme
return httpRoutes, gateways, errors
}

type pathsByMatchGroupType struct {
key string
paths []ingressPath
}

func (rg *ingressRuleGroup) toHTTPRoute(options i2gw.ProviderImplementationSpecificOptions) (gatewayv1beta1.HTTPRoute, field.ErrorList) {
pathsByMatchGroup := groupPaths(rg.rules)
httpRoute := gatewayv1beta1.HTTPRoute{
Expand Down
5 changes: 5 additions & 0 deletions pkg/i2gw/providers/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ func ToBackendRef(ib networkingv1.IngressBackend, path *field.Path) (*gatewayv1b
}, nil
}

type pathsByMatchGroupType struct {
key string
paths []ingressPath
}

func groupPaths(rules []ingressRule) []pathsByMatchGroupType {
// we use a slice instead of a map to preserve rules order
pathsByMatchGroup := []pathsByMatchGroupType{}
Expand Down
Loading

0 comments on commit ba636b0

Please sign in to comment.