Skip to content

Commit

Permalink
Adds a command to generate the zz_generated.deepcopy.go files for the…
Browse files Browse the repository at this point in the history
… apis (#3900)

* Adds a command to generate the zz_generated.deepcopy.go files for the apis
* Combines CRD client and deepcopy code generation into one script
* Updates boilerplate headers to 2024
* Generated code from gen-all-sdk-grpc
* Small update to template comment
  • Loading branch information
igooch authored Jul 11, 2024
1 parent 8ca6ffd commit d5027db
Show file tree
Hide file tree
Showing 188 changed files with 220 additions and 203 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/kubernetes_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ List of items to do for upgrading to {version_1} {version_2} {version_3}
- [ ] Update CRD API reference to {version_2}
- [ ] Update links to k8s documentation in `site/assets/templates/crd-doc-config.json`
- [ ] Regenerate crd api reference docs - `make gen-api-docs`
- [ ] Regenerate crd client libraries - `make gen-crd-client`
- [ ] Regenerate crd client libraries and generated code - `make gen-crd-code`
- [ ] Regenerate Kubernetes resource includes (e.g. ObjectMeta, PodTemplateSpec)
- [ ] Start a cluster with `make gcloud-test-cluster` (this cluster will use Kubernetes {version_2}), uninstall agones using `helm uninstall agones -n agones-system`, and then run `make gen-embedded-openapi` and `make gen-install`
- [ ] Update documentation for creating clusters and k8s API references to align with the above clusters versions and the k8s API version
Expand All @@ -41,11 +41,11 @@ List of items to do for upgrading to {version_1} {version_2} {version_3}
- [ ] Update the `grpc_release_tag` in the SDK [base image grpc version](https://github.com/googleforgames/agones/blob/main/build/includes/sdk.mk).
- [ ] Update the gRPC version number in C++ gRPC Dependency documentation [here](https://github.com/googleforgames/agones/blob/main/site/content/en/docs/Guides/Client%20SDKs/cpp.md).
- [ ] Update the gRPC version
([Dockerfile](https://github.com/googleforgames/agones/blob/main/examples/cpp-simple/Dockerfile)) and
([Dockerfile](https://github.com/googleforgames/agones/blob/main/examples/cpp-simple/Dockerfile)) and
increment the image tag
([Makefile](https://github.com/googleforgames/agones/blob/main/examples/cpp-simple/Makefile)) in the C++
`cpp-simple` example.
- [ ] Regenerate all client sdks: [make gen-all-sdk-grpc](https://github.com/googleforgames/agones/blob/main/build/README.md#make-gen-all-sdk-grpc)
- [ ] Regenerate all client sdks: [make gen-all-sdk-grpc](https://github.com/googleforgames/agones/blob/main/build/README.md#make-gen-all-sdk-grpc)
This can take 20 minutes or so, as the above changes force a rebuild. Plan your day accordingly 😃.
- [ ] Regenerate allocated API endpoints: [make gen-allocation-grpc](https://github.com/googleforgames/agones/blob/main/build/README.md#make-gen-allocation-grpc)
- [ ] Confirm the update works as expected by running e2e tests
Expand Down
29 changes: 19 additions & 10 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -738,12 +738,12 @@ gen-install: $(ensure-build-image)
--set agones.crds.cleanupOnDelete=false \
> $(mount_path)/install/yaml/install.yaml'

# Generate the client for our CustomResourceDefinition
gen-crd-client: $(ensure-build-image)
# Generate the client, conversions, deepcopy, and defaults code for our CustomResourceDefinition
gen-crd-code: $(ensure-build-image)
docker run --rm \
$(common_mounts) -w $(workdir_path) $(build_tag) bash -c "\
$(git_safe) && \
/root/gen-crd-client.sh && \
/root/gen-crd-code.sh && \
cd $(workdir_path)/pkg && goimports -w ."

# Run a bash shell with the developer tools in it. (Creates the image if it doesn't exist)
Expand Down Expand Up @@ -848,14 +848,23 @@ update-go-deps:
$(DOCKER_RUN) go mod tidy
$(DOCKER_RUN) go mod vendor

test-gen-crd-client:
mkdir -p build/tmp
mv ../pkg/client build/tmp
make gen-crd-client
diff_output=$$(diff -bBr build/tmp/client ../pkg/client); \
if [ -z "$$diff_output" ]; then \
echo "No differences found. Deleting build/tmp"; \
test-gen-crd-code:
mkdir -p build/tmp/apis | mkdir -p build/tmp/client; \
cp -r ../pkg/apis/* build/tmp/apis | cp -r ../pkg/client/* build/tmp/client; \
make gen-crd-code; \
$(MAKE) diff-directory DIRECTORY=apis
$(MAKE) diff-directory DIRECTORY=client
# Delete build/tmp if the directory is empty
if [ ! "$(ls -A build/tmp)" ]; then \
echo "No differences found. Deleting empty directory build/tmp."; \
rm -r build/tmp; \
fi

diff-directory:
diff_output=$$(diff -bBr build/tmp/$(DIRECTORY) ../pkg/$(DIRECTORY)); \
if [ -z "$$diff_output" ]; then \
echo "No differences found. Deleting build/tmp/$(DIRECTORY)"; \
rm -r build/tmp/$(DIRECTORY); \
else \
echo "Differences found."; \
echo "$$diff_output"; \
Expand Down
8 changes: 4 additions & 4 deletions build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Table of Contents
* [make build-agones-sdk-image](#make-build-agones-sdk-image)
* [make gen-install](#make-gen-install)
* [make gen-embedded-openapi](#make-gen-embedded-openapi)
* [make gen-crd-client](#make-gen-crd-client)
* [make gen-crd-code](#make-gen-crd-code)
* [make gen-allocation-grpc](#make-gen-allocation-grpc)
* [make gen-all-sdk-grpc](#make-gen-all-sdk-grpc)
* [make gen-sdk-grpc](#make-gen-sdk-grpc)
Expand Down Expand Up @@ -585,7 +585,7 @@ make test-e2e-integration ARGS='-run TestGameServerReserve'
Run controller failure portion of the end-to-end tests.

#### `make test-e2e-allocator-crash`
Run allocator failure portion of the end-to-end test.
Run allocator failure portion of the end-to-end test.

#### `make setup-prometheus`

Expand Down Expand Up @@ -675,8 +675,8 @@ Generate the embedded OpenAPI specs for existing Kubernetes Objects, such as `Po

This should be run against a clean or brand new cluster, as external CRD's or schemas could cause errors to occur.

#### `make gen-crd-client`
Generate the Custom Resource Definition client(s)
#### `make gen-crd-code`
Generate the Custom Resource Definition client(s), conversions, deepcopy, and defaults code.

#### `make gen-allocation-grpc`
Generate the allocator gRPC code
Expand Down
2 changes: 1 addition & 1 deletion build/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC All Rights Reserved.
// Copyright 2024 Google LLC All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion build/boilerplate.yaml.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Google LLC All Rights Reserved.
# Copyright 2024 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ kube::codegen::gen_client \
/go/src/agones.dev/agones/pkg/apis

echo "CRD client code generation complete."

echo "Generating CRD conversions, deepcopy, and defaults code..."

kube::codegen::gen_helpers \
--boilerplate /go/src/agones.dev/agones/build/boilerplate.go.txt \
/go/src/agones.dev/agones/pkg/apis

echo "CRD conversions, deepcopy, and defaults code generation complete."
6 changes: 3 additions & 3 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ steps:
# Preventing Broken PR Merges in CI
#
- name: make-docker
id: test-gen-crd-client
id: test-gen-crd-code
waitFor: [pull-build-image]
dir: build
args: [test-gen-crd-client]
args: [test-gen-crd-code]

#
# Runs the linter -- but also builds the build image, if not able to download
Expand All @@ -128,7 +128,7 @@ steps:
id: lint
waitFor:
- pull-build-image
- test-gen-crd-client
- test-gen-crd-code
- test-gen-all-sdk-grpc
dir: build
args: [lint] # pull the build image if it exists
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/agones/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/allocation/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/autoscaling/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/multicluster/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/counterstatus.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/eviction.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/fleet.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/fleetspec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/fleetstatus.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/gameserver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/gameserverport.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/gameserverset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/gameserverspec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/health.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/liststatus.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/playersspec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/playerstatus.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/priority.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/agones/v1/sdkserver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/autoscaling/v1/listpolicy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/applyconfiguration/internal/internal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d5027db

Please sign in to comment.