mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 19:23:40 +00:00
Codegen: use plain grep instead of git grep
Some consumers want to operate across repositories, so git just gets in the way.
This commit is contained in:
parent
8a0147c882
commit
527d2ea9d0
@ -34,10 +34,13 @@ function kube::codegen::internal::git_find() {
|
|||||||
git ls-files -cmo --exclude-standard "$@"
|
git ls-files -cmo --exclude-standard "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function kube::codegen::internal::git_grep() {
|
function kube::codegen::internal::grep() {
|
||||||
# We want to include modified and untracked files because this might be
|
# We use `grep` rather than `git grep` because sometimes external projects
|
||||||
# running against code which is not tracked by git yet.
|
# use this across repos.
|
||||||
git grep --untracked "$@" ":(exclude)vendor/"
|
grep "$@" \
|
||||||
|
--exclude-dir .git \
|
||||||
|
--exclude-dir _output \
|
||||||
|
--exclude-dir vendor
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate tagged helper code: conversions, deepcopy, and defaults
|
# 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 .)"
|
pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)"
|
||||||
input_pkgs+=("${pkg}")
|
input_pkgs+=("${pkg}")
|
||||||
done < <(
|
done < <(
|
||||||
( kube::codegen::internal::git_grep -l --null \
|
( kube::codegen::internal::grep -l --null \
|
||||||
-e '+k8s:deepcopy-gen=' \
|
-e '+k8s:deepcopy-gen=' \
|
||||||
":(glob)${root}"/'**/*.go' \
|
-r "${root}" \
|
||||||
|
--include '*.go' \
|
||||||
|| true \
|
|| true \
|
||||||
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
||||||
| LC_ALL=C sort -u
|
| LC_ALL=C sort -u
|
||||||
@ -161,9 +165,10 @@ function kube::codegen::gen_helpers() {
|
|||||||
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 --null \
|
( kube::codegen::internal::grep -l --null \
|
||||||
-e '+k8s:defaulter-gen=' \
|
-e '+k8s:defaulter-gen=' \
|
||||||
":(glob)${root}"/'**/*.go' \
|
-r "${root}" \
|
||||||
|
--include '*.go' \
|
||||||
|| true \
|
|| true \
|
||||||
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
||||||
| LC_ALL=C sort -u
|
| LC_ALL=C sort -u
|
||||||
@ -195,9 +200,10 @@ function kube::codegen::gen_helpers() {
|
|||||||
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 --null \
|
( kube::codegen::internal::grep -l --null \
|
||||||
-e '+k8s:conversion-gen=' \
|
-e '+k8s:conversion-gen=' \
|
||||||
":(glob)${root}"/'**/*.go' \
|
-r "${root}" \
|
||||||
|
--include '*.go' \
|
||||||
|| true \
|
|| true \
|
||||||
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
||||||
| LC_ALL=C sort -u
|
| LC_ALL=C sort -u
|
||||||
@ -357,9 +363,10 @@ function kube::codegen::gen_openapi() {
|
|||||||
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 --null \
|
( kube::codegen::internal::grep -l --null \
|
||||||
-e '+k8s:openapi-gen=' \
|
-e '+k8s:openapi-gen=' \
|
||||||
":(glob)${root}"/'**/*.go' \
|
-r "${root}" \
|
||||||
|
--include '*.go' \
|
||||||
|| true \
|
|| true \
|
||||||
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
||||||
| LC_ALL=C sort -u
|
| LC_ALL=C sort -u
|
||||||
@ -566,9 +573,10 @@ function kube::codegen::gen_client() {
|
|||||||
group_versions+=("${leaf2}/${leaf}")
|
group_versions+=("${leaf2}/${leaf}")
|
||||||
fi
|
fi
|
||||||
done < <(
|
done < <(
|
||||||
( kube::codegen::internal::git_grep -l --null \
|
( kube::codegen::internal::grep -l --null \
|
||||||
-e '+genclient' \
|
-e '+genclient' \
|
||||||
":(glob)${in_root}${one_input_api}"/'**/*.go' \
|
-r "${in_root}${one_input_api}" \
|
||||||
|
--include '*.go' \
|
||||||
|| true \
|
|| true \
|
||||||
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
) | while read -r -d $'\0' F; do dirname "${F}"; done \
|
||||||
| LC_ALL=C sort -u
|
| LC_ALL=C sort -u
|
||||||
@ -584,9 +592,10 @@ function kube::codegen::gen_client() {
|
|||||||
|
|
||||||
echo "Generating applyconfig code for ${#input_pkgs[@]} targets"
|
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.$' \
|
-e '^// Code generated by applyconfiguration-gen. DO NOT EDIT.$' \
|
||||||
":(glob)${out_root}/${applyconfig_subdir}"/'**/*.go' \
|
-r "${out_root}/${applyconfig_subdir}" \
|
||||||
|
--include '*.go' \
|
||||||
|| true \
|
|| true \
|
||||||
) | xargs -0 rm -f
|
) | xargs -0 rm -f
|
||||||
|
|
||||||
@ -604,9 +613,10 @@ function kube::codegen::gen_client() {
|
|||||||
|
|
||||||
echo "Generating client code for ${#group_versions[@]} targets"
|
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.$' \
|
-e '^// Code generated by client-gen. DO NOT EDIT.$' \
|
||||||
":(glob)${out_root}/${clientset_subdir}"/'**/*.go' \
|
-r "${out_root}/${clientset_subdir}" \
|
||||||
|
--include '*.go' \
|
||||||
|| true \
|
|| true \
|
||||||
) | xargs -0 rm -f
|
) | xargs -0 rm -f
|
||||||
|
|
||||||
@ -627,9 +637,10 @@ function kube::codegen::gen_client() {
|
|||||||
if [ "${watchable}" == "true" ]; then
|
if [ "${watchable}" == "true" ]; then
|
||||||
echo "Generating lister code for ${#input_pkgs[@]} targets"
|
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.$' \
|
-e '^// Code generated by lister-gen. DO NOT EDIT.$' \
|
||||||
":(glob)${out_root}/${listers_subdir}"/'**/*.go' \
|
-r "${out_root}/${listers_subdir}" \
|
||||||
|
--include '*.go' \
|
||||||
|| true \
|
|| true \
|
||||||
) | xargs -0 rm -f
|
) | xargs -0 rm -f
|
||||||
|
|
||||||
@ -646,9 +657,10 @@ function kube::codegen::gen_client() {
|
|||||||
|
|
||||||
echo "Generating informer code for ${#input_pkgs[@]} targets"
|
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.$' \
|
-e '^// Code generated by informer-gen. DO NOT EDIT.$' \
|
||||||
":(glob)${out_root}/${informers_subdir}"/'**/*.go' \
|
-r "${out_root}/${informers_subdir}" \
|
||||||
|
--include '*.go' \
|
||||||
|| true \
|
|| true \
|
||||||
) | xargs -0 rm -f
|
) | xargs -0 rm -f
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user