Skip to content

Commit

Permalink
scripts: codegen helper portability tweaks (#4358)
Browse files Browse the repository at this point in the history
1) BSD sed (by default on macOS) doesn't support `\L` so just use
   `awk` which should work on anything remotely POSIX-y

2) Codegen script has `nounset` so need to check if variables are
   defined in a very particular way to make Bash happy
  • Loading branch information
milas committed Mar 23, 2021
1 parent e5a84e4 commit 37855e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/api-new-type.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fi
# where the first is used in YAML and the second is used in HTTP endpoints
#
# shellcheck disable=SC2001
TYPE_NAME_LOWER=$(echo "$TYPE_NAME" | sed -e 's/^\(.*\)$/\L\1/g')
TYPE_NAME_LOWER=$(echo "$TYPE_NAME" | awk '{print tolower($0)}')
if [[ "$TYPE_NAME" == "$TYPE_NAME_LOWER" ]]; then
echo "Error: type name must be uppercase"
exit 1
Expand Down
4 changes: 2 additions & 2 deletions scripts/update-codegen-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -o errexit
set -o nounset
set -o pipefail

if [[ "$CODEGEN_USER" != "" ]]; then
if [[ -n "${CODEGEN_USER-}" ]]; then
useradd "$CODEGEN_USER"
fi

Expand Down Expand Up @@ -50,7 +50,7 @@ bash "${CODEGEN_PKG}/generate-internal-groups.sh" "deepcopy,defaulter,openapi" \
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../../.." \
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt"

if [[ "$CODEGEN_USER" != "" ]]; then
if [[ -n "${CODEGEN_USER-}" ]]; then
chown "$CODEGEN_USER" -R pkg/clientset
chown "$CODEGEN_USER" -R pkg/informers
chown "$CODEGEN_USER" -R pkg/listers
Expand Down

0 comments on commit 37855e4

Please sign in to comment.