Skip to content

Commit eca3b94

Browse files
authored
*: Flatten repository structure (#10583)
Signed-off-by: timflannagan <[email protected]>
1 parent 322714e commit eca3b94

File tree

488 files changed

+1436
-1437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

488 files changed

+1436
-1437
lines changed

.github/workflows/pr-unit-tests.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ env:
1111
GITHUB_TOKEN: ${{ github.token }}
1212

1313
jobs:
14-
# Runs the unit tests for `projects/gateway2`
14+
# Runs the unit tests for `internal/gateway2`
1515
kube_gateway_project:
16+
# TODO(tim): rename this job or consolidate with the other workflows.
1617
name: projects/gateway2
1718
runs-on: ubuntu-22.04
1819
timeout-minutes: 10
@@ -23,14 +24,14 @@ jobs:
2324
with:
2425
go-version-file: go.mod
2526
- name: Build
26-
run: go build -v ./projects/gateway2/...
27+
run: go build -v ./internal/gateway2/...
2728
- name: Install Test Utils
2829
shell: bash
29-
run: make -C ./projects/gateway2/ install-go-tools
30+
run: make -C ./internal/gateway2/ install-go-tools
3031
- name: Run Tests
3132
shell: bash
3233
env:
33-
TEST_PKG: "./projects/gateway2/..."
34+
TEST_PKG: "./internal/gateway2/..."
3435
run: make go-test-with-coverage
3536
- name: Validate Test Coverage
3637
shell: bash

.goreleaser.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ before:
55
- go mod download
66
builds:
77
- id: controller
8-
main: ./projects/gateway2/cmd/
8+
main: ./cmd/gateway2
99
binary: kgateway-linux-{{ .Arch }}
1010
gcflags: "{{ .Env.GCFLAGS }}"
1111
ldflags: "{{ .Env.LDFLAGS }}"
@@ -21,7 +21,7 @@ builds:
2121
- amd64
2222
- arm64
2323
- id: sds
24-
main: ./projects/sds/cmd/
24+
main: ./cmd/sds
2525
binary: sds-linux-{{ .Arch }}
2626
gcflags: "{{ .Env.GCFLAGS }}"
2727
ldflags: "{{ .Env.LDFLAGS }}"
@@ -36,7 +36,7 @@ builds:
3636
- amd64
3737
- arm64
3838
- id: envoyinit
39-
main: ./projects/envoyinit/cmd/
39+
main: ./cmd/envoyinit
4040
binary: envoyinit-linux-{{ .Arch }}
4141
gcflags: "{{ .Env.GCFLAGS }}"
4242
ldflags: "{{ .Env.LDFLAGS }}"
@@ -54,7 +54,7 @@ dockers:
5454
- image_templates:
5555
- &controller_arm_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.CONTROLLER_IMAGE_REPO }}:{{ .Env.VERSION }}-arm64"
5656
use: buildx
57-
dockerfile: &controller_dockerfile projects/gateway2/cmd/Dockerfile
57+
dockerfile: &controller_dockerfile cmd/gateway2/Dockerfile
5858
goos: linux
5959
goarch: arm64
6060
build_flag_templates:
@@ -76,7 +76,7 @@ dockers:
7676
- image_templates:
7777
- &sds_arm_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.SDS_IMAGE_REPO }}:{{ .Env.VERSION }}-arm64"
7878
use: buildx
79-
dockerfile: &sds_dockerfile projects/sds/cmd/Dockerfile
79+
dockerfile: &sds_dockerfile cmd/sds/Dockerfile
8080
goos: linux
8181
goarch: arm64
8282
build_flag_templates:
@@ -98,17 +98,17 @@ dockers:
9898
- image_templates:
9999
- &envoyinit_arm_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.ENVOYINIT_IMAGE_REPO }}:{{ .Env.VERSION }}-arm64"
100100
use: buildx
101-
dockerfile: &envoyinit_dockerfile projects/envoyinit/cmd/Dockerfile.envoyinit
101+
dockerfile: &envoyinit_dockerfile cmd/envoyinit/Dockerfile.envoyinit
102102
goos: linux
103103
goarch: arm64
104104
build_flag_templates:
105105
- "--pull"
106106
- "--platform=linux/arm64"
107107
- "--build-arg=GOARCH=arm64"
108-
- "--build-arg=ENTRYPOINT_SCRIPT=/projects/envoyinit/cmd/docker-entrypoint.sh"
108+
- "--build-arg=ENTRYPOINT_SCRIPT=/cmd/envoyinit/docker-entrypoint.sh"
109109
- "--build-arg=ENVOY_IMAGE={{ .Env.ENVOY_IMAGE }}"
110110
extra_files:
111-
- projects/envoyinit/cmd/docker-entrypoint.sh
111+
- cmd/envoyinit/docker-entrypoint.sh
112112
- image_templates:
113113
- &envoyinit_amd_image "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.ENVOYINIT_IMAGE_REPO }}:{{ .Env.VERSION }}-amd64"
114114
use: buildx
@@ -119,10 +119,10 @@ dockers:
119119
- "--pull"
120120
- "--platform=linux/amd64"
121121
- "--build-arg=GOARCH=amd64"
122-
- "--build-arg=ENTRYPOINT_SCRIPT=/projects/envoyinit/cmd/docker-entrypoint.sh"
122+
- "--build-arg=ENTRYPOINT_SCRIPT=/cmd/envoyinit/docker-entrypoint.sh"
123123
- "--build-arg=ENVOY_IMAGE={{ .Env.ENVOY_IMAGE }}"
124124
extra_files:
125-
- projects/envoyinit/cmd/docker-entrypoint.sh
125+
- cmd/envoyinit/docker-entrypoint.sh
126126
docker_manifests:
127127
- name_template: "{{ .Env.IMAGE_REGISTRY }}/{{ .Env.CONTROLLER_IMAGE_REPO }}:{{ .Env.VERSION }}"
128128
image_templates:

Makefile

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ mod-download: check-go-version
137137

138138
.PHONY: check-format
139139
check-format:
140-
NOT_FORMATTED=$$(gofmt -l ./projects/ ./pkg/ ./test/) && if [ -n "$$NOT_FORMATTED" ]; then echo These files are not formatted: $$NOT_FORMATTED; exit 1; fi
140+
NOT_FORMATTED=$$(gofmt -l ./pkg/ ./internal/ ./test/) && if [ -n "$$NOT_FORMATTED" ]; then echo These files are not formatted: $$NOT_FORMATTED; exit 1; fi
141141

142142
.PHONY: check-spelling
143143
check-spelling:
@@ -301,7 +301,7 @@ generated-code: fmt
301301

302302
.PHONY: go-generate-all
303303
go-generate-all: ## Run all go generate directives in the repo, including codegen for protos, mockgen, and more
304-
GO111MODULE=on go generate ./projects/gateway2/...
304+
GO111MODULE=on go generate ./hack/...
305305

306306
.PHONY: go-generate-mocks
307307
go-generate-mocks: ## Runs all generate directives for mockgen in the repo
@@ -311,7 +311,7 @@ go-generate-mocks: ## Runs all generate directives for mockgen in the repo
311311
# TODO: do we still want this?
312312
.PHONY: getter-check
313313
getter-check:
314-
go run github.com/saiskee/gettercheck -ignoretests -ignoregenerated -write ./projects/gateway2/...
314+
go run github.com/saiskee/gettercheck -ignoretests -ignoregenerated -write ./internal/gateway2/...
315315

316316
.PHONY: mod-tidy
317317
mod-tidy:
@@ -336,7 +336,7 @@ generate-crd-reference-docs:
336336
# Distroless base images
337337
#----------------------------------------------------------------------------------
338338

339-
DISTROLESS_DIR=projects/distroless
339+
DISTROLESS_DIR=internal/distroless
340340
DISTROLESS_OUTPUT_DIR=$(OUTPUT_DIR)/$(DISTROLESS_DIR)
341341

342342
$(DISTROLESS_OUTPUT_DIR)/Dockerfile: $(DISTROLESS_DIR)/Dockerfile
@@ -365,20 +365,20 @@ distroless-with-utils-docker: distroless-docker $(DISTROLESS_OUTPUT_DIR)/Dockerf
365365
# Controller
366366
#----------------------------------------------------------------------------------
367367

368-
K8S_GATEWAY_DIR=projects/gateway2
368+
K8S_GATEWAY_DIR=internal/gateway2
369369
K8S_GATEWAY_SOURCES=$(call get_sources,$(K8S_GATEWAY_DIR))
370370
CONTROLLER_OUTPUT_DIR=$(OUTPUT_DIR)/$(K8S_GATEWAY_DIR)
371371
export CONTROLLER_IMAGE_REPO ?= kgateway
372372

373373
# We include the files in EDGE_GATEWAY_DIR and K8S_GATEWAY_DIR as dependencies to the gloo build
374374
# so changes in those directories cause the make target to rebuild
375375
$(CONTROLLER_OUTPUT_DIR)/kgateway-linux-$(GOARCH): $(K8S_GATEWAY_SOURCES)
376-
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags='$(LDFLAGS)' -gcflags='$(GCFLAGS)' -o $@ $(K8S_GATEWAY_DIR)/cmd/main.go
376+
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags='$(LDFLAGS)' -gcflags='$(GCFLAGS)' -o $@ cmd/gateway2/main.go
377377

378378
.PHONY: kgateway
379379
kgateway: $(CONTROLLER_OUTPUT_DIR)/kgateway-linux-$(GOARCH)
380380

381-
$(CONTROLLER_OUTPUT_DIR)/Dockerfile: $(K8S_GATEWAY_DIR)/cmd/Dockerfile
381+
$(CONTROLLER_OUTPUT_DIR)/Dockerfile: cmd/gateway2/Dockerfile
382382
cp $< $@
383383

384384
.PHONY: kgateway-docker
@@ -388,7 +388,7 @@ kgateway-docker: $(CONTROLLER_OUTPUT_DIR)/kgateway-linux-$(GOARCH) $(CONTROLLER_
388388
--build-arg ENVOY_IMAGE=$(ENVOY_IMAGE) \
389389
-t $(IMAGE_REGISTRY)/$(CONTROLLER_IMAGE_REPO):$(VERSION)
390390

391-
$(CONTROLLER_OUTPUT_DIR)/Dockerfile.distroless: $(K8S_GATEWAY_DIR)/cmd/Dockerfile.distroless
391+
$(CONTROLLER_OUTPUT_DIR)/Dockerfile.distroless: cmd/gateway2/Dockerfile.distroless
392392
cp $< $@
393393

394394
# Explicitly specify the base image is amd64 as we only build the amd64 flavour of envoy
@@ -404,18 +404,18 @@ kgateway-distroless-docker: $(CONTROLLER_OUTPUT_DIR)/kgateway-linux-$(GOARCH) $(
404404
# SDS Server - gRPC server for serving Secret Discovery Service config
405405
#----------------------------------------------------------------------------------
406406

407-
SDS_DIR=projects/sds
407+
SDS_DIR=internal/sds
408408
SDS_SOURCES=$(call get_sources,$(SDS_DIR))
409409
SDS_OUTPUT_DIR=$(OUTPUT_DIR)/$(SDS_DIR)
410410
export SDS_IMAGE_REPO ?= sds
411411

412412
$(SDS_OUTPUT_DIR)/sds-linux-$(GOARCH): $(SDS_SOURCES)
413-
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags='$(LDFLAGS)' -gcflags='$(GCFLAGS)' -o $@ $(SDS_DIR)/cmd/main.go
413+
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags='$(LDFLAGS)' -gcflags='$(GCFLAGS)' -o $@ cmd/sds/main.go
414414

415415
.PHONY: sds
416416
sds: $(SDS_OUTPUT_DIR)/sds-linux-$(GOARCH)
417417

418-
$(SDS_OUTPUT_DIR)/Dockerfile.sds: $(SDS_DIR)/cmd/Dockerfile
418+
$(SDS_OUTPUT_DIR)/Dockerfile.sds: cmd/sds/Dockerfile
419419
cp $< $@
420420

421421
.PHONY: sds-docker
@@ -425,7 +425,7 @@ sds-docker: $(SDS_OUTPUT_DIR)/sds-linux-$(GOARCH) $(SDS_OUTPUT_DIR)/Dockerfile.s
425425
--build-arg BASE_IMAGE=$(ALPINE_BASE_IMAGE) \
426426
-t $(IMAGE_REGISTRY)/$(SDS_IMAGE_REPO):$(VERSION)
427427

428-
$(SDS_OUTPUT_DIR)/Dockerfile.sds.distroless: $(SDS_DIR)/cmd/Dockerfile.distroless
428+
$(SDS_OUTPUT_DIR)/Dockerfile.sds.distroless: cmd/sds/Dockerfile.distroless
429429
cp $< $@
430430

431431
.PHONY: sds-distroless-docker
@@ -439,21 +439,21 @@ sds-distroless-docker: $(SDS_OUTPUT_DIR)/sds-linux-$(GOARCH) $(SDS_OUTPUT_DIR)/D
439439
# Envoy init (BASE/SIDECAR)
440440
#----------------------------------------------------------------------------------
441441

442-
ENVOYINIT_DIR=projects/envoyinit/cmd
442+
ENVOYINIT_DIR=internal/envoyinit
443443
ENVOYINIT_SOURCES=$(call get_sources,$(ENVOYINIT_DIR))
444444
ENVOYINIT_OUTPUT_DIR=$(OUTPUT_DIR)/$(ENVOYINIT_DIR)
445445
export ENVOYINIT_IMAGE_REPO ?= envoy-wrapper
446446

447447
$(ENVOYINIT_OUTPUT_DIR)/envoyinit-linux-$(GOARCH): $(ENVOYINIT_SOURCES)
448-
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags='$(LDFLAGS)' -gcflags='$(GCFLAGS)' -o $@ $(ENVOYINIT_DIR)/main.go
448+
$(GO_BUILD_FLAGS) GOOS=linux go build -ldflags='$(LDFLAGS)' -gcflags='$(GCFLAGS)' -o $@ cmd/envoyinit/main.go
449449

450450
.PHONY: envoyinit
451451
envoyinit: $(ENVOYINIT_OUTPUT_DIR)/envoyinit-linux-$(GOARCH)
452452

453-
$(ENVOYINIT_OUTPUT_DIR)/Dockerfile.envoyinit: $(ENVOYINIT_DIR)/Dockerfile.envoyinit
453+
$(ENVOYINIT_OUTPUT_DIR)/Dockerfile.envoyinit: cmd/envoyinit/Dockerfile.envoyinit
454454
cp $< $@
455455

456-
$(ENVOYINIT_OUTPUT_DIR)/docker-entrypoint.sh: $(ENVOYINIT_DIR)/docker-entrypoint.sh
456+
$(ENVOYINIT_OUTPUT_DIR)/docker-entrypoint.sh: cmd/envoyinit/docker-entrypoint.sh
457457
cp $< $@
458458

459459
.PHONY: envoy-wrapper-docker
@@ -463,7 +463,7 @@ envoy-wrapper-docker: $(ENVOYINIT_OUTPUT_DIR)/envoyinit-linux-$(GOARCH) $(ENVOYI
463463
--build-arg ENVOY_IMAGE=$(ENVOY_IMAGE) \
464464
-t $(IMAGE_REGISTRY)/$(ENVOYINIT_IMAGE_REPO):$(VERSION)
465465

466-
$(ENVOYINIT_OUTPUT_DIR)/Dockerfile.envoyinit.distroless: $(ENVOYINIT_DIR)/Dockerfile.envoyinit.distroless
466+
$(ENVOYINIT_OUTPUT_DIR)/Dockerfile.envoyinit.distroless: cmd/envoyinit/Dockerfile.envoyinit.distroless
467467
cp $< $@
468468

469469
# Explicitly specify the base image is amd64 as we only build the amd64 flavour of envoy

projects/gateway2/api/README.md renamed to api/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ These are the steps required to add a new CRD to be used in the Kubernetes Gatew
88

99
1. If creating a new API version (e.g. `v1`, `v2alpha1`), create a new directory for the version and create a `doc.go` file with the `// +kubebuilder:object:generate=true` annotation, so that Go types in that directory will be converted into CRDs when codegen is run.
1010
- The `groupName` marker specifies the API group name for the generated CRD.
11-
2. Create a `_types.go` file in the API version directory. Following [gateway_parameters_types.go](/projects/gateway2/api/v1alpha1/gateway_parameters_types.go) as an example:
11+
2. Create a `_types.go` file in the API version directory. Following [gateway_parameters_types.go](/api/v1alpha1/gateway_parameters_types.go) as an example:
1212
- Define a struct for the resource (containing the metadata fields, `Spec`, and `Status`)
1313
- Tip: For spec fields, try to use pointer values when appropriate, as it makes inheritance easier (allows us to differentiate between zero values and nil).
1414
- Define getters for each field, as these are not generated automatically.
@@ -17,12 +17,12 @@ These are the steps required to add a new CRD to be used in the Kubernetes Gatew
1717
- Avoid using slices with pointers. see: https://github.com/kubernetes/code-generator/issues/166
1818
- Define RBAC rules using the `+kubebuilder:rbac` annotation (note: this annotation should not belong to the type, but rather the file or package.). Alternativly, define RBAC rules in the helm chart in `install/helm/gloo/templates/44-rbac.yaml`.
1919
- Define a struct for the resource list (containing the metadata fields and `Items`)
20-
3. Run codegen via `make generated-code -B`. This will invoke the `controller-gen` command specified in [generate.go](/projects/gateway2/generate.go), which should result in the following:
20+
3. Run codegen via `make generated-code -B`. This will invoke the `controller-gen` command specified in [generate.go](/hack/generate.go), which should result in the following:
2121
- A `zz_generated.deepcopy.go` file is created in the same directory as the Go types.
2222
- A `zz_generated.register.go` file is created in the same directory as the Go types. To help with registering the Go types with the scheme.
2323
- A CRD file is generated in [install/helm/gloo/crds](/install/helm/gloo/crds)
2424
- RBAC role is generated in `install/helm/gloo/files/rbac/role.yaml`
25-
- Updates the `projects/gateway2/api/applyconfiguration` `projects/gateway2/pkg/generated` and `projects/gateway2/pkg/client` folders with kube clients. These are used in plugin initialization and the fake client is used in tests.
25+
- Updates the `api/applyconfiguration` `pkg/generated` and `pkg/client` folders with kube clients. These are used in plugin initialization and the fake client is used in tests.
2626

2727
## Background
2828

projects/gateway2/api/applyconfiguration/api/v1alpha1/aiextensionstats.go renamed to api/applyconfiguration/api/v1alpha1/aiextensionstats.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/gateway2/api/applyconfiguration/api/v1alpha1/directresponse.go renamed to api/applyconfiguration/api/v1alpha1/directresponse.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)