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

Migrating from generate-groups.sh to kube_codegen.sh #3722

Merged
merged 12 commits into from
Mar 22, 2024
9 changes: 5 additions & 4 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,11 @@ gen-install: $(ensure-build-image)

# Generate the client for our CustomResourceDefinition
gen-crd-client: $(ensure-build-image)
docker run --rm $(common_mounts) -w $(workdir_path) $(build_tag) bash -c "\
$(git_safe) && \
/root/gen-crd-client.sh && \
cd $(workdir_path)/pkg && goimports -w ."
docker run --rm \
$(common_mounts) -w $(workdir_path) $(build_tag) bash -c "\
$(git_safe) && \
/root/gen-crd-client.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)
# Can use DOCKER_RUN_ARGS for extra arguments.
Expand Down
7 changes: 6 additions & 1 deletion build/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ RUN go install golang.org/x/tools/cmd/goimports@latest && \
go install golang.org/x/pkgsite/cmd/pkgsite@latest

# the kubernetes version for the file
#
# When this is raised to 1.29: bump the code-generator version on line 66 to the v0.30 tag.
# When this is raised to >=1.30: delete line 66-67 and uncomment line 68 to stop pinning code-generator.
ENV KUBERNETES_VER 1.28.6

# overwrite kubectl as we want a specific version
Expand All @@ -60,7 +63,9 @@ RUN echo "source <(kubectl completion bash)" >> /root/.bashrc

# install the release branch of the code generator tools
RUN mkdir -p /go/src/k8s.io && cd /go/src/k8s.io && \
git clone -b kubernetes-${KUBERNETES_VER} --depth=3 https://github.com/kubernetes/code-generator.git
git clone -b v0.30.0-beta.0 --depth=3 https://github.com/kubernetes/code-generator.git
# We are pinning code-generator for now - kube_codegen.sh has substantial improvements in later releases.
# git clone -b kubernetes-${KUBERNETES_VER} --depth=3 https://github.com/kubernetes/code-generator.git

# install Helm package manager
ENV HELM_VER 3.10.3
Expand Down
26 changes: 22 additions & 4 deletions build/build-image/gen-crd-client.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash

set -x
set -o errexit
set -o nounset
set -o pipefail

CODEGEN_SCRIPT="/go/src/k8s.io/code-generator/kube_codegen.sh"

source "${CODEGEN_SCRIPT}"

echo "Generating CRD client code..."
OUTPUT_DIR="/go/src/agones.dev/agones/pkg/client"
OUTPUT_PKG="agones.dev/agones/pkg/client"

kube::codegen::gen_client \
--with-watch \
--with-applyconfig \
--output-dir "${OUTPUT_DIR}" \
--output-pkg "${OUTPUT_PKG}" \
--boilerplate /go/src/agones.dev/agones/build/boilerplate.go.txt \
/go/src/agones.dev/agones/pkg/apis

bash /go/src/k8s.io/code-generator/generate-groups.sh "all" \
agones.dev/agones/pkg/client \
agones.dev/agones/pkg/apis "allocation:v1 agones:v1 multicluster:v1 autoscaling:v1" \
--go-header-file=/go/src/agones.dev/agones/build/boilerplate.go.txt
echo "CRD client code generation complete."
10 changes: 10 additions & 0 deletions pkg/client/informers/externalversions/factory.go

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

Loading