Skip to content

Commit

Permalink
Fix renaming references to previous gateway2 name
Browse files Browse the repository at this point in the history
Signed-off-by: timflannagan <[email protected]>
  • Loading branch information
timflannagan committed Feb 10, 2025
1 parent fb36caf commit ed53f3d
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ test-with-coverage: test
go tool cover -html $(OUTPUT_DIR)/coverage.cov

.PHONY: run-tests
run-tests: GINKGO_FLAGS += -skip-package=e2e,gateway2,test/kubernetes/testutils/helper ## Run all non E2E tests, or only run the test package at {TEST_PKG} if it is specified
run-tests: GINKGO_FLAGS += -skip-package=e2e,kgateway,test/kubernetes/testutils/helper ## Run all non E2E tests, or only run the test package at {TEST_PKG} if it is specified
run-tests: GINKGO_FLAGS += --label-filter="!end-to-end && !performance"
run-tests: test

.PHONY: run-performance-tests
# Performance tests are filtered using a Ginkgo label
# This means that any tests which do not rely on Ginkgo, will by default be compiled and run
# Since this is not the desired behavior, we explicitly skip these packages
run-performance-tests: GINKGO_FLAGS += -skip-package=gateway2,kubernetes/e2e,test/kube2e
run-performance-tests: GINKGO_FLAGS += -skip-package=kgateway,kubernetes/e2e,test/kube2e
run-performance-tests: GINKGO_FLAGS += --label-filter="performance" ## Run only tests with the Performance label
run-performance-tests: test

Expand Down
20 changes: 10 additions & 10 deletions design/10498.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ A more conventional project structure will reduce unnecessary complexity while p
- Improve developer onboarding by creating a flatter, more conventional structure (e.g., `/api`, `/cmd`, `/pkg`) so contributors can easily locate API definitions, binaries, library code, and other key components.
- Preserve git history by ensuring file movements retain commit logs using `git mv` or similarly recognized techniques.
- Maintain working CI by updating all references in scripts, Makefiles, Dockerfiles, and other relevant files to ensure the pipeline remains fully operational.
- Centralize the high-level API by moving existing `projects/gateway2` API types to a top-level `api/` directory, ensuring a clear separation of concerns.
- Centralize the high-level API by moving existing `projects/kgateway` API types to a top-level `api/` directory, ensuring a clear separation of concerns.
- Separate the project's Go applications by extracting existing CLI entry points (currently nested in `projects/*/cmd` subdirectories) into a top-level `cmd/` directory, in order to follow standard Go patterns.
- Standardize tooling placement by ensuring all project-specific tooling, miscellaneous scripts, and other automation-related files reside in a `hack/` directory.

## Non-Goals

- Renaming the `projects/gateway2` (new name TBD) directory. This can be done separately to preserve git history.
- Renaming the `projects/kgateway` (new name TBD) directory. This can be done separately to preserve git history.
- Further re-organization efforts, such as splitting the root `go.mod` into sub-modules (e.g. tools and tests) to refine build dependencies, will not be included in this effort.
- Auditing all existing `README.md` files for references to legacy paths or project names. This will be handled as a follow-up effort.

## Implementation Details

This effort will consolidate key parts of the repository into a standard Go project layout. Most notably, the `projects/gateway2` package will be diced up into several, top-level directories. containing all Go-based API definitions.
This effort will consolidate key parts of the repository into a standard Go project layout. Most notably, the `projects/kgateway` package will be diced up into several, top-level directories. containing all Go-based API definitions.

To minimize disruption, we will perform this restructuring in a single or minimal number of pull requests. The process will include updating import paths, adjusting CI and build scripts, and ensuring that all automated tests pass. Documentation will be updated to reflect the new structure, and contributors will be provided with migration guidance for adapting to the changes.

Expand All @@ -38,7 +38,7 @@ To minimize disruption, we will perform this restructuring in a single or minima
```bash
$ tree -L 1
├── .github/ # GitHub Actions workflows, etc.
├── api/ # Migrated from `projects/gateway2/api/...` initially. Any future API types will be added here.
├── api/ # Migrated from `projects/kgateway/api/...` initially. Any future API types will be added here.
├── cmd/ # Top-level directory containing main entry points (e.g., cmd/sds, cmd/controller, cmd/envoy-init, etc.).
├── design/ # Enhancements, templates, etc.
├── examples/ # Example usage, etc. Open question on whether we want to keep this. The README.md would reference this directory.
Expand All @@ -52,16 +52,16 @@ $ tree -L 1

### Plan

1. Move the `projects/*` directory into `pkg/`. Commit: "Move projects/gateway2/api to api/"
1. Move the `projects/*` directory into `pkg/`. Commit: "Move projects/kgateway/api to api/"

```bash
git mv projects/* pkg/
```

2. Extract the `pkg/gateway2/api` package into `api/`. Commit: "Move pkg/gateway2/api to api/"
2. Extract the `pkg/kgateway/api` package into `api/`. Commit: "Move pkg/kgateway/api to api/"

```bash
git mv pkg/gateway2/api api/
git mv pkg/kgateway/api api/
```

3. Extract the `pkg/*/cmd` packages into `cmd/`. Commit: "Move pkg/*/cmd to cmd/"
Expand All @@ -76,7 +76,7 @@ git mv pkg/*/cmd cmd/
```bash
find . -type f -name "*.go" -exec sed -i 's|github.com/kgateway-dev/kgateway/projects/|github.com/kgateway-dev/kgateway/pkg/|g' {} +
find . -type f -name "*.go" -exec sed -i 's|github.com/kgateway-dev/kgateway/pkg/gateway2/api|github.com/kgateway-dev/kgateway/api|g' {} +
find . -type f -name "*.go" -exec sed -i 's|github.com/kgateway-dev/kgateway/pkg/kgateway/api|github.com/kgateway-dev/kgateway/api|g' {} +
find . -type f -name "*.go" -exec sed -i 's|github.com/kgateway-dev/kgateway/pkg/*/cmd|github.com/kgateway-dev/kgateway/cmd|g' {} +
```

Expand Down Expand Up @@ -107,7 +107,7 @@ N/A.

### 2. Retain Existing Structure

- Perform minimal changes, possibly just renaming `projects/gateway2`.
- Perform minimal changes, possibly just renaming `projects/kgateway`.
- **Pros**: Fewer disruptions to code, minimal rename overhead.
- **Cons**: Keeps the non-standard layout, likely remains confusing to new contributors.

Expand All @@ -124,7 +124,7 @@ N/A.
- Versioning: Should there be a dedicated `internal/version` package, or is placing version info in `cmd/` acceptable?
- CI directory: Should CI-specific scripts remain in `ci/` or be moved into `hack/`?
- projects/distroless: Should we keep this directory? If so, where should it live?
- projects/gateway2: Do we need to keep the non-code files, e.g. istio.sh, Makefile, etc.?
- projects/kgateway: Do we need to keep the non-code files, e.g. istio.sh, Makefile, etc.?

## Prerequisites

Expand Down
2 changes: 1 addition & 1 deletion internal/kgateway/controller/controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func getAssetsDir() string {
assets := ""
if os.Getenv("KUBEBUILDER_ASSETS") == "" {
// set default if not user provided
out, err := exec.Command("sh", "-c", "make -sC $(dirname $(go env GOMOD))/internal/gateway2 envtest-path").CombinedOutput()
out, err := exec.Command("sh", "-c", "make -sC $(dirname $(go env GOMOD))/internal/kgateway envtest-path").CombinedOutput()
fmt.Fprintln(GinkgoWriter, "out:", string(out))
ExpectWithOffset(1, err).NotTo(HaveOccurred())
assets = strings.TrimSpace(string(out))
Expand Down
2 changes: 1 addition & 1 deletion internal/kgateway/setup/ggv2setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func getAssetsDir(t *testing.T) string {
assets := ""
if os.Getenv("KUBEBUILDER_ASSETS") == "" {
// set default if not user provided
out, err := exec.Command("sh", "-c", "make -sC $(dirname $(go env GOMOD))/internal/gateway2 envtest-path").CombinedOutput()
out, err := exec.Command("sh", "-c", "make -sC $(dirname $(go env GOMOD))/internal/kgateway envtest-path").CombinedOutput()
t.Log("out:", string(out))
if err != nil {
t.Fatalf("failed to get assets dir: %v", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ package irtranslator_test
// }
// }

// // TODO(Law): consolidate this with iterators in gateway2/controller.go
// // TODO(Law): consolidate this with iterators in kgateway/controller.go
// fakeClient := testutils.BuildIndexedFakeClient(
// dependencies,
// gwquery.IterateIndices,
Expand Down
2 changes: 1 addition & 1 deletion internal/kgateway/translator/sslutils/ssl_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func cleanedSslKeyPair(certChain, privateKey, rootCa string) (cleanedChain strin
// this might not be needed once we have larger envoy validation
candidateCert, err := cert.ParseCertsPEM([]byte(certChain))
if err != nil {
// return err rather than sanitize. This is to maintain UX with older versions and to keep in line with gateway2 pkg.
// return err rather than sanitize. This is to maintain UX with older versions and to keep in line with kgateway pkg.
return "", err
}
cleanedChainBytes, err := cert.EncodeCertificates(candidateCert...)
Expand Down
2 changes: 1 addition & 1 deletion test/ginkgo/parallel/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func portInUseListen(proposedPort uint32) error {
}

var denyListPorts = map[uint32]struct{}{
// See internal/gateway2/admin/server.go
// See internal/kgateway/admin/server.go
// This port is reserved for the admin server
9097: {},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
var _ e2e.NewSuiteFunc = NewIstioIntegrationTestingSuite

// istioIntegrationDeployerSuite is the entire Suite of tests for the "deployer" feature that relies on an Istio installation
// The "deployer" code can be found here: /internal/gateway2/deployer
// The "deployer" code can be found here: /internal/kgateway/deployer
type istioIntegrationDeployerSuite struct {
suite.Suite

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var _ e2e.NewSuiteFunc = NewMinimalDefaultGatewayParametersTestingSuite

// minimalDefaultGatewayParametersDeployerSuite tests the "deployer" feature in situations where users have applied `null` values
// to as many of the helm values controlling the default GatewayParameters for the gloo-gateway GatewayClass as possible.
// The "deployer" code can be found here: /internal/gateway2/deployer
// The "deployer" code can be found here: /internal/kgateway/deployer
type minimalDefaultGatewayParametersDeployerSuite struct {
suite.Suite

Expand Down
2 changes: 1 addition & 1 deletion test/kubernetes/e2e/features/deployer/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
var _ e2e.NewSuiteFunc = NewTestingSuite

// testingSuite is the entire Suite of tests for the "deployer" feature
// The "deployer" code can be found here: /internal/gateway2/deployer
// The "deployer" code can be found here: /internal/kgateway/deployer
type testingSuite struct {
suite.Suite

Expand Down

0 comments on commit ed53f3d

Please sign in to comment.