From 372f5d1202398757f7abe9802d18455fefc02e6e Mon Sep 17 00:00:00 2001 From: Stavros Kontopoulos Date: Tue, 3 Sep 2024 12:02:27 +0300 Subject: [PATCH] Migrate to kube codegen (#15491) --- hack/update-codegen.sh | 48 +++++++++++++++++-------------- pkg/apis/zz_generated.deepcopy.go | 22 ++++++++++++++ 2 files changed, 48 insertions(+), 22 deletions(-) create mode 100644 pkg/apis/zz_generated.deepcopy.go diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 587ecedf2a8c..420e0f0e1eb6 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -60,20 +60,25 @@ ${REPO_ROOT_DIR}/hack/update-checksums.sh group "Kubernetes Codegen" -# generate the code with: -# --output-base because this script should also be able to run inside the vendor dir of -# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir -# instead of the $GOPATH directly. For normal projects this can be dropped. -${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ - knative.dev/serving/pkg/client knative.dev/serving/pkg/apis \ - "serving:v1 serving:v1beta1 autoscaling:v1alpha1" \ - --go-header-file "${boilerplate}" - -# Generate our own client for cert-manager (otherwise injection won't work) -${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ - knative.dev/serving/pkg/client/certmanager github.com/cert-manager/cert-manager/pkg/apis \ - "certmanager:v1 acme:v1" \ - --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt +source "${CODEGEN_PKG}/kube_codegen.sh" + +kube::codegen::gen_helpers \ + --boilerplate "${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt" \ + "${REPO_ROOT_DIR}/pkg/apis" + +kube::codegen::gen_client \ + --boilerplate "${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt" \ + --output-dir "${REPO_ROOT_DIR}/pkg/client" \ + --output-pkg "knative.dev/serving/pkg/client" \ + --with-watch \ + "${REPO_ROOT_DIR}/pkg/apis" + +kube::codegen::gen_client \ + --boilerplate "${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt" \ + --output-dir "${REPO_ROOT_DIR}/pkg/client/certmanager" \ + --output-pkg "knative.dev/serving/pkg/client/certmanager" \ + --with-watch \ + "${REPO_ROOT_DIR}/vendor/github.com/cert-manager/cert-manager/pkg/apis" group "Knative Codegen" @@ -92,16 +97,15 @@ ${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \ group "Deepcopy Gen" -# Depends on generate-groups.sh to install bin/deepcopy-gen ${GOPATH}/bin/deepcopy-gen \ - -O zz_generated.deepcopy \ + --output-file zz_generated.deepcopy.go \ --go-header-file "${boilerplate}" \ - -i knative.dev/serving/pkg/apis/config \ - -i knative.dev/serving/pkg/reconciler/route/config \ - -i knative.dev/serving/pkg/autoscaler/config/autoscalerconfig \ - -i knative.dev/serving/pkg/autoscaler/scaling \ - -i knative.dev/serving/pkg/deployment \ - -i knative.dev/serving/pkg/gc + knative.dev/serving/pkg/apis/config \ + knative.dev/serving/pkg/reconciler/route/config \ + knative.dev/serving/pkg/autoscaler/config/autoscalerconfig \ + knative.dev/serving/pkg/autoscaler/scaling \ + knative.dev/serving/pkg/deployment \ + knative.dev/serving/pkg/gc group "Generating API reference docs" diff --git a/pkg/apis/zz_generated.deepcopy.go b/pkg/apis/zz_generated.deepcopy.go new file mode 100644 index 000000000000..d05cae749c20 --- /dev/null +++ b/pkg/apis/zz_generated.deepcopy.go @@ -0,0 +1,22 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2022 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package apis