kube_codegen: smarter grepping of codegen tags

Be smarter about finding the input packages for genclient et al.  The
previous grep patterns were too generic. This caused code-generator, for
example, to pick up it's own auto-generated packages. In this particular
case having a status field in the type adds a comment to the
autogenerated code like:

  // Add a +genclient:noStatus comment above the type...

This, in turn causes problems in some scenarios where the input (api)
and the target package for the auto-generated code reside in separate go
modules.
This commit is contained in:
Markus Lehtonen 2024-05-22 15:22:50 +03:00
parent 68091805a5
commit fbb441cf8a

View File

@ -121,7 +121,7 @@ function kube::codegen::gen_helpers() {
input_pkgs+=("${pkg}")
done < <(
( kube::codegen::internal::grep -l --null \
-e '+k8s:deepcopy-gen=' \
-e '^\s*//\s*+k8s:deepcopy-gen=' \
-r "${in_dir}" \
--include '*.go' \
|| true \
@ -153,7 +153,7 @@ function kube::codegen::gen_helpers() {
input_pkgs+=("${pkg}")
done < <(
( kube::codegen::internal::grep -l --null \
-e '+k8s:defaulter-gen=' \
-e '^\s*//\s*+k8s:defaulter-gen=' \
-r "${in_dir}" \
--include '*.go' \
|| true \
@ -185,7 +185,7 @@ function kube::codegen::gen_helpers() {
input_pkgs+=("${pkg}")
done < <(
( kube::codegen::internal::grep -l --null \
-e '+k8s:conversion-gen=' \
-e '^\s*//\s*+k8s:conversion-gen=' \
-r "${in_dir}" \
--include '*.go' \
|| true \
@ -338,7 +338,7 @@ function kube::codegen::gen_openapi() {
input_pkgs+=("${pkg}")
done < <(
( kube::codegen::internal::grep -l --null \
-e '+k8s:openapi-gen=' \
-e '^\s*//\s*+k8s:openapi-gen=' \
-r "${in_dir}" \
--include '*.go' \
|| true \
@ -568,7 +568,7 @@ function kube::codegen::gen_client() {
fi
done < <(
( kube::codegen::internal::grep -l --null \
-e '+genclient' \
-e '^\s*//\s*+genclient' \
-r "${in_dir}${one_input_api}" \
--include '*.go' \
|| true \