Update to use new Gloo Edge 1.6 API

Signed-off-by: Kevin Dorosh <kcdorosh@gmail.com>
This commit is contained in:
Kevin Dorosh
2020-12-22 10:09:20 -05:00
parent a3f791be17
commit b9f14ee57a
3 changed files with 25 additions and 22 deletions
+3 -7
View File
@@ -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"`
+21 -14
View File
@@ -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 {
+1 -1
View File
@@ -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