From 8b697a58facfc72fb2f73fa78a8402ba7a4ba0f8 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 8 Nov 2021 09:01:33 -0800 Subject: [PATCH] Add build.sh for observability dashboards Signed-off-by: Joshua Li --- .../observabilityDashboards/build.sh | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 scripts/components/observabilityDashboards/build.sh diff --git a/scripts/components/observabilityDashboards/build.sh b/scripts/components/observabilityDashboards/build.sh new file mode 100755 index 0000000000..259768f226 --- /dev/null +++ b/scripts/components/observabilityDashboards/build.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. + +set -ex + +function usage() { + echo "Usage: $0 [args]" + echo "" + echo "Arguments:" + echo -e "-v VERSION\t[Required] OpenSearch version." + echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'." + echo -e "-p PLATFORM\t[Optional] Platform, ignored." + echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored." + echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'." + echo -e "-h help" +} + +while getopts ":h:v:s:o:p:a:" arg; do + case $arg in + h) + usage + exit 1 + ;; + v) + VERSION=$OPTARG + ;; + s) + SNAPSHOT=$OPTARG + ;; + o) + OUTPUT=$OPTARG + ;; + p) + PLATFORM=$OPTARG + ;; + a) + ARCHITECTURE=$OPTARG + ;; + :) + echo "Error: -${OPTARG} requires an argument" + usage + exit 1 + ;; + ?) + echo "Invalid option: -${arg}" + exit 1 + ;; + esac +done + +if [ -z "$VERSION" ]; then + echo "Error: You must specify the OpenSearch Dashboards version" + usage + exit 1 +fi + +[ -z "$OUTPUT" ] && OUTPUT=artifacts + +mkdir -p $OUTPUT/plugins +# For hybrid plugin it actually resides in 'trace-analytics/dashboards-observability' +PLUGIN_FOLDER=$(basename "$PWD") +PLUGIN_NAME=$(basename $(dirname "$PWD")) +# TODO: [CLEANUP] Needed OpenSearch Dashboards git repo to build the required modules for plugins +# This makes it so there is a dependency on having Dashboards pulled already. +cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins +echo "BUILD MODULES FOR $PLUGIN_NAME" +(cd ../../OpenSearch-Dashboards && yarn osd bootstrap) +echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" +(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build) +echo "COPY $PLUGIN_NAME.zip" +cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION.zip $OUTPUT/plugins/ +rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER