From 79c2b13c74c46912338ce1adbd3b291eca70519d Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Fri, 13 Sep 2024 14:33:38 -0500 Subject: [PATCH] handle spaces in variables --- .evergreen/run-deployed-lambda-aws-tests.sh | 4 ++-- .evergreen/run-fuzz.sh | 4 ++-- .evergreen/run-mongodb-aws-ecs-test.sh | 4 ++-- .evergreen/run-mongodb-aws-test.sh | 4 ++-- .evergreen/run-tests.sh | 4 ++-- etc/check_fmt.sh | 4 ++-- etc/check_modules.sh | 4 ++-- etc/compile_check.sh | 4 ++-- etc/install-libmongocrypt.sh | 4 ++-- etc/run-atlas-test.sh | 4 ++-- etc/run-awskms-test.sh | 4 ++-- etc/run-enterprise-gssapi-test.sh | 4 ++-- etc/run-enterprise-plain-test.sh | 4 ++-- etc/run-oidc-remote-test.sh | 4 ++-- etc/run-oidc-test.sh | 4 ++-- etc/run-serverless-test.sh | 4 ++-- etc/run.sh | 4 ++-- etc/run_docker.sh | 4 ++-- etc/setup-encryption.sh | 4 ++-- 19 files changed, 38 insertions(+), 38 deletions(-) diff --git a/.evergreen/run-deployed-lambda-aws-tests.sh b/.evergreen/run-deployed-lambda-aws-tests.sh index 52ffc1bc03..39ba191779 100755 --- a/.evergreen/run-deployed-lambda-aws-tests.sh +++ b/.evergreen/run-deployed-lambda-aws-tests.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -eux -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh source ${DRIVERS_TOOLS}/.evergreen/atlas/secrets-export.sh diff --git a/.evergreen/run-fuzz.sh b/.evergreen/run-fuzz.sh index 0252aacb92..bd15dad552 100755 --- a/.evergreen/run-fuzz.sh +++ b/.evergreen/run-fuzz.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -eux -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh FUZZTIME=10m diff --git a/.evergreen/run-mongodb-aws-ecs-test.sh b/.evergreen/run-mongodb-aws-ecs-test.sh index 6ac6873194..65f1339e30 100755 --- a/.evergreen/run-mongodb-aws-ecs-test.sh +++ b/.evergreen/run-mongodb-aws-ecs-test.sh @@ -3,8 +3,8 @@ # Script to set up encryption assets and servers. set -eux -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh if [[ -z "$1" ]]; then echo "usage: $0 " diff --git a/.evergreen/run-mongodb-aws-test.sh b/.evergreen/run-mongodb-aws-test.sh index 1efe2068dc..63ac44da61 100755 --- a/.evergreen/run-mongodb-aws-test.sh +++ b/.evergreen/run-mongodb-aws-test.sh @@ -3,8 +3,8 @@ # Script to set up encryption assets and servers. set -eux -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh # Supported/used environment variables: # MONGODB_URI Set the URI, including an optional username/password to use diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index 9bfe76b3ff..7d3effbe2a 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -eux -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh export PKG_CONFIG_PATH=$(pwd)/install/libmongocrypt/lib64/pkgconfig export LD_LIBRARY_PATH=$(pwd)/install/libmongocrypt/lib64 diff --git a/etc/check_fmt.sh b/etc/check_fmt.sh index 4999cd55f8..26a854aade 100755 --- a/etc/check_fmt.sh +++ b/etc/check_fmt.sh @@ -3,8 +3,8 @@ # Runs go fmt on all packages in the repo and checks that *_example_test.go files have wrapped lines. set -eu -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh gofmt_out="$(go fmt ./...)" diff --git a/etc/check_modules.sh b/etc/check_modules.sh index ee163dff89..7481aacf29 100755 --- a/etc/check_modules.sh +++ b/etc/check_modules.sh @@ -5,8 +5,8 @@ # tidy" and expect that no unrelated changes are made to the "go.mod" file. set -eu -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh mods=$(find . -name go.mod) exit_code=0 diff --git a/etc/compile_check.sh b/etc/compile_check.sh index 0a43f7d0b1..55b3f7abf4 100755 --- a/etc/compile_check.sh +++ b/etc/compile_check.sh @@ -6,8 +6,8 @@ GC=go COMPILE_CHECK_DIR="internal/cmd/compilecheck" DEV_MIN_VERSION=1.19 -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh # version will flatten a version string of upto 4 components for inequality # comparison. diff --git a/etc/install-libmongocrypt.sh b/etc/install-libmongocrypt.sh index 7af2a2a0d5..e788bce15e 100755 --- a/etc/install-libmongocrypt.sh +++ b/etc/install-libmongocrypt.sh @@ -3,8 +3,8 @@ # This script installs libmongocrypt into an "install" directory. set -eux -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh LIBMONGOCRYPT_TAG="1.11.0" diff --git a/etc/run-atlas-test.sh b/etc/run-atlas-test.sh index 3a1a38fedd..a2c37a1b02 100755 --- a/etc/run-atlas-test.sh +++ b/etc/run-atlas-test.sh @@ -4,8 +4,8 @@ set -eu set +x -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh # Get the atlas secrets. . ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/atlas_connect diff --git a/etc/run-awskms-test.sh b/etc/run-awskms-test.sh index bfb21b74c8..2a13f3acff 100755 --- a/etc/run-awskms-test.sh +++ b/etc/run-awskms-test.sh @@ -3,8 +3,8 @@ # Runs the awskms test. set -eu -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh echo "Building build-kms-test ... begin" BUILD_TAGS="-tags=cse" \ diff --git a/etc/run-enterprise-gssapi-test.sh b/etc/run-enterprise-gssapi-test.sh index 2b9ef64579..2b5d4b9552 100755 --- a/etc/run-enterprise-gssapi-test.sh +++ b/etc/run-enterprise-gssapi-test.sh @@ -3,8 +3,8 @@ # Runs the enterprise auth tests with gssapi credentials. set -eu -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh . ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/enterprise_auth if [ "Windows_NT" = "${OS:-}" ]; then diff --git a/etc/run-enterprise-plain-test.sh b/etc/run-enterprise-plain-test.sh index fb850505c8..0f227c830d 100755 --- a/etc/run-enterprise-plain-test.sh +++ b/etc/run-enterprise-plain-test.sh @@ -3,8 +3,8 @@ # Runs the enterprise auth tests with plain credentials. set -eu -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh . ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/enterprise_auth export MONGODB_URI="mongodb://${SASL_USER}:${SASL_PASS}@${SASL_HOST}:${SASL_PORT}/ldap?authMechanism=PLAIN" diff --git a/etc/run-oidc-remote-test.sh b/etc/run-oidc-remote-test.sh index 5c5e80786e..d95d194a89 100755 --- a/etc/run-oidc-remote-test.sh +++ b/etc/run-oidc-remote-test.sh @@ -3,8 +3,8 @@ # Runs oidc auth remote tests. set -eu -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh OIDC_DRIVERS_TAR_FILE=/tmp/mongo-go-driver.tar.gz # we need to statically link libc to avoid the situation where the VM has a different diff --git a/etc/run-oidc-test.sh b/etc/run-oidc-test.sh index f87bbb9e37..c563a670d1 100755 --- a/etc/run-oidc-test.sh +++ b/etc/run-oidc-test.sh @@ -7,8 +7,8 @@ echo "Running MONGODB-OIDC authentication tests" OIDC_ENV="${OIDC_ENV:-"test"}" -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh if [ $OIDC_ENV == "test" ]; then # Make sure DRIVERS_TOOLS is set. diff --git a/etc/run-serverless-test.sh b/etc/run-serverless-test.sh index 33cf235127..75e357a426 100755 --- a/etc/run-serverless-test.sh +++ b/etc/run-serverless-test.sh @@ -3,8 +3,8 @@ # Runs the serverless tests. set -eu -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh source ${DRIVERS_TOOLS}/.evergreen/serverless/secrets-export.sh AUTH="auth" \ diff --git a/etc/run.sh b/etc/run.sh index 013287313f..2c244111e0 100755 --- a/etc/run.sh +++ b/etc/run.sh @@ -3,8 +3,8 @@ # Go Driver task runner set -eu -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh TEST_TIMEOUT=1800 diff --git a/etc/run_docker.sh b/etc/run_docker.sh index 55526008b9..2140863abb 100755 --- a/etc/run_docker.sh +++ b/etc/run_docker.sh @@ -3,8 +3,8 @@ # Script to run a test suite in docker locally set -eux -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh if [ -z "$DRIVERS_TOOLS" ]; then echo "Please set DRIVERS_TOOLS env variable." diff --git a/etc/setup-encryption.sh b/etc/setup-encryption.sh index b90c137785..8fc21f8e9f 100755 --- a/etc/setup-encryption.sh +++ b/etc/setup-encryption.sh @@ -3,8 +3,8 @@ # Script to set up encryption assets and servers. set -eux -# Source .env file if it exists -test -f .env && export $(grep -v '^#' .env | xargs -0) || true +# Source .env file if it exists. +. ./etc/dotenv.sh if [ -z "$DRIVERS_TOOLS" ]; then echo "Please define DRIVERS_TOOLS variable"