From b9f14ee57a6aebdb7badb0e89751925b74ba81a6 Mon Sep 17 00:00:00 2001 From: Kevin Dorosh Date: Sun, 20 Dec 2020 22:54:50 -0500 Subject: [PATCH] Update to use new Gloo Edge 1.6 API Signed-off-by: Kevin Dorosh --- pkg/apis/gloo/v1/types.go | 10 +++------- pkg/router/gloo.go | 35 +++++++++++++++++++++-------------- test/gloo/install.sh | 2 +- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/pkg/apis/gloo/v1/types.go b/pkg/apis/gloo/v1/types.go index f372284a..c9f54abc 100644 --- a/pkg/apis/gloo/v1/types.go +++ b/pkg/apis/gloo/v1/types.go @@ -20,16 +20,12 @@ type RouteTableSpec struct { } type Route struct { - Matchers []Matcher `json:"matchers,omitempty"` - Action RouteAction `json:"routeAction,omitempty"` + Matchers []Matcher `json:"matchers,omitempty"` + Action RouteAction `json:"routeAction,omitempty"` + InheritablePathMatchers bool `json:"inheritablePathMatchers,omitempty"` } type Matcher struct { - // only one of Prefix, Exact, Regex may be nonempty - Prefix string `json:"prefix,omitempty"` - Exact string `json:"exact,omitempty"` - Regex string `json:"regex,omitempty"` - Headers []HeaderMatcher `json:"headers,omitempty"` QueryParameterMatchers []QueryParameterMatcher `json:"queryParameters,omitempty"` Methods []string `json:"methods,omitempty"` diff --git a/pkg/router/gloo.go b/pkg/router/gloo.go index 0563cd0c..60638b3e 100644 --- a/pkg/router/gloo.go +++ b/pkg/router/gloo.go @@ -51,13 +51,8 @@ func (gr *GlooRouter) Reconcile(canary *flaggerv1.Canary) error { newSpec := gloov1.RouteTableSpec{ Routes: []gloov1.Route{ { - Matchers: []gloov1.Matcher{ - { - Prefix: "/", - Headers: getHeaderMatchers(canary), - Methods: getMethods(canary), - }, - }, + InheritablePathMatchers: true, + Matchers: getMatchers(canary), Action: gloov1.RouteAction{ Destination: gloov1.MultiDestination{ Destinations: []gloov1.WeightedDestination{ @@ -192,14 +187,9 @@ func (gr *GlooRouter) SetRoutes( routeTable.Spec = gloov1.RouteTableSpec{ Routes: []gloov1.Route{ { + InheritablePathMatchers: true, // eventually inherit from parent, used for A/B rollouts too? - Matchers: []gloov1.Matcher{ - { - Prefix: "/", - Headers: getHeaderMatchers(canary), - Methods: getMethods(canary), - }, - }, + Matchers: getMatchers(canary), Action: gloov1.RouteAction{ Destination: gloov1.MultiDestination{ Destinations: []gloov1.WeightedDestination{ @@ -239,6 +229,23 @@ func (gr *GlooRouter) Finalize(_ *flaggerv1.Canary) error { return nil } +func getMatchers(canary *flaggerv1.Canary) []gloov1.Matcher { + + headerMatchers := getHeaderMatchers(canary) + methods := getMethods(canary) + + if len(headerMatchers) == 0 && len(methods) == 0 { + return nil + } + + return []gloov1.Matcher{ + { + Headers: headerMatchers, + Methods: methods, + }, + } +} + func getHeaderMatchers(canary *flaggerv1.Canary) []gloov1.HeaderMatcher { var headerMatchers []gloov1.HeaderMatcher for _, match := range canary.GetAnalysis().Match { diff --git a/test/gloo/install.sh b/test/gloo/install.sh index 89a2f73a..3b09f90b 100755 --- a/test/gloo/install.sh +++ b/test/gloo/install.sh @@ -2,7 +2,7 @@ set -o errexit -GLOO_VER="1.5.13" +GLOO_VER="1.6.0-beta22" # this can be replaced with 1.6.0 when it's released in two weeks REPO_ROOT=$(git rev-parse --show-toplevel) mkdir -p ${REPO_ROOT}/bin