Skip to content

Commit

Permalink
Add converter in gce
Browse files Browse the repository at this point in the history
  • Loading branch information
sawsa307 committed Jun 6, 2024
1 parent b0ae0cb commit 5f1d5fd
Show file tree
Hide file tree
Showing 5 changed files with 707 additions and 24 deletions.
34 changes: 29 additions & 5 deletions pkg/i2gw/providers/gce/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package gce

import (
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw"
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/providers/common"
networkingv1 "k8s.io/api/networking/v1"
"k8s.io/apimachinery/pkg/util/validation/field"
)

Expand All @@ -33,15 +35,37 @@ type converter struct {
func newConverter(conf *i2gw.ProviderConf) converter {
return converter{
conf: conf,
featureParsers: []i2gw.FeatureParser{
// The list of feature parsers comes here.
},
featureParsers: []i2gw.FeatureParser{},
implementationSpecificOptions: i2gw.ProviderImplementationSpecificOptions{
// The list of the implementationSpecific ingress fields options comes here.
ToImplementationSpecificHTTPPathTypeMatch: implementationSpecificHTTPPathTypeMatch,
},
}
}

func (c *converter) convert(storage *storage) (i2gw.GatewayResources, field.ErrorList) {
return i2gw.GatewayResources{}, field.ErrorList{}
ingressList := []networkingv1.Ingress{}
for _, ing := range storage.Ingresses {
ingressList = append(ingressList, *ing)
}

// Convert plain ingress resources to gateway resources, ignoring all
// provider-specific features.
gatewayResources, errs := common.ToGateway(ingressList, c.implementationSpecificOptions)
if len(errs) > 0 {
return i2gw.GatewayResources{}, errs
}

errs = setGCEGatewayClasses(ingressList, &gatewayResources)
if len(errs) > 0 {
return i2gw.GatewayResources{}, errs
}

for _, parseFeatureFunc := range c.featureParsers {
// Apply the feature parsing function to the gateway resources, one by one.
parseErrs := parseFeatureFunc(ingressList, &gatewayResources)
// Append the parsing errors to the error list.
errs = append(errs, parseErrs...)
}

return gatewayResources, errs
}
Loading

0 comments on commit 5f1d5fd

Please sign in to comment.