Update Gateway API version to v0.3.0

Co-authored-by: Tom Moulard <tom.moulard@traefik.io>
This commit is contained in:
Jean-Baptiste Doumenjou 2021-07-15 17:20:08 +02:00 committed by GitHub
parent 6ae50389e6
commit 16f65f669b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 3634 additions and 1404 deletions

View file

@ -9,12 +9,15 @@ import (
"github.com/traefik/traefik/v2/pkg/config/dynamic"
"github.com/traefik/traefik/v2/pkg/provider"
"github.com/traefik/traefik/v2/pkg/tls"
"k8s.io/utils/pointer"
"sigs.k8s.io/gateway-api/apis/v1alpha1"
)
var _ provider.Provider = (*Provider)(nil)
func Bool(v bool) *bool { return &v }
func PMT(p v1alpha1.PathMatchType) *v1alpha1.PathMatchType { return &p }
func HMT(h v1alpha1.HeaderMatchType) *v1alpha1.HeaderMatchType { return &h }
func TestLoadHTTPRoutes(t *testing.T) {
testCases := []struct {
@ -526,7 +529,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.2:80",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
},
@ -616,7 +619,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.2:80",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
},
@ -672,7 +675,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.2:80",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
},
@ -736,7 +739,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.2:80",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
},
@ -791,7 +794,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.2:80",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
},
@ -846,7 +849,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.2:80",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
},
@ -916,7 +919,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.2:80",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
"default-whoami2-8080": {
@ -929,7 +932,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.4:8080",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
},
@ -988,7 +991,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.2:80",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
"default-whoami2-8080": {
@ -1001,7 +1004,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.4:8080",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
},
@ -1077,7 +1080,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.2:80",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
},
@ -1162,7 +1165,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.2:80",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
},
@ -1241,7 +1244,7 @@ func TestLoadHTTPRoutes(t *testing.T) {
URL: "http://10.10.0.2:80",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
},
@ -2727,7 +2730,7 @@ func TestLoadMixedRoutes(t *testing.T) {
URL: "http://10.10.0.2:80",
},
},
PassHostHeader: Bool(true),
PassHostHeader: pointer.Bool(true),
},
},
},
@ -2936,14 +2939,88 @@ func TestExtractRule(t *testing.T) {
hostRule: "Host(`foo.com`)",
expectedRule: "Host(`foo.com`) && PathPrefix(`/`)",
},
{
desc: "One HTTPRouteMatch with nil HTTPHeaderMatch",
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{Headers: nil},
},
},
expectedRule: "",
},
{
desc: "One HTTPRouteMatch with nil HTTPHeaderMatch Type",
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{
Headers: &v1alpha1.HTTPHeaderMatch{
Type: nil,
Values: map[string]string{"foo": "bar"},
},
},
},
},
expectedRule: "",
},
{
desc: "One HTTPRouteMatch with nil HTTPHeaderMatch Values",
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{
Headers: &v1alpha1.HTTPHeaderMatch{
Type: HMT(v1alpha1.HeaderMatchExact),
Values: nil,
},
},
},
},
expectedRule: "",
},
{
desc: "One HTTPRouteMatch with nil HTTPPathMatch",
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{Path: nil},
},
},
expectedRule: "",
},
{
desc: "One HTTPRouteMatch with nil HTTPPathMatch Type",
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{
Path: &v1alpha1.HTTPPathMatch{
Type: nil,
Value: pointer.String("/foo/"),
},
},
},
},
expectedRule: "",
},
{
desc: "One HTTPRouteMatch with nil HTTPPathMatch Values",
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{
Path: &v1alpha1.HTTPPathMatch{
Type: PMT(v1alpha1.PathMatchExact),
Value: nil,
},
},
},
},
expectedRule: "",
},
{
desc: "One Path in matches",
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{
Path: v1alpha1.HTTPPathMatch{
Type: v1alpha1.PathMatchExact,
Value: "/foo/",
Path: &v1alpha1.HTTPPathMatch{
Type: PMT(v1alpha1.PathMatchExact),
Value: pointer.String("/foo/"),
},
},
},
@ -2955,15 +3032,15 @@ func TestExtractRule(t *testing.T) {
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{
Path: v1alpha1.HTTPPathMatch{
Type: v1alpha1.PathMatchExact,
Value: "/foo/",
Path: &v1alpha1.HTTPPathMatch{
Type: PMT(v1alpha1.PathMatchExact),
Value: pointer.String("/foo/"),
},
},
{
Path: v1alpha1.HTTPPathMatch{
Type: "unknown",
Value: "/foo/",
Path: &v1alpha1.HTTPPathMatch{
Type: PMT("unknown"),
Value: pointer.String("/foo/"),
},
},
},
@ -2975,9 +3052,9 @@ func TestExtractRule(t *testing.T) {
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{
Path: v1alpha1.HTTPPathMatch{
Type: v1alpha1.PathMatchExact,
Value: "/foo/",
Path: &v1alpha1.HTTPPathMatch{
Type: PMT(v1alpha1.PathMatchExact),
Value: pointer.String("/foo/"),
},
},
{},
@ -2990,14 +3067,14 @@ func TestExtractRule(t *testing.T) {
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{
Path: v1alpha1.HTTPPathMatch{
Type: v1alpha1.PathMatchExact,
Value: "/foo/",
Path: &v1alpha1.HTTPPathMatch{
Type: PMT(v1alpha1.PathMatchExact),
Value: pointer.String("/foo/"),
},
},
{
Headers: &v1alpha1.HTTPHeaderMatch{
Type: v1alpha1.HeaderMatchExact,
Type: HMT(v1alpha1.HeaderMatchExact),
Values: map[string]string{
"my-header": "foo",
},
@ -3012,12 +3089,12 @@ func TestExtractRule(t *testing.T) {
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{
Path: v1alpha1.HTTPPathMatch{
Type: v1alpha1.PathMatchExact,
Value: "/foo/",
Path: &v1alpha1.HTTPPathMatch{
Type: PMT(v1alpha1.PathMatchExact),
Value: pointer.String("/foo/"),
},
Headers: &v1alpha1.HTTPHeaderMatch{
Type: v1alpha1.HeaderMatchExact,
Type: HMT(v1alpha1.HeaderMatchExact),
Values: map[string]string{
"my-header": "foo",
},
@ -3033,12 +3110,12 @@ func TestExtractRule(t *testing.T) {
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{
Path: v1alpha1.HTTPPathMatch{
Type: v1alpha1.PathMatchExact,
Value: "/foo/",
Path: &v1alpha1.HTTPPathMatch{
Type: PMT(v1alpha1.PathMatchExact),
Value: pointer.String("/foo/"),
},
Headers: &v1alpha1.HTTPHeaderMatch{
Type: v1alpha1.HeaderMatchExact,
Type: HMT(v1alpha1.HeaderMatchExact),
Values: map[string]string{
"my-header": "foo",
},
@ -3054,14 +3131,14 @@ func TestExtractRule(t *testing.T) {
routeRule: v1alpha1.HTTPRouteRule{
Matches: []v1alpha1.HTTPRouteMatch{
{
Path: v1alpha1.HTTPPathMatch{
Type: v1alpha1.PathMatchExact,
Value: "/foo/",
Path: &v1alpha1.HTTPPathMatch{
Type: PMT(v1alpha1.PathMatchExact),
Value: pointer.String("/foo/"),
},
},
{
Headers: &v1alpha1.HTTPHeaderMatch{
Type: v1alpha1.HeaderMatchExact,
Type: HMT(v1alpha1.HeaderMatchExact),
Values: map[string]string{
"my-header": "foo",
},