Skip to content

Commit 3414acf

Browse files
committed
Initial Support for Implementation Emitters
Signed-off-by: Daneyon Hansen <[email protected]>
1 parent e79e5af commit 3414acf

File tree

12 files changed

+569
-77
lines changed

12 files changed

+569
-77
lines changed

cmd/print.go

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ import (
4242

4343
// Call init for notifications
4444
_ "github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/notifications"
45+
46+
// Call init function for the implementations
47+
_ "github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/implementations/kgateway"
4548
)
4649

4750
type PrintRunner struct {
@@ -72,6 +75,10 @@ type PrintRunner struct {
7275

7376
// Provider specific flags --<provider>-<flag>.
7477
providerSpecificFlags map[string]*string
78+
79+
// implementations indicates which implementations are used to generate
80+
// implementation-specific (GEP-713 style) resources.
81+
implementations []string
7582
}
7683

7784
// PrintGatewayAPIObjects performs necessary steps to digest and print
@@ -81,14 +88,21 @@ type PrintRunner struct {
8188
func (pr *PrintRunner) PrintGatewayAPIObjects(cmd *cobra.Command, _ []string) error {
8289
err := pr.initializeResourcePrinter()
8390
if err != nil {
84-
return fmt.Errorf("failed to initialize resrouce printer: %w", err)
91+
return fmt.Errorf("failed to initialize resource printer: %w", err)
8592
}
8693
err = pr.initializeNamespaceFilter()
8794
if err != nil {
8895
return fmt.Errorf("failed to initialize namespace filter: %w", err)
8996
}
9097

91-
gatewayResources, notificationTablesMap, err := i2gw.ToGatewayAPIResources(cmd.Context(), pr.namespaceFilter, pr.inputFile, pr.providers, pr.getProviderSpecificFlags())
98+
gatewayResources, notificationTablesMap, err := i2gw.ToGatewayAPIResources(
99+
cmd.Context(),
100+
pr.namespaceFilter,
101+
pr.inputFile,
102+
pr.providers,
103+
pr.getProviderSpecificFlags(),
104+
pr.implementations,
105+
)
92106
if err != nil {
93107
return err
94108
}
@@ -319,6 +333,26 @@ func newPrintCommand() *cobra.Command {
319333
if openAPIExist && len(pr.providers) != 1 {
320334
return fmt.Errorf("openapi3 must be the only provider when specified")
321335
}
336+
337+
// Validate implementations (if any) against registered emitters.
338+
if len(pr.implementations) > 0 {
339+
// Build a list of supported implementations from the registry.
340+
supported := make([]string, 0, len(i2gw.ImplementationEmitters))
341+
for name := range i2gw.ImplementationEmitters {
342+
supported = append(supported, name)
343+
}
344+
345+
for _, impl := range pr.implementations {
346+
if _, ok := i2gw.ImplementationEmitters[impl]; !ok {
347+
return fmt.Errorf(
348+
"unsupported implementation %q; supported implementations are: %s",
349+
impl,
350+
strings.Join(supported, ", "),
351+
)
352+
}
353+
}
354+
}
355+
322356
return nil
323357
},
324358
}
@@ -339,6 +373,13 @@ if specified with --namespace.`)
339373
cmd.Flags().StringSliceVar(&pr.providers, "providers", []string{},
340374
fmt.Sprintf("If present, the tool will try to convert only resources related to the specified providers, supported values are %v.", i2gw.GetSupportedProviders()))
341375

376+
cmd.Flags().StringSliceVar(
377+
&pr.implementations,
378+
"implementations",
379+
[]string{},
380+
"Comma-separated list of implementations for which to generate implementation-specific resources.",
381+
)
382+
342383
pr.providerSpecificFlags = make(map[string]*string)
343384
for provider, flags := range i2gw.GetProviderSpecificFlagDefinitions() {
344385
for _, flag := range flags {

go.mod

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
module github.com/kubernetes-sigs/ingress2gateway
22

3-
go 1.24.0
4-
5-
toolchain go1.24.6
3+
go 1.25.3
64

75
require (
86
github.com/GoogleCloudPlatform/gke-gateway-api v1.3.0
97
github.com/getkin/kin-openapi v0.124.0
108
github.com/google/go-cmp v0.7.0
9+
github.com/kgateway-dev/kgateway/v2 v2.1.1
1110
github.com/kong/kubernetes-ingress-controller/v2 v2.12.3
1211
github.com/olekukonko/tablewriter v0.0.5
1312
github.com/samber/lo v1.39.0
14-
github.com/spf13/cobra v1.9.1
15-
github.com/stretchr/testify v1.11.0
16-
istio.io/api v1.20.0
13+
github.com/spf13/cobra v1.10.1
14+
github.com/stretchr/testify v1.11.1
15+
istio.io/api v1.26.0-alpha.0.0.20251002142010-859b66f07fad
1716
k8s.io/api v0.34.1
1817
k8s.io/apimachinery v0.34.1
1918
k8s.io/cli-runtime v0.34.0
@@ -25,19 +24,19 @@ require (
2524
)
2625

2726
require (
28-
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
27+
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
2928
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
3029
github.com/invopop/yaml v0.2.0 // indirect
31-
github.com/mattn/go-runewidth v0.0.15 // indirect
32-
github.com/moby/term v0.5.0 // indirect
30+
github.com/mattn/go-runewidth v0.0.16 // indirect
31+
github.com/moby/term v0.5.2 // indirect
3332
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
3433
github.com/perimeterx/marshmallow v1.1.5 // indirect
3534
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
36-
github.com/rivo/uniseg v0.2.0 // indirect
35+
github.com/rivo/uniseg v0.4.7 // indirect
3736
github.com/x448/float16 v0.8.4 // indirect
3837
go.yaml.in/yaml/v2 v2.4.2 // indirect
3938
go.yaml.in/yaml/v3 v3.0.4 // indirect
40-
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
39+
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
4140
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
4241
sigs.k8s.io/randfill v1.0.0 // indirect
4342
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
@@ -63,18 +62,18 @@ require (
6362
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6463
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
6564
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
66-
github.com/spf13/pflag v1.0.7 // indirect
67-
golang.org/x/net v0.43.0 // indirect
65+
github.com/spf13/pflag v1.0.10 // indirect
66+
golang.org/x/net v0.44.0 // indirect
6867
golang.org/x/oauth2 v0.30.0 // indirect
69-
golang.org/x/sys v0.35.0 // indirect
70-
golang.org/x/term v0.34.0 // indirect
71-
golang.org/x/text v0.28.0 // indirect
68+
golang.org/x/sys v0.36.0 // indirect
69+
golang.org/x/term v0.35.0 // indirect
70+
golang.org/x/text v0.29.0 // indirect
7271
golang.org/x/time v0.12.0 // indirect
73-
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect
74-
google.golang.org/protobuf v1.36.8
72+
google.golang.org/genproto/googleapis/api v0.0.0-20250811230008-5f3141c8851a // indirect
73+
google.golang.org/protobuf v1.36.10
7574
gopkg.in/inf.v0 v0.9.1 // indirect
7675
gopkg.in/yaml.v3 v3.0.1 // indirect
77-
istio.io/client-go v1.19.0-alpha.1.0.20231130185426-9f1859c8ff42
76+
istio.io/client-go v1.26.0-alpha.0.0.20251002142408-752760d8f171
7877
k8s.io/klog/v2 v2.130.1
7978
k8s.io/kube-openapi v0.0.0-20250814151709-d7b6acb124c3 // indirect
8079
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect

0 commit comments

Comments
 (0)