@@ -18,6 +18,9 @@ package gce
1818
1919import (
2020 "github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw"
21+ "github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/providers/common"
22+ networkingv1 "k8s.io/api/networking/v1"
23+ "k8s.io/apimachinery/pkg/util/validation/field"
2124)
2225
2326// converter implements the ToGatewayAPI function of i2gw.ResourceConverter interface.
@@ -32,11 +35,37 @@ type converter struct {
3235func newConverter (conf * i2gw.ProviderConf ) converter {
3336 return converter {
3437 conf : conf ,
35- featureParsers : []i2gw.FeatureParser {
36- // The list of feature parsers comes here.
37- },
38+ featureParsers : []i2gw.FeatureParser {},
3839 implementationSpecificOptions : i2gw.ProviderImplementationSpecificOptions {
39- // The list of the implementationSpecific ingress fields options comes here.
40+ ToImplementationSpecificHTTPPathTypeMatch : implementationSpecificHTTPPathTypeMatch ,
4041 },
4142 }
4243}
44+
45+ func (c * converter ) convert (storage * storage ) (i2gw.GatewayResources , field.ErrorList ) {
46+ ingressList := []networkingv1.Ingress {}
47+ for _ , ing := range storage .Ingresses {
48+ ingressList = append (ingressList , * ing )
49+ }
50+
51+ // Convert plain ingress resources to gateway resources, ignoring all
52+ // provider-specific features.
53+ gatewayResources , errs := common .ToGateway (ingressList , c .implementationSpecificOptions )
54+ if len (errs ) > 0 {
55+ return i2gw.GatewayResources {}, errs
56+ }
57+
58+ errs = toGceGatewayClass (ingressList , & gatewayResources )
59+ if len (errs ) > 0 {
60+ return i2gw.GatewayResources {}, errs
61+ }
62+
63+ for _ , parseFeatureFunc := range c .featureParsers {
64+ // Apply the feature parsing function to the gateway resources, one by one.
65+ parseErrs := parseFeatureFunc (ingressList , & gatewayResources )
66+ // Append the parsing errors to the error list.
67+ errs = append (errs , parseErrs ... )
68+ }
69+
70+ return gatewayResources , errs
71+ }
0 commit comments