Skip to content

Commit

Permalink
Create Ingress2gateway version annotation and attach it to Gateway.
Browse files Browse the repository at this point in the history
* Ingress2gateway annotation will track the current version of the
  ingress2gateway tool. The version is currently a string that needs to
  be updated manually before release.
* This annotation will be attached to the resulting Gateway during print
  since this is an output-only translation, and we can avoid interfering
  with existing Gateway translation tests.
  • Loading branch information
sawsa307 committed Sep 3, 2024
1 parent c626d14 commit 357037b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
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
4 changes: 4 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 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

0 comments on commit 357037b

Please sign in to comment.