Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create IR structs, and merge functions for IRs. #188

Merged
merged 10 commits into from
Sep 10, 2024
21 changes: 21 additions & 0 deletions pkg/i2gw/ir/provider_apisix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2024 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package ir

type ApisixGatewayIR struct{}
type ApisixHTTPRouteIR struct{}
type ApisixServiceIR struct{}
21 changes: 21 additions & 0 deletions pkg/i2gw/ir/provider_gce.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2024 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package ir

type GceGatewayIR struct{}
type GceHTTPRouteIR struct{}
type GceServiceIR struct{}
21 changes: 21 additions & 0 deletions pkg/i2gw/ir/provider_ingressnginx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2024 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package ir

type IngressNginxGatewayIR struct{}
type IngressNginxHTTPRouteIR struct{}
type IngressNginxServiceIR struct{}
21 changes: 21 additions & 0 deletions pkg/i2gw/ir/provider_istio.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2024 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package ir

type IstioGatewayIR struct{}
type IstioHTTPRouteIR struct{}
type IstioServiceIR struct{}
21 changes: 21 additions & 0 deletions pkg/i2gw/ir/provider_kong.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2024 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package ir

type KongGatewayIR struct{}
type KongHTTPRouteIR struct{}
type KongServiceIR struct{}
21 changes: 21 additions & 0 deletions pkg/i2gw/ir/provider_openapi3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2024 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package ir

type Openapi3GatewayIR struct{}
type Openapi3HTTPRouteIR struct{}
type Openapi3ServiceIR struct{}
67 changes: 67 additions & 0 deletions pkg/i2gw/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"sync"

"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/ir"
networkingv1 "k8s.io/api/networking/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/validation/field"
Expand Down Expand Up @@ -101,6 +102,72 @@ type GatewayResources struct {
ReferenceGrants map[types.NamespacedName]gatewayv1beta1.ReferenceGrant
}

// IR holds specifications of Gateway Objects for supporting Ingress extensions,
// annotations, and proprietary API features not supported as Gateway core
// features. An IR field can be mapped to core Gateway-API fields,
// or provider-specific Gateway extensions.
type IR struct {
Gateways map[types.NamespacedName]GatewayContext
HTTPRoutes map[types.NamespacedName]HTTPRouteContext
Services map[types.NamespacedName]*ServiceIR

GatewayClasses map[types.NamespacedName]gatewayv1.GatewayClass
TLSRoutes map[types.NamespacedName]gatewayv1alpha2.TLSRoute
TCPRoutes map[types.NamespacedName]gatewayv1alpha2.TCPRoute
UDPRoutes map[types.NamespacedName]gatewayv1alpha2.UDPRoute

ReferenceGrants map[types.NamespacedName]gatewayv1beta1.ReferenceGrant
}

// GatewayContext contains the Gateway-API Gateway object and GatewayIR, which
// has a dedicated field for each provider to specify their extension features
// on Gateways.
// The IR will contain necessary information to construct the Gateway
// extensions, but not the extensions themselves.
type GatewayContext struct {
gatewayv1.Gateway
GatewayIR
}

type GatewayIR struct {
LiorLieberman marked this conversation as resolved.
Show resolved Hide resolved
Apisix *ir.ApisixGatewayIR
Gce *ir.GceGatewayIR
IngressNginx *ir.IngressNginxGatewayIR
Istio *ir.IstioGatewayIR
Kong *ir.KongGatewayIR
Openapi3 *ir.Openapi3GatewayIR
}

// HTTPRouteContext contains the Gateway-API HTTPRoute object and HTTPRouteIR,
// which has a dedicated field for each provider to specify their extension
// features on HTTPRoutes.
// The IR will contain necessary information to construct the HTTPRoute
// extensions, but not the extensions themselves.
type HTTPRouteContext struct {
gatewayv1.HTTPRoute
HTTPRouteIR
}

type HTTPRouteIR struct {
Apisix *ir.ApisixHTTPRouteIR
Gce *ir.GceHTTPRouteIR
IngressNginx *ir.IngressNginxHTTPRouteIR
Istio *ir.IstioHTTPRouteIR
Kong *ir.KongHTTPRouteIR
Openapi3 *ir.Openapi3HTTPRouteIR
}

// ServiceIR contains a dedicated field for each provider to specify their
// extension features on Service.
type ServiceIR struct {
Apisix *ir.ApisixServiceIR
Gce *ir.GceServiceIR
IngressNginx *ir.IngressNginxServiceIR
Istio *ir.IstioServiceIR
Kong *ir.KongServiceIR
Openapi3 *ir.Openapi3ServiceIR
}
LiorLieberman marked this conversation as resolved.
Show resolved Hide resolved

// FeatureParser is a function that reads the Ingresses, and applies
// the appropriate modifications to the GatewayResources.
//
Expand Down