Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen: set LC_ALL and unset GREP_OPTIONS #116141

Merged
merged 1 commit into from Feb 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 20 additions & 14 deletions hack/update-codegen.sh
Expand Up @@ -38,6 +38,12 @@ PRJ_SRC_PATH="k8s.io/kubernetes"
BOILERPLATE_FILENAME="vendor/k8s.io/code-generator/hack/boilerplate.go.txt"
APPLYCONFIG_PKG="k8s.io/client-go/applyconfigurations"

# Any time we call sort, we want it in the same locale.
export LC_ALL="C"

# Work around for older grep tools which might have options we don't want.
unset GREP_OPTIONS

if [[ "${DBG_CODEGEN}" == 1 ]]; then
kube::log::status "DBG: starting generated_files"
fi
Expand Down Expand Up @@ -101,7 +107,7 @@ function codegen::protobuf() {
cmd pkg staging \
| xargs -0 -n1 dirname \
| sed 's|^|k8s.io/kubernetes/|;s|k8s.io/kubernetes/staging/src/||' \
| LC_ALL=C sort -u)
| sort -u)

kube::log::status "Generating protobufs for ${#apis[@]} targets"
if [[ "${DBG_CODEGEN}" == 1 ]]; then
Expand Down Expand Up @@ -221,9 +227,9 @@ function codegen::prerelease() {
fi
local tag_dirs=()
kube::util::read-array tag_dirs < <( \
grep -l --null --color=never '+k8s:prerelease-lifecycle-gen=true' "${ALL_K8S_TAG_FILES[@]}" \
grep -l --null '+k8s:prerelease-lifecycle-gen=true' "${ALL_K8S_TAG_FILES[@]}" \
| xargs -0 -n1 dirname \
| LC_ALL=C sort -u)
| sort -u)
if [[ "${DBG_CODEGEN}" == 1 ]]; then
kube::log::status "DBG: found ${#tag_dirs[@]} +k8s:prerelease-lifecycle-gen tagged dirs"
fi
Expand Down Expand Up @@ -284,9 +290,9 @@ function codegen::deepcopy() {
fi
local tag_dirs=()
kube::util::read-array tag_dirs < <( \
grep -l --null --color=never '+k8s:deepcopy-gen=' "${ALL_K8S_TAG_FILES[@]}" \
grep -l --null '+k8s:deepcopy-gen=' "${ALL_K8S_TAG_FILES[@]}" \
| xargs -0 -n1 dirname \
| LC_ALL=C sort -u)
| sort -u)
if [[ "${DBG_CODEGEN}" == 1 ]]; then
kube::log::status "DBG: found ${#tag_dirs[@]} +k8s:deepcopy-gen tagged dirs"
fi
Expand Down Expand Up @@ -354,9 +360,9 @@ function codegen::defaults() {
fi
local tag_dirs=()
kube::util::read-array tag_dirs < <( \
grep -l --null --color=never '+k8s:defaulter-gen=' "${ALL_K8S_TAG_FILES[@]}" \
grep -l --null '+k8s:defaulter-gen=' "${ALL_K8S_TAG_FILES[@]}" \
| xargs -0 -n1 dirname \
| LC_ALL=C sort -u)
| sort -u)
if [[ "${DBG_CODEGEN}" == 1 ]]; then
kube::log::status "DBG: found ${#tag_dirs[@]} +k8s:defaulter-gen tagged dirs"
fi
Expand Down Expand Up @@ -429,9 +435,9 @@ function codegen::conversions() {
fi
local tag_dirs=()
kube::util::read-array tag_dirs < <(\
grep -l --null --color=never '^// *+k8s:conversion-gen=' "${ALL_K8S_TAG_FILES[@]}" \
grep -l --null '^// *+k8s:conversion-gen=' "${ALL_K8S_TAG_FILES[@]}" \
| xargs -0 -n1 dirname \
| LC_ALL=C sort -u)
| sort -u)
if [[ "${DBG_CODEGEN}" == 1 ]]; then
kube::log::status "DBG: found ${#tag_dirs[@]} +k8s:conversion-gen tagged dirs"
fi
Expand Down Expand Up @@ -645,9 +651,9 @@ function codegen::openapi() {

local tag_dirs=()
kube::util::read-array tag_dirs < <(
grep -l --null --color=never '+k8s:openapi-gen=' $(indirect_array "${prefix}_tag_files") \
grep -l --null '+k8s:openapi-gen=' $(indirect_array "${prefix}_tag_files") \
| xargs -0 -n1 dirname \
| LC_ALL=C sort -u)
| sort -u)

if [[ "${DBG_CODEGEN}" == 1 ]]; then
kube::log::status "DBG: found ${#tag_dirs[@]} +k8s:openapi-gen tagged dirs for ${prefix}"
Expand Down Expand Up @@ -707,7 +713,7 @@ function codegen::applyconfigs() {
cd "${KUBE_ROOT}/staging/src"
git_find -z ':(glob)k8s.io/api/**/types.go' \
| xargs -0 -n1 dirname \
| LC_ALL=C sort -u)
| sort -u)
ext_apis+=("k8s.io/apimachinery/pkg/apis/meta/v1")

kube::log::status "Generating apply-config code for ${#ext_apis[@]} targets"
Expand Down Expand Up @@ -803,7 +809,7 @@ function codegen::listers() {
cd "${KUBE_ROOT}/staging/src"
git_find -z ':(glob)k8s.io/api/**/types.go' \
| xargs -0 -n1 dirname \
| LC_ALL=C sort -u)
| sort -u)

kube::log::status "Generating lister code for ${#ext_apis[@]} targets"
if [[ "${DBG_CODEGEN}" == 1 ]]; then
Expand Down Expand Up @@ -843,7 +849,7 @@ function codegen::informers() {
cd "${KUBE_ROOT}/staging/src"
git_find -z ':(glob)k8s.io/api/**/types.go' \
| xargs -0 -n1 dirname \
| LC_ALL=C sort -u)
| sort -u)

kube::log::status "Generating informer code for ${#ext_apis[@]} targets"
if [[ "${DBG_CODEGEN}" == 1 ]]; then
Expand Down