mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #123397 from thockin/kube_codegen_no_git
Don't use git commands in kube_codegen.sh
This commit is contained in:
commit
b069ef6e13
@ -27,17 +27,20 @@ set -o pipefail
|
||||
|
||||
KUBE_CODEGEN_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
|
||||
function kube::codegen::internal::git_find() {
|
||||
# Similar to find but faster and easier to understand. We want to include
|
||||
# modified and untracked files because this might be running against code
|
||||
# which is not tracked by git yet.
|
||||
git ls-files -cmo --exclude-standard "$@"
|
||||
function kube::codegen::internal::findz() {
|
||||
# We use `find` rather than `git ls-files` because sometimes external
|
||||
# projects use this across repos. This is an imperfect wrapper of find,
|
||||
# but good enough for this script.
|
||||
find "$@" -print0
|
||||
}
|
||||
|
||||
function kube::codegen::internal::git_grep() {
|
||||
# We want to include modified and untracked files because this might be
|
||||
# running against code which is not tracked by git yet.
|
||||
git grep --untracked "$@" ":(exclude)vendor/"
|
||||
function kube::codegen::internal::grep() {
|
||||
# We use `grep` rather than `git grep` because sometimes external projects
|
||||
# use this across repos.
|
||||
grep "$@" \
|
||||
--exclude-dir .git \
|
||||
--exclude-dir _output \
|
||||
--exclude-dir vendor
|
||||
}
|
||||
|
||||
# Generate tagged helper code: conversions, deepcopy, and defaults
|
||||
@ -127,9 +130,10 @@ function kube::codegen::gen_helpers() {
|
||||
pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)"
|
||||
input_pkgs+=("${pkg}")
|
||||
done < <(
|
||||
( kube::codegen::internal::git_grep -l --null \
|
||||
( kube::codegen::internal::grep -l --null \
|
||||
-e '+k8s:deepcopy-gen=' \
|
||||
":(glob)${root}"/'**/*.go' \
|
||||
-r "${root}" \
|
||||
--include '*.go' \
|
||||
|| true \
|
||||
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
||||
| LC_ALL=C sort -u
|
||||
@ -138,8 +142,10 @@ function kube::codegen::gen_helpers() {
|
||||
if [ "${#input_pkgs[@]}" != 0 ]; then
|
||||
echo "Generating deepcopy code for ${#input_pkgs[@]} targets"
|
||||
|
||||
kube::codegen::internal::git_find -z \
|
||||
":(glob)${root}"/'**/zz_generated.deepcopy.go' \
|
||||
kube::codegen::internal::findz \
|
||||
"${root}" \
|
||||
-type f \
|
||||
-name zz_generated.deepcopy.go \
|
||||
| xargs -0 rm -f
|
||||
|
||||
local input_args=()
|
||||
@ -161,9 +167,10 @@ function kube::codegen::gen_helpers() {
|
||||
pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)"
|
||||
input_pkgs+=("${pkg}")
|
||||
done < <(
|
||||
( kube::codegen::internal::git_grep -l --null \
|
||||
( kube::codegen::internal::grep -l --null \
|
||||
-e '+k8s:defaulter-gen=' \
|
||||
":(glob)${root}"/'**/*.go' \
|
||||
-r "${root}" \
|
||||
--include '*.go' \
|
||||
|| true \
|
||||
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
||||
| LC_ALL=C sort -u
|
||||
@ -172,8 +179,10 @@ function kube::codegen::gen_helpers() {
|
||||
if [ "${#input_pkgs[@]}" != 0 ]; then
|
||||
echo "Generating defaulter code for ${#input_pkgs[@]} targets"
|
||||
|
||||
kube::codegen::internal::git_find -z \
|
||||
":(glob)${root}"/'**/zz_generated.defaults.go' \
|
||||
kube::codegen::internal::findz \
|
||||
"${root}" \
|
||||
-type f \
|
||||
-name zz_generated.defaults.go \
|
||||
| xargs -0 rm -f
|
||||
|
||||
local input_args=()
|
||||
@ -195,9 +204,10 @@ function kube::codegen::gen_helpers() {
|
||||
pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)"
|
||||
input_pkgs+=("${pkg}")
|
||||
done < <(
|
||||
( kube::codegen::internal::git_grep -l --null \
|
||||
( kube::codegen::internal::grep -l --null \
|
||||
-e '+k8s:conversion-gen=' \
|
||||
":(glob)${root}"/'**/*.go' \
|
||||
-r "${root}" \
|
||||
--include '*.go' \
|
||||
|| true \
|
||||
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
||||
| LC_ALL=C sort -u
|
||||
@ -206,8 +216,10 @@ function kube::codegen::gen_helpers() {
|
||||
if [ "${#input_pkgs[@]}" != 0 ]; then
|
||||
echo "Generating conversion code for ${#input_pkgs[@]} targets"
|
||||
|
||||
kube::codegen::internal::git_find -z \
|
||||
":(glob)${root}"/'**/zz_generated.conversion.go' \
|
||||
kube::codegen::internal::findz \
|
||||
"${root}" \
|
||||
-type f \
|
||||
-name zz_generated.conversion.go \
|
||||
| xargs -0 rm -f
|
||||
|
||||
local input_args=()
|
||||
@ -357,9 +369,10 @@ function kube::codegen::gen_openapi() {
|
||||
pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)"
|
||||
input_pkgs+=("${pkg}")
|
||||
done < <(
|
||||
( kube::codegen::internal::git_grep -l --null \
|
||||
( kube::codegen::internal::grep -l --null \
|
||||
-e '+k8s:openapi-gen=' \
|
||||
":(glob)${root}"/'**/*.go' \
|
||||
-r "${root}" \
|
||||
--include '*.go' \
|
||||
|| true \
|
||||
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
||||
| LC_ALL=C sort -u
|
||||
@ -368,8 +381,10 @@ function kube::codegen::gen_openapi() {
|
||||
if [ "${#input_pkgs[@]}" != 0 ]; then
|
||||
echo "Generating openapi code for ${#input_pkgs[@]} targets"
|
||||
|
||||
kube::codegen::internal::git_find -z \
|
||||
":(glob)${root}"/'**/zz_generated.openapi.go' \
|
||||
kube::codegen::internal::findz \
|
||||
"${root}" \
|
||||
-type f \
|
||||
-name zz_generated.openapi.go \
|
||||
| xargs -0 rm -f
|
||||
|
||||
local inputs=()
|
||||
@ -566,9 +581,10 @@ function kube::codegen::gen_client() {
|
||||
group_versions+=("${leaf2}/${leaf}")
|
||||
fi
|
||||
done < <(
|
||||
( kube::codegen::internal::git_grep -l --null \
|
||||
( kube::codegen::internal::grep -l --null \
|
||||
-e '+genclient' \
|
||||
":(glob)${in_root}${one_input_api}"/'**/*.go' \
|
||||
-r "${in_root}${one_input_api}" \
|
||||
--include '*.go' \
|
||||
|| true \
|
||||
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
||||
| LC_ALL=C sort -u
|
||||
@ -584,9 +600,10 @@ function kube::codegen::gen_client() {
|
||||
|
||||
echo "Generating applyconfig code for ${#input_pkgs[@]} targets"
|
||||
|
||||
( kube::codegen::internal::git_grep -l --null \
|
||||
( kube::codegen::internal::grep -l --null \
|
||||
-e '^// Code generated by applyconfiguration-gen. DO NOT EDIT.$' \
|
||||
":(glob)${out_root}/${applyconfig_subdir}"/'**/*.go' \
|
||||
-r "${out_root}/${applyconfig_subdir}" \
|
||||
--include '*.go' \
|
||||
|| true \
|
||||
) | xargs -0 rm -f
|
||||
|
||||
@ -604,9 +621,10 @@ function kube::codegen::gen_client() {
|
||||
|
||||
echo "Generating client code for ${#group_versions[@]} targets"
|
||||
|
||||
( kube::codegen::internal::git_grep -l --null \
|
||||
( kube::codegen::internal::grep -l --null \
|
||||
-e '^// Code generated by client-gen. DO NOT EDIT.$' \
|
||||
":(glob)${out_root}/${clientset_subdir}"/'**/*.go' \
|
||||
-r "${out_root}/${clientset_subdir}" \
|
||||
--include '*.go' \
|
||||
|| true \
|
||||
) | xargs -0 rm -f
|
||||
|
||||
@ -627,9 +645,10 @@ function kube::codegen::gen_client() {
|
||||
if [ "${watchable}" == "true" ]; then
|
||||
echo "Generating lister code for ${#input_pkgs[@]} targets"
|
||||
|
||||
( kube::codegen::internal::git_grep -l --null \
|
||||
( kube::codegen::internal::grep -l --null \
|
||||
-e '^// Code generated by lister-gen. DO NOT EDIT.$' \
|
||||
":(glob)${out_root}/${listers_subdir}"/'**/*.go' \
|
||||
-r "${out_root}/${listers_subdir}" \
|
||||
--include '*.go' \
|
||||
|| true \
|
||||
) | xargs -0 rm -f
|
||||
|
||||
@ -646,9 +665,10 @@ function kube::codegen::gen_client() {
|
||||
|
||||
echo "Generating informer code for ${#input_pkgs[@]} targets"
|
||||
|
||||
( kube::codegen::internal::git_grep -l --null \
|
||||
( kube::codegen::internal::grep -l --null \
|
||||
-e '^// Code generated by informer-gen. DO NOT EDIT.$' \
|
||||
":(glob)${out_root}/${informers_subdir}"/'**/*.go' \
|
||||
-r "${out_root}/${informers_subdir}" \
|
||||
--include '*.go' \
|
||||
|| true \
|
||||
) | xargs -0 rm -f
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user