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 Ingress2gateway version annotation and attach it to all Gateway resources #187

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ a PR. This must go through the regular PR review process and get merged into the
`main` branch. Approval of the PR indicates community consensus for a new
release.

### Update ingress2gateway version in annotation
1. Once the new release version is determined, update `CurrentVersion` in [pkg/i2gw/ingress2gateway.go](pkg/i2gw/ingress2gateway.go) so the translated Gateways will reflect the correct ingress2gateway tool version that generated them.

### Patch a release

1. Create a new branch in your fork named something like `<githubuser>/release-x.x.x`. Use the new branch
Expand Down
24 changes: 24 additions & 0 deletions cmd/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ func (pr *PrintRunner) outputResult(gatewayResources []i2gw.GatewayResources) {
resourceCount += len(r.Gateways)
for _, gateway := range r.Gateways {
gateway := gateway
if gateway.Annotations == nil {
gateway.Annotations = make(map[string]string)
}
gateway.Annotations[i2gw.GeneratorAnnotationKey] = fmt.Sprintf("ingress2gateway-%s", i2gw.CurrentVersion)
err := pr.resourcePrinter.PrintObj(&gateway, os.Stdout)
if err != nil {
fmt.Printf("# Error printing %s Gateway: %v\n", gateway.Name, err)
Expand All @@ -128,6 +132,10 @@ func (pr *PrintRunner) outputResult(gatewayResources []i2gw.GatewayResources) {
resourceCount += len(r.HTTPRoutes)
for _, httpRoute := range r.HTTPRoutes {
httpRoute := httpRoute
if httpRoute.Annotations == nil {
httpRoute.Annotations = make(map[string]string)
}
httpRoute.Annotations[i2gw.GeneratorAnnotationKey] = fmt.Sprintf("ingress2gateway-%s", i2gw.CurrentVersion)
err := pr.resourcePrinter.PrintObj(&httpRoute, os.Stdout)
if err != nil {
fmt.Printf("# Error printing %s HTTPRoute: %v\n", httpRoute.Name, err)
Expand All @@ -139,6 +147,10 @@ func (pr *PrintRunner) outputResult(gatewayResources []i2gw.GatewayResources) {
resourceCount += len(r.TLSRoutes)
for _, tlsRoute := range r.TLSRoutes {
tlsRoute := tlsRoute
if tlsRoute.Annotations == nil {
tlsRoute.Annotations = make(map[string]string)
}
tlsRoute.Annotations[i2gw.GeneratorAnnotationKey] = fmt.Sprintf("ingress2gateway-%s", i2gw.CurrentVersion)
err := pr.resourcePrinter.PrintObj(&tlsRoute, os.Stdout)
if err != nil {
fmt.Printf("# Error printing %s TLSRoute: %v\n", tlsRoute.Name, err)
Expand All @@ -150,6 +162,10 @@ func (pr *PrintRunner) outputResult(gatewayResources []i2gw.GatewayResources) {
resourceCount += len(r.TCPRoutes)
for _, tcpRoute := range r.TCPRoutes {
tcpRoute := tcpRoute
if tcpRoute.Annotations == nil {
tcpRoute.Annotations = make(map[string]string)
}
tcpRoute.Annotations[i2gw.GeneratorAnnotationKey] = fmt.Sprintf("ingress2gateway-%s", i2gw.CurrentVersion)
err := pr.resourcePrinter.PrintObj(&tcpRoute, os.Stdout)
if err != nil {
fmt.Printf("# Error printing %s TCPRoute: %v\n", tcpRoute.Name, err)
Expand All @@ -161,6 +177,10 @@ func (pr *PrintRunner) outputResult(gatewayResources []i2gw.GatewayResources) {
resourceCount += len(r.UDPRoutes)
for _, udpRoute := range r.UDPRoutes {
udpRoute := udpRoute
if udpRoute.Annotations == nil {
udpRoute.Annotations = make(map[string]string)
}
udpRoute.Annotations[i2gw.GeneratorAnnotationKey] = fmt.Sprintf("ingress2gateway-%s", i2gw.CurrentVersion)
err := pr.resourcePrinter.PrintObj(&udpRoute, os.Stdout)
if err != nil {
fmt.Printf("# Error printing %s UDPRoute: %v\n", udpRoute.Name, err)
Expand All @@ -172,6 +192,10 @@ func (pr *PrintRunner) outputResult(gatewayResources []i2gw.GatewayResources) {
resourceCount += len(r.ReferenceGrants)
for _, referenceGrant := range r.ReferenceGrants {
referenceGrant := referenceGrant
if referenceGrant.Annotations == nil {
referenceGrant.Annotations = make(map[string]string)
}
referenceGrant.Annotations[i2gw.GeneratorAnnotationKey] = fmt.Sprintf("ingress2gateway-%s", i2gw.CurrentVersion)
err := pr.resourcePrinter.PrintObj(&referenceGrant, os.Stdout)
if err != nil {
fmt.Printf("# Error printing %s ReferenceGrant: %v\n", referenceGrant.Name, err)
Expand Down
4 changes: 4 additions & 0 deletions pkg/i2gw/ingress2gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import (
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
)

const GeneratorAnnotationKey = "gateway.networking.k8s.io/generator"

var CurrentVersion = "0.3.0"

func ToGatewayAPIResources(ctx context.Context, namespace string, inputFile string, providers []string, providerSpecificFlags map[string]map[string]string) ([]GatewayResources, map[string]string, error) {
var clusterClient client.Client

Expand Down
Loading