From a167d5460898925034e09e1643bf70c52de81981 Mon Sep 17 00:00:00 2001 From: Ryan Tidwell Date: Wed, 24 Jun 2020 14:14:36 -0500 Subject: [PATCH] build: Enable -mod build flag to be toggled via environment variable This change will enable builds to be performed with the option of passing the -mod flag to 'go build'. This can be done by optionally setting the MODMODE environment variable prior to building. For example, toggling the -mod setting for the build can be accomplished as follows: ``` $ MODMODE=vendor ./build ``` Signed-off-by: Ryan Tidwell --- build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build b/build index 56d5155dd..882a23e59 100755 --- a/build +++ b/build @@ -44,7 +44,11 @@ if [ "$GO111MODULE" == "off" ]; then else # build with go modules export GO111MODULE=on + BUILD_ARGS=(-o ${DEST_DIR}/multus -tags no_openssl) + if [ -n "$MODMODE" ]; then + BUILD_ARGS+=(-mod "$MODMODE") + fi echo "Building plugins" - go build -o ${DEST_DIR}/multus -tags no_openssl -ldflags "${LDFLAGS}" "$@" ./multus + go build ${BUILD_ARGS[*]} -ldflags "${LDFLAGS}" "$@" ./multus fi