Merge pull request #121411 from thockin/master

Fix kube_codegen for some uncovered external cases
This commit is contained in:
Kubernetes Prow Robot 2023-12-13 21:26:18 +01:00 committed by GitHub
commit d6fe8dbc6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,16 +118,16 @@ function kube::codegen::gen_helpers() {
# Deepcopy # Deepcopy
# #
local input_pkgs=() local input_pkgs=()
while read -r file; do while read -r dir; do
dir="$(dirname "${file}")"
pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)" pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)"
input_pkgs+=("${pkg}") input_pkgs+=("${pkg}")
done < <( done < <(
( kube::codegen::internal::git_grep -l \ ( kube::codegen::internal::git_grep -l --null \
-e '+k8s:deepcopy-gen=' \ -e '+k8s:deepcopy-gen=' \
":(glob)${root}"/'**/*.go' \ ":(glob)${root}"/'**/*.go' \
|| true \ || true \
) | LC_ALL=C sort -u ) | xargs -0 -n1 dirname \
| LC_ALL=C sort -u
) )
if [ "${#input_pkgs[@]}" != 0 ]; then if [ "${#input_pkgs[@]}" != 0 ]; then
@ -152,16 +152,16 @@ function kube::codegen::gen_helpers() {
# Defaults # Defaults
# #
local input_pkgs=() local input_pkgs=()
while read -r file; do while read -r dir; do
dir="$(dirname "${file}")"
pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)" pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)"
input_pkgs+=("${pkg}") input_pkgs+=("${pkg}")
done < <( done < <(
( kube::codegen::internal::git_grep -l \ ( kube::codegen::internal::git_grep -l --null \
-e '+k8s:defaulter-gen=' \ -e '+k8s:defaulter-gen=' \
":(glob)${root}"/'**/*.go' \ ":(glob)${root}"/'**/*.go' \
|| true \ || true \
) | LC_ALL=C sort -u ) | xargs -0 -n1 dirname \
| LC_ALL=C sort -u
) )
if [ "${#input_pkgs[@]}" != 0 ]; then if [ "${#input_pkgs[@]}" != 0 ]; then
@ -186,16 +186,16 @@ function kube::codegen::gen_helpers() {
# Conversions # Conversions
# #
local input_pkgs=() local input_pkgs=()
while read -r file; do while read -r dir; do
dir="$(dirname "${file}")"
pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)" pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)"
input_pkgs+=("${pkg}") input_pkgs+=("${pkg}")
done < <( done < <(
( kube::codegen::internal::git_grep -l \ ( kube::codegen::internal::git_grep -l --null \
-e '+k8s:conversion-gen=' \ -e '+k8s:conversion-gen=' \
":(glob)${root}"/'**/*.go' \ ":(glob)${root}"/'**/*.go' \
|| true \ || true \
) | LC_ALL=C sort -u ) | xargs -0 -n1 dirname \
| LC_ALL=C sort -u
) )
if [ "${#input_pkgs[@]}" != 0 ]; then if [ "${#input_pkgs[@]}" != 0 ]; then
@ -347,16 +347,16 @@ function kube::codegen::gen_openapi() {
root="$(cd "${root}" && pwd -P)" root="$(cd "${root}" && pwd -P)"
local input_pkgs=( "${extra_pkgs[@]:+"${extra_pkgs[@]}"}") local input_pkgs=( "${extra_pkgs[@]:+"${extra_pkgs[@]}"}")
while read -r file; do while read -r dir; do
dir="$(dirname "${file}")"
pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)" pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)"
input_pkgs+=("${pkg}") input_pkgs+=("${pkg}")
done < <( done < <(
( kube::codegen::internal::git_grep -l \ ( kube::codegen::internal::git_grep -l --null \
-e '+k8s:openapi-gen=' \ -e '+k8s:openapi-gen=' \
":(glob)${root}"/'**/*.go' \ ":(glob)${root}"/'**/*.go' \
|| true \ || true \
) | LC_ALL=C sort -u ) | xargs -0 -n1 dirname \
| LC_ALL=C sort -u
) )
if [ "${#input_pkgs[@]}" != 0 ]; then if [ "${#input_pkgs[@]}" != 0 ]; then
@ -396,10 +396,15 @@ function kube::codegen::gen_openapi() {
# #
# Args: # Args:
# --input-pkg-root <string> # --input-pkg-root <string>
# The root package under which to search for types.go files which request # The root package under which to search for *.go files which request
# clients to be generated. This must be Go package syntax, e.g. # clients to be generated. This must be Go package syntax, e.g.
# "k8s.io/foo/bar". # "k8s.io/foo/bar".
# #
# --one-input-api <string>
# A specific API (a directory) under the --input-pkg-root for which to
# generate a client. If this is not set, clients for all APIs under the
# input root will be generated (under the --output-pkg-root).
#
# --output-pkg-root <string> # --output-pkg-root <string>
# The root package into which generated directories and files will be # The root package into which generated directories and files will be
# placed. This must be Go package syntax, e.g. "k8s.io/foo/bar". # placed. This must be Go package syntax, e.g. "k8s.io/foo/bar".
@ -435,6 +440,7 @@ function kube::codegen::gen_openapi() {
# #
function kube::codegen::gen_client() { function kube::codegen::gen_client() {
local in_pkg_root="" local in_pkg_root=""
local one_input_api=""
local out_pkg_root="" local out_pkg_root=""
local out_base="" # gengo needs the output dir must be $out_base/$out_pkg_root local out_base="" # gengo needs the output dir must be $out_base/$out_pkg_root
local clientset_subdir="clientset" local clientset_subdir="clientset"
@ -453,6 +459,10 @@ function kube::codegen::gen_client() {
in_pkg_root="$2" in_pkg_root="$2"
shift 2 shift 2
;; ;;
"--one-input-api")
one_input_api="/$2"
shift 2
;;
"--output-pkg-root") "--output-pkg-root")
out_pkg_root="$2" out_pkg_root="$2"
shift 2 shift 2
@ -538,8 +548,7 @@ function kube::codegen::gen_client() {
local group_versions=() local group_versions=()
local input_pkgs=() local input_pkgs=()
while read -r file; do while read -r dir; do
dir="$(dirname "${file}")"
pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)" pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)"
leaf="$(basename "${dir}")" leaf="$(basename "${dir}")"
if grep -E -q '^v[0-9]+((alpha|beta)[0-9]+)?$' <<< "${leaf}"; then if grep -E -q '^v[0-9]+((alpha|beta)[0-9]+)?$' <<< "${leaf}"; then
@ -550,11 +559,12 @@ function kube::codegen::gen_client() {
group_versions+=("${leaf2}/${leaf}") group_versions+=("${leaf2}/${leaf}")
fi fi
done < <( done < <(
( kube::codegen::internal::git_grep -l \ ( kube::codegen::internal::git_grep -l --null \
-e '+genclient' \ -e '+genclient' \
":(glob)${in_root}"/'**/types.go' \ ":(glob)${in_root}${one_input_api}"/'**/*.go' \
|| true \ || true \
) | LC_ALL=C sort -u ) | xargs -0 -n1 dirname \
| LC_ALL=C sort -u
) )
if [ "${#group_versions[@]}" == 0 ]; then if [ "${#group_versions[@]}" == 0 ]; then