-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
/hack: improve shell script in hack #8143
Conversation
hack/dev-build.sh
Outdated
@@ -110,9 +110,9 @@ echo ========== | |||
echo "Deleting cluster ${CLUSTER_NAME}. Elle est finie." | |||
|
|||
kops delete cluster \ | |||
--name $CLUSTER_NAME \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double quote to prevent globbing and word splitting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your effort is appreciated!
as for the || exit
here and likely in other spots as well, maybe we could set -e
at the top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
hack/make-apimachinery.sh
Outdated
|
||
cleanup() { | ||
chmod -R +w "${WORK_DIR}" | ||
rm -rf "${WORK_DIR}" | ||
} | ||
trap cleanup EXIT | ||
|
||
mkdir -p ${WORK_DIR}/go/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double quote to prevent globbing and word splitting
hack/make-gendocs.sh
Outdated
@@ -18,45 +18,45 @@ | |||
|
|||
. $(dirname "${BASH_SOURCE}")/common.sh | |||
|
|||
WORK_DIR=`mktemp -d` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use $(...) notation instead of legacy backticked ...
@@ -12,21 +14,24 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
|
|||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shebang must be on the first line
@@ -12,5 +14,4 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
|
|||
#!/bin/sh -eu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shebang must be on the first line
hack/publish-docs.sh
Outdated
@@ -14,7 +14,7 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
|
|||
if ! [ -z $DEBUG ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommend [ -n .. ] instead of ! [ -z .. ]
hack/verify-bazel.sh
Outdated
@@ -14,7 +15,7 @@ | |||
# limitations under the License. | |||
|
|||
KOPS_ROOT=$(git rev-parse --show-toplevel) | |||
cd ${KOPS_ROOT} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case cd fails.
@@ -25,7 +25,7 @@ changes=$(git status --porcelain || true) | |||
if [ -n "${changes}" ]; then | |||
echo "ERROR: go modules are not up to date; please run: go mod tidy" | |||
echo "changed files:" | |||
printf "${changes}\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use variables in the printf format string. Use printf "..%s.." "$foo"
@@ -23,7 +23,7 @@ export API_OPTIONS="--verify-only" | |||
if make apimachinery-codegen; then | |||
echo "apimachinery is up to date" | |||
else | |||
echo "\n FAIL: - the verify-apimachinery.sh test failed, apimachinery is not up to date" | |||
echo "\n FAIL: - please run the command 'make apimachinery'" | |||
echo -e "\n FAIL: - the verify-apimachinery.sh test failed, apimachinery is not up to date" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "\n FAIL: - the verify-apimachinery.sh test failed, apimachinery is not up to date"
\n FAIL: - the verify-apimachinery.sh test failed, apimachinery is not up to date
--------------->
echo -e "\n FAIL: - the verify-apimachinery.sh test failed, apimachinery is not up to date"
FAIL: - the verify-apimachinery.sh test failed, apimachinery is not up to date
/assign @geojaz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any major problems with this and am in favor of cleaning these scripts up and making them more consistent. I provided some suggestions, but didn't point them out each time.
Was there a specific reason to refactor these files right now or were they broken in your use case?
hack/dev-build.sh
Outdated
@@ -110,9 +110,9 @@ echo ========== | |||
echo "Deleting cluster ${CLUSTER_NAME}. Elle est finie." | |||
|
|||
kops delete cluster \ | |||
--name $CLUSTER_NAME \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your effort is appreciated!
as for the || exit
here and likely in other spots as well, maybe we could set -e
at the top?
@@ -1,4 +1,5 @@ | |||
#!/usr/bin/env bash | |||
|
|||
# Copyright 2017 The Kubernetes Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an open question that I've been running into frequently these days, but don't currently have an answer to. When you touch a file, do you update the boilerplate date? i've seen what appears to be new code PRed with a date in the past, and dates that aren't being updated when code is touched. Do we (cncf/k8s org) have a standard for this? random selection of people who may know: @justinsb @thockin @mikesplain @joshbranham @luxas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we need to talk about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I am unsure so curious to hear from others here
hack/make-apimachinery.sh
Outdated
mkdir -p ${WORK_DIR}/go/ | ||
ln -s ${GOPATH}/src/k8s.io/kops/vendor/ ${WORK_DIR}/go/src | ||
mkdir -p "${WORK_DIR}"/go/ | ||
ln -s "${GOPATH}"/src/k8s.io/kops/vendor/ "${WORK_DIR}"/go/src |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ln -s "${GOPATH}"/src/k8s.io/kops/vendor/ "${WORK_DIR}"/go/src | |
ln -s "${GOPATH}/src/k8s.io/kops/vendor/" "${WORK_DIR}/go/src" |
hack/make-apimachinery.sh
Outdated
|
||
unset GOBIN | ||
GOPATH=${WORK_DIR}/go/ go install -v k8s.io/code-generator/cmd/conversion-gen/ | ||
cp ${WORK_DIR}/go/bin/conversion-gen ${GOPATH}/bin/ | ||
cp "${WORK_DIR}"/go/bin/conversion-gen "${GOPATH}"/bin/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cp "${WORK_DIR}"/go/bin/conversion-gen "${GOPATH}"/bin/ | |
cp "${WORK_DIR}/go/bin/conversion-gen" "${GOPATH}/bin/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and so on. i did not point out each incident of this stylistic suggestion)
hack/dev-build.sh
Outdated
--name $CLUSTER_NAME \ | ||
--state $KOPS_STATE_STORE \ | ||
-v $VERBOSITY \ | ||
--name "$CLUSTER_NAME" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the rest of the interpolations mostly use "${CLUSTER_NAME}"
form. if you're going to add the "'s, I think we may as well go the whole way.
/cc @geojaz |
These changes all look good, and we can always do more cleanups in other PRs. We don't have a position that we know of on updating copyright years. /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justinsb, tanjunchen The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cc @justinsb @mikesplain @rifelpet @robinpercy
/hold
Let's talk about there changes
i have run ./hack/update-header.sh before i commited it.