This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 45e90ec fix: Support version/githash for target api-run (#1200)
45e90ec is described below
commit 45e90ec8e13a1c9659645034f1fd50f0552b93e3
Author: Joey <[email protected]>
AuthorDate: Tue Jan 5 08:17:03 2021 +0800
fix: Support version/githash for target api-run (#1200)
Signed-off-by: imjoey <[email protected]>
---
Makefile | 3 ++-
api/build.sh | 17 +++++++++++++----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 666deb5..ec962c2 100644
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,8 @@ api-test: api-default
### api-run: Run the manager-api
.PHONY: api-run
api-run: api-default
- cd api/ && go run ./cmd/manager
+ api/build.sh --dry-run
+
### api-stop: Stop the manager-api
api-stop:
diff --git a/api/build.sh b/api/build.sh
index fe7a630..d2b9ed5 100755
--- a/api/build.sh
+++ b/api/build.sh
@@ -15,12 +15,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-set -ex
-export ENV=local
-pwd=`pwd`
+set -e
VERSION=$(cat ./api/VERSION)
GITHASH=$(cat ./.githash 2> /dev/null || HASH="ref: HEAD"; while [[ $HASH ==
ref\:* ]]; do HASH="$(cat ".git/$(echo $HASH | cut -d \ -f 2)")"; done; echo
${HASH:0:7})
+GOLDFLAGS="-X github.com/apisix/manager-api/cmd.Version=${VERSION} -X
github.com/apisix/manager-api/cmd.GitHash=${GITHASH}"
+
+# Enter dry-run mode
+if [ "$1" == "--dry-run" ]; then
+ cd ./api && go run -ldflags "${GOLDFLAGS}" ./cmd/manager
+ exit 0
+fi
+
+set -x
+export ENV=local
+pwd=`pwd`
rm -rf output && mkdir -p output/conf && mkdir -p output/dag-to-lua
@@ -32,7 +41,7 @@ if [[ ! -f "dag-to-lua-1.1/lib/dag-to-lua.lua" ]]; then
fi
# build
-cd ./api && go build -o ../output/manager-api -ldflags "-X
github.com/apisix/manager-api/cmd.Version=${VERSION} -X
github.com/apisix/manager-api/cmd.GitHash=${GITHASH}" ./cmd/manager && cd ..
+cd ./api && go build -o ../output/manager-api -ldflags "${GOLDFLAGS}"
./cmd/manager && cd ..
cp ./api/conf/schema.json ./output/conf/schema.json
cp ./api/conf/conf.yaml ./output/conf/conf.yaml