scripts: declare ROOT closer to where it's used, and some DRY changes

This also prevents shellcheck from complaining about a possibly
undefined variable.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-07-20 12:10:37 +02:00
parent dba0ef4eb5
commit 6c257552a7
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
5 changed files with 12 additions and 7 deletions

View File

@ -14,10 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
basedir="$(dirname "${BASH_SOURCE[0]}")"
source "${basedir}/utils.sh"
ROOT="$( cd "${basedir}" && pwd )"/../..
cd "${ROOT}"
# FOCUS focuses the test to run.

View File

@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/../..
IS_WINDOWS=0
if [ -v "OS" ] && [ "${OS}" == "Windows_NT" ]; then
IS_WINDOWS=1

View File

@ -27,6 +27,8 @@ set -o pipefail
basedir="$(dirname "${BASH_SOURCE[0]}")"
source "${basedir}/build-utils.sh"
source "${basedir}/init-buildx.sh"
ROOT="$( cd "$basedir" && pwd )"/..
cd "${ROOT}"
# ignore errors if the image already exists

View File

@ -14,10 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
# PROJECT is the gce project to upload tarball.
PROJECT=${PROJECT:-"k8s-cri-containerd"}
: "${PROJECT:=k8s-cri-containerd}"
# GOOGLE_APPLICATION_CREDENTIALS is the path of service account file.
if [ -z "${GOOGLE_APPLICATION_CREDENTIALS:-""}" ]; then

View File

@ -22,7 +22,10 @@ set -o errexit
set -o nounset
set -o pipefail
source "$(dirname "${BASH_SOURCE[0]}")/build-utils.sh"
basedir="$(dirname "${BASH_SOURCE[0]}")"
source "${basedir}/build-utils.sh"
ROOT="$( cd "${basedir}" && pwd )"/..
cd "${ROOT}"
# Make sure output directory is clean.