Skip to content

Commit

Permalink
Merge pull request #2121 from pubudu538/gw-upgrade
Browse files Browse the repository at this point in the history
Upgrade K8s gateway api to v1.0.0
  • Loading branch information
pubudu538 authored Mar 18, 2024
2 parents 7d09198 + 918fde4 commit de64c03
Show file tree
Hide file tree
Showing 30 changed files with 9,122 additions and 6,310 deletions.
38 changes: 19 additions & 19 deletions adapter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ require (
github.com/fsnotify/fsnotify v1.7.0
github.com/golang/protobuf v1.5.3
github.com/google/uuid v1.6.0
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.10
github.com/onsi/ginkgo/v2 v2.14.0
github.com/onsi/gomega v1.30.0
github.com/pelletier/go-toml v1.9.5
github.com/prometheus/client_golang v1.17.0
github.com/prometheus/client_golang v1.18.0
github.com/sirupsen/logrus v1.9.0
github.com/wso2/apk/common-go-libs v0.0.0-20231208100153-24bee7b4bd81
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb
google.golang.org/grpc v1.62.0
google.golang.org/protobuf v1.32.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.28.3
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
sigs.k8s.io/controller-runtime v0.15.0
k8s.io/api v0.29.2
k8s.io/apimachinery v0.29.2
k8s.io/client-go v0.29.2
sigs.k8s.io/controller-runtime v0.17.2
)

require (
Expand All @@ -29,12 +29,12 @@ require (
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
Expand All @@ -56,7 +56,7 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
Expand All @@ -75,21 +75,21 @@ require (
golang.org/x/term v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.16.0 // indirect
golang.org/x/tools v0.16.1 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.28.3 // indirect
k8s.io/component-base v0.28.3 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/apiextensions-apiserver v0.29.2 // indirect
k8s.io/component-base v0.29.2 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

Expand All @@ -102,5 +102,5 @@ require (
github.com/stretchr/testify v1.8.4
golang.org/x/sys v0.17.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1
sigs.k8s.io/gateway-api v0.7.1
sigs.k8s.io/gateway-api v1.0.0
)
98 changes: 40 additions & 58 deletions adapter/go.sum

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions adapter/internal/oasparser/envoyconf/envoyconf_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/wso2/apk/adapter/internal/oasparser/model"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/wrapperspb"
gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
)

func TestCreateRoute(t *testing.T) {
Expand All @@ -62,11 +62,11 @@ func TestCreateRoute(t *testing.T) {
// Creating path rewrite policy
var policies = model.OperationPolicies{}
policyParameters := make(map[string]interface{})
policyParameters[constants.RewritePathType] = gwapiv1b1.PrefixMatchHTTPPathModifier
policyParameters[constants.RewritePathType] = gwapiv1.PrefixMatchHTTPPathModifier
policyParameters[constants.IncludeQueryParams] = true
policyParameters[constants.RewritePathResourcePath] = "/basepath/resourcePath"
policies.Request = append(policies.Request, model.Policy{
PolicyName: string(gwapiv1b1.HTTPRouteFilterURLRewrite),
PolicyName: string(gwapiv1.HTTPRouteFilterURLRewrite),
Action: constants.ActionRewritePath,
Parameters: policyParameters,
})
Expand Down Expand Up @@ -217,148 +217,148 @@ func TestGenerateTLSCert(t *testing.T) {
func TestGenerateRegex(t *testing.T) {

type generateRegexTestItem struct {
pathMatchType gwapiv1b1.PathMatchType
pathMatchType gwapiv1.PathMatchType
resourcePath string
userInputPath string
message string
isMatched bool
}
dataItems := []generateRegexTestItem{
{
pathMatchType: gwapiv1b1.PathMatchRegularExpression,
pathMatchType: gwapiv1.PathMatchRegularExpression,
resourcePath: "/pet/[\\d]{1}",
userInputPath: "/pet/5",
message: "when regex is provided end of the path",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchRegularExpression,
pathMatchType: gwapiv1.PathMatchRegularExpression,
resourcePath: "/pet/[\\d]{1}",
userInputPath: "/pet/5/",
message: "when the input path does not have tailing slash and user input path has trailing slash",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchRegularExpression,
pathMatchType: gwapiv1.PathMatchRegularExpression,
resourcePath: "/pet/[\\d]{1}/",
userInputPath: "/pet/5",
message: "when the input path has tailing slash and user input path does not have trailing slash",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchRegularExpression,
pathMatchType: gwapiv1.PathMatchRegularExpression,
resourcePath: "/pet/[\\d]{1}/",
userInputPath: "/pet/5/",
message: "when both the input path and user input path has trailing slash",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchRegularExpression,
pathMatchType: gwapiv1.PathMatchRegularExpression,
resourcePath: "/pet/[\\d]{1}/info",
userInputPath: "/pet/5/info",
message: "when regex is provided in the middle of the path",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchRegularExpression,
pathMatchType: gwapiv1.PathMatchRegularExpression,
resourcePath: "/pet/[\\d]{1}/tst/[\\d]{1}",
userInputPath: "/pet/5/tst/3",
message: "when multiple regex match sections are provided",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchRegularExpression,
pathMatchType: gwapiv1.PathMatchRegularExpression,
resourcePath: "/pet/[\\d]{1}",
userInputPath: "/pet/5/test",
message: "when path parameter is provided end of the path and provide incorrect path",
isMatched: false,
},
{
pathMatchType: gwapiv1b1.PathMatchExact,
pathMatchType: gwapiv1.PathMatchExact,
resourcePath: "/pet/5",
userInputPath: "/pet/5",
message: "when using an exact match type",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchExact,
pathMatchType: gwapiv1.PathMatchExact,
resourcePath: "/pet/5",
userInputPath: "/pett/5",
message: "when provide a incorrect path with exact match",
isMatched: false,
},
{
pathMatchType: gwapiv1b1.PathMatchExact,
pathMatchType: gwapiv1.PathMatchExact,
resourcePath: "/pet/5",
userInputPath: "/pet/5/",
message: "when using an exact match with a trailing slash in user input only",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchExact,
pathMatchType: gwapiv1.PathMatchExact,
resourcePath: "/pet/5/",
userInputPath: "/pet/5",
message: "when using an exact match with a trailing slash in resource path only",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchExact,
pathMatchType: gwapiv1.PathMatchExact,
resourcePath: "/pet/5/",
userInputPath: "/pet/5/",
message: "when using an exact match with a trailing slash in user input and resource path",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchPathPrefix,
pathMatchType: gwapiv1.PathMatchPathPrefix,
resourcePath: "/pet",
userInputPath: "/pet/",
message: "when using path prefix type match, a single trailing slash is allowed",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchPathPrefix,
pathMatchType: gwapiv1.PathMatchPathPrefix,
resourcePath: "/pet",
userInputPath: "/pet",
message: "when using path prefix type, it can match any value after a single slash",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchPathPrefix,
pathMatchType: gwapiv1.PathMatchPathPrefix,
resourcePath: "/pet",
userInputPath: "/pet/foo/bar",
message: "when using path prefix type, it can match several slash and value sections",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchPathPrefix,
pathMatchType: gwapiv1.PathMatchPathPrefix,
resourcePath: "/pet",
userInputPath: "/pet123",
message: "cannot have a value without starting with a trailing slash",
isMatched: false,
},
{
pathMatchType: gwapiv1b1.PathMatchPathPrefix,
pathMatchType: gwapiv1.PathMatchPathPrefix,
resourcePath: "/pet/[\\d]{1}.api",
userInputPath: "/pet/findByIdstatus=availabe",
message: "when the resource regex section is suffixed",
isMatched: false,
},
{
pathMatchType: gwapiv1b1.PathMatchRegularExpression,
pathMatchType: gwapiv1.PathMatchRegularExpression,
resourcePath: "/pet/[a-z0-9]+.api",
userInputPath: "/pet/pet1.api",
message: "when the resource path param suffixed",
isMatched: true,
},
{
pathMatchType: gwapiv1b1.PathMatchRegularExpression,
pathMatchType: gwapiv1.PathMatchRegularExpression,
resourcePath: "/pet/pet[a-z0-9]+",
userInputPath: "/pet/findByIdstatus=availabe",
message: "when the resource ends with regex section",
isMatched: false,
},
{
pathMatchType: gwapiv1b1.PathMatchRegularExpression,
pathMatchType: gwapiv1.PathMatchRegularExpression,
resourcePath: "/pet/pet[a-z0-9]+",
userInputPath: "/pet/pet1",
message: "when the resource ends with regex section",
Expand All @@ -381,50 +381,50 @@ func TestGenerateRegex(t *testing.T) {

func TestGenerateSubstitutionString(t *testing.T) {
type generateSubsStringTestItem struct {
pathMatchType gwapiv1b1.PathMatchType
pathMatchType gwapiv1.PathMatchType
inputPath string
expectedSubsString string
message string
shouldEqual bool
}
dataItems := []generateSubsStringTestItem{
{
gwapiv1b1.PathMatchExact,
gwapiv1.PathMatchExact,
"/v2/pet/",
"/v2/pet/",
"when using exact type",
true,
},
{
gwapiv1b1.PathMatchPathPrefix,
gwapiv1.PathMatchPathPrefix,
"/v2/pet/",
"/v2/pet\\1",
"when using path prefix type",
true,
},
{
gwapiv1b1.PathMatchRegularExpression,
gwapiv1.PathMatchRegularExpression,
"/v2/pet/(dog-[\\d]{2})",
"\\1",
"when using regex type",
true,
},
{
gwapiv1b1.PathMatchExact,
gwapiv1.PathMatchExact,
"/v2/pet",
"/v2/pet",
"when using exact type without a trailing slash in the path",
true,
},
{
gwapiv1b1.PathMatchPathPrefix,
gwapiv1.PathMatchPathPrefix,
"/v2/pet",
"/v2/pet\\1",
"when using path prefix type without a trailing slash in the path",
true,
},
{
gwapiv1b1.PathMatchRegularExpression,
gwapiv1.PathMatchRegularExpression,
"/v2/pet/(dog-[\\d]{2})/",
"\\1",
"when using regex type with a trailing slash in the path",
Expand Down
Loading

0 comments on commit de64c03

Please sign in to comment.