From 5f1b1c74cb6ed39a251002760a2abfa59ebb35cb Mon Sep 17 00:00:00 2001 From: RainbowMango Date: Mon, 20 May 2024 18:16:03 +0800 Subject: [PATCH] Fix hack/update-codegen.sh failed to generates the code in right place Signed-off-by: RainbowMango --- hack/update-codegen.sh | 41 ++++++++++++++++------ pkg/apis/v1alpha1/appliedwork_type.go | 2 ++ pkg/apis/v1alpha1/doc.go | 1 + pkg/apis/v1alpha1/work_types.go | 2 ++ pkg/apis/v1alpha1/zz_generated.deepcopy.go | 19 ++++++++-- 5 files changed, 51 insertions(+), 14 deletions(-) diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 3f2bf319..950586cd 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -38,22 +38,41 @@ if [[ "${VERIFY_CODEGEN:-}" == "true" ]]; then fi COMMON_FLAGS="${VERIFY_FLAG:-} --go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt" +# code generator tools rely on the environment variable GOPATH and generates files to $GOPATH/src/. +export GOPATH=$(go env GOPATH | awk -F ':' '{print $1}') + echo "Generating deepcopy funcs" -"${gobin}/deepcopy-gen" --input-dirs "${FQ_APIS}" -O zz_generated.deepcopy --bounding-dirs "${APIS_PKG}" ${COMMON_FLAGS} +"${gobin}/deepcopy-gen" \ + --input-dirs=sigs.k8s.io/work-api/pkg/apis/v1alpha1 \ + --output-package=sigs.k8s.io/work-api/pkg/apis/v1alpha1 \ + --output-file-base=zz_generated.deepcopy \ + ${COMMON_FLAGS} + +echo "Generating register at ${FQ_APIS}" +"${gobin}/register-gen" \ + --input-dirs=sigs.k8s.io/work-api/pkg/apis/v1alpha1 \ + --output-package=sigs.k8s.io/work-api/pkg/apis/v1alpha1 \ + --output-file-base=zz_generated.register \ + ${COMMON_FLAGS} echo "Generating clientset at ${OUTPUT_PKG}/${CLIENTSET_PKG_NAME}" -"${gobin}/client-gen" --clientset-name "${CLIENTSET_NAME}" --input-base "" --input "${FQ_APIS}" --output-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME}" ${COMMON_FLAGS} +"${gobin}/client-gen" \ + --input-base="" \ + --input=sigs.k8s.io/work-api/pkg/apis/v1alpha1 \ + --output-package=sigs.k8s.io/work-api/pkg/client/clientset \ + --clientset-name=versioned \ + ${COMMON_FLAGS} echo "Generating listers at ${OUTPUT_PKG}/listers" -"${gobin}/lister-gen" --input-dirs "${FQ_APIS}" --output-package "${OUTPUT_PKG}/listers" ${COMMON_FLAGS} +"${gobin}/lister-gen" \ + --input-dirs=sigs.k8s.io/work-api/pkg/apis/v1alpha1 \ + --output-package=sigs.k8s.io/work-api/pkg/client/listers \ + ${COMMON_FLAGS} echo "Generating informers at ${OUTPUT_PKG}/informers" "${gobin}/informer-gen" \ - --input-dirs "${FQ_APIS}" \ - --versioned-clientset-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME}/${CLIENTSET_NAME}" \ - --listers-package "${OUTPUT_PKG}/listers" \ - --output-package "${OUTPUT_PKG}/informers" \ - ${COMMON_FLAGS} - -echo "Generating register at ${FQ_APIS}" -"${gobin}/register-gen" --output-package "${FQ_APIS}" --input-dirs ${FQ_APIS} ${COMMON_FLAGS} + --input-dirs=sigs.k8s.io/work-api/pkg/apis/v1alpha1 \ + --versioned-clientset-package=sigs.k8s.io/work-api/pkg/client/clientset/versioned \ + --listers-package=sigs.k8s.io/work-api/pkg/client/listers \ + --output-package=sigs.k8s.io/work-api/pkg/client/informers \ + ${COMMON_FLAGS} diff --git a/pkg/apis/v1alpha1/appliedwork_type.go b/pkg/apis/v1alpha1/appliedwork_type.go index 1e92b575..c5dbe73b 100644 --- a/pkg/apis/v1alpha1/appliedwork_type.go +++ b/pkg/apis/v1alpha1/appliedwork_type.go @@ -65,6 +65,7 @@ type AppliedResourceMeta struct { // +kubebuilder:subresource:status // +kubebuilder:resource:scope=Cluster,categories={fleet} // +kubebuilder:object:root=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // AppliedWork represents an applied work on managed cluster that is placed // on a managed cluster. An appliedwork links to a work on a hub recording resources @@ -89,6 +90,7 @@ type AppliedWork struct { } // +kubebuilder:object:root=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // AppliedWorkList contains a list of AppliedWork type AppliedWorkList struct { diff --git a/pkg/apis/v1alpha1/doc.go b/pkg/apis/v1alpha1/doc.go index 38378904..8836721e 100644 --- a/pkg/apis/v1alpha1/doc.go +++ b/pkg/apis/v1alpha1/doc.go @@ -16,6 +16,7 @@ limitations under the License. // Package v1alpha1 contains API schema definitions for the Multi-Cluster // Services v1alpha1 API group. +// +k8s:deepcopy-gen=package,register // +kubebuilder:object:generate=true // +groupName=multicluster.x-k8s.io package v1alpha1 diff --git a/pkg/apis/v1alpha1/work_types.go b/pkg/apis/v1alpha1/work_types.go index 5e6ef365..f3b7a3d2 100644 --- a/pkg/apis/v1alpha1/work_types.go +++ b/pkg/apis/v1alpha1/work_types.go @@ -101,6 +101,7 @@ type ManifestCondition struct { // +genclient // +kubebuilder:object:root=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +kubebuilder:subresource:status // Work is the Schema for the works API @@ -116,6 +117,7 @@ type Work struct { } // +kubebuilder:object:root=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // WorkList contains a list of Work type WorkList struct { diff --git a/pkg/apis/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/v1alpha1/zz_generated.deepcopy.go index 515039b5..531a6126 100644 --- a/pkg/apis/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/v1alpha1/zz_generated.deepcopy.go @@ -17,19 +17,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by controller-gen. DO NOT EDIT. +// Code generated by deepcopy-gen. DO NOT EDIT. package v1alpha1 import ( - "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AppliedResourceMeta) DeepCopyInto(out *AppliedResourceMeta) { *out = *in out.ResourceIdentifier = in.ResourceIdentifier + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppliedResourceMeta. @@ -49,6 +50,7 @@ func (in *AppliedWork) DeepCopyInto(out *AppliedWork) { in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) out.Spec = in.Spec in.Status.DeepCopyInto(&out.Status) + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppliedWork. @@ -81,6 +83,7 @@ func (in *AppliedWorkList) DeepCopyInto(out *AppliedWorkList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppliedWorkList. @@ -104,6 +107,7 @@ func (in *AppliedWorkList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AppliedWorkSpec) DeepCopyInto(out *AppliedWorkSpec) { *out = *in + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppliedWorkSpec. @@ -124,6 +128,7 @@ func (in *AppliedtWorkStatus) DeepCopyInto(out *AppliedtWorkStatus) { *out = make([]AppliedResourceMeta, len(*in)) copy(*out, *in) } + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppliedtWorkStatus. @@ -140,6 +145,7 @@ func (in *AppliedtWorkStatus) DeepCopy() *AppliedtWorkStatus { func (in *Manifest) DeepCopyInto(out *Manifest) { *out = *in in.RawExtension.DeepCopyInto(&out.RawExtension) + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Manifest. @@ -163,6 +169,7 @@ func (in *ManifestCondition) DeepCopyInto(out *ManifestCondition) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManifestCondition. @@ -178,6 +185,7 @@ func (in *ManifestCondition) DeepCopy() *ManifestCondition { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceIdentifier) DeepCopyInto(out *ResourceIdentifier) { *out = *in + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceIdentifier. @@ -197,6 +205,7 @@ func (in *Work) DeepCopyInto(out *Work) { in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Work. @@ -229,6 +238,7 @@ func (in *WorkList) DeepCopyInto(out *WorkList) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkList. @@ -253,6 +263,7 @@ func (in *WorkList) DeepCopyObject() runtime.Object { func (in *WorkSpec) DeepCopyInto(out *WorkSpec) { *out = *in in.Workload.DeepCopyInto(&out.Workload) + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkSpec. @@ -282,6 +293,7 @@ func (in *WorkStatus) DeepCopyInto(out *WorkStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkStatus. @@ -304,6 +316,7 @@ func (in *WorkloadTemplate) DeepCopyInto(out *WorkloadTemplate) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + return } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkloadTemplate.