Skip to content

Commit

Permalink
Copy the OpenSearch-Dashboards git package to ~/.cache folder when bu…
Browse files Browse the repository at this point in the history
…ilding the OpenSearch-Dashboards component. Also create the load_dashboard_from_cache function for plugin build to reuse OpenSearch-Dashboards source code. This way allows individual plugin to build independently, opensearch-project#606

Signed-off-by: Tengda He <tengh@amazon.com>
  • Loading branch information
Tengda-He committed Oct 27, 2021
1 parent 894f07d commit 1bf1ed9
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ONBOARDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This document describes steps to onboard a new plugin to release workflow for co

2. Create a `scripts/build.sh` if you have specific requirements that are not covered by the [default build.sh script](/scripts/default/build.sh) and commit it to your repository.

3. Ensure your `build.sh` reads and passes along both `-Dbuild.snapshot=` and `-Dopensearch.version=` flags. Snapshot builds should produce a -SNAPSHOT tagged artifact for example `opensearch-plugin-1.1.0.0-SNAPSHOT.zip` where a release build of the same component would produce `opensearch-plugin-1.1.0.0.zip`.
3. Ensure your `build.sh` reads and passes along both `-Dbuild.snapshot=` and `-Dopensearch.version=` flags. Snapshot builds should produce a -SNAPSHOT tagged artifact for example `opensearch-plugin-1.1.0.0-SNAPSHOT.zip` where a release build of the same component would produce `opensearch-plugin-1.1.0.0.zip`. If building a opensearch-dashboards plugin be sure to have the opensearch-dashboards core already in cache.

4. Execute `./build.sh` to ensure your component builds and all artifacts are correctly placed into ./artifacts/ with correct output names.

Expand Down
5 changes: 5 additions & 0 deletions scripts/components/OpenSearch-Dashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ case $ARCHITECTURE in
;;
esac

echo "Copying dashboard to .cache for reuse"
rm -rf ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/
mkdir -p ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/
cp -r . ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/

echo "Building node modules for core"
yarn osd bootstrap

Expand Down
15 changes: 15 additions & 0 deletions scripts/components/ganttChartDashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ function usage() {
echo -e "-h help"
}

function load_opensearch_dashboards_from_cache() {
if [ ! -d ../OpenSearch-Dashboards ]; then
echo "No OpenSearch-Dashboards folder found, trying to load from cache"
if [ -d ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ]; then
echo "Copy OpenSearch-Dashboards from cache"
cp -r ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ../../
else
echo "No correct version OpenSearch-Dashboards found from cache,
please run: ./build.sh manifests/1.1.0/opensearch-dashboards-1.1.0.yml --component=OpenSearch-Dashboards"
exit 1
fi
fi
}

while getopts ":h:v:s:o:p:a:" arg; do
case $arg in
h)
Expand Down Expand Up @@ -67,6 +81,7 @@ 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.
load_opensearch_dashboards_from_cache
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
echo "BUILD MODULES FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && yarn osd bootstrap)
Expand Down
15 changes: 15 additions & 0 deletions scripts/components/notebooksDashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ function usage() {
echo -e "-h help"
}

function load_opensearch_dashboards_from_cache() {
if [ ! -d ../OpenSearch-Dashboards ]; then
echo "No OpenSearch-Dashboards folder found, trying to load from cache"
if [ -d ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ]; then
echo "Copy OpenSearch-Dashboards from cache"
cp -r ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ../../
else
echo "No correct version OpenSearch-Dashboards found from cache,
please run: ./build.sh manifests/1.1.0/opensearch-dashboards-1.1.0.yml --component=OpenSearch-Dashboards"
exit 1
fi
fi
}

while getopts ":h:v:s:o:p:a:" arg; do
case $arg in
h)
Expand Down Expand Up @@ -67,6 +81,7 @@ 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.
load_opensearch_dashboards_from_cache
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
echo "BUILD MODULES FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && yarn osd bootstrap)
Expand Down
15 changes: 15 additions & 0 deletions scripts/components/notificationsDashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ function usage() {
echo -e "-h help"
}

function load_opensearch_dashboards_from_cache() {
if [ ! -d ../OpenSearch-Dashboards ]; then
echo "No OpenSearch-Dashboards folder found, trying to load from cache"
if [ -d ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ]; then
echo "Copy OpenSearch-Dashboards from cache"
cp -r ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ../../
else
echo "No correct version OpenSearch-Dashboards found from cache,
please run: ./build.sh manifests/1.1.0/opensearch-dashboards-1.1.0.yml --component=OpenSearch-Dashboards"
exit 1
fi
fi
}

while getopts ":h:v:s:o:p:a:" arg; do
case $arg in
h)
Expand Down Expand Up @@ -67,6 +81,7 @@ 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.
load_opensearch_dashboards_from_cache
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
echo "BUILD MODULES FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && yarn osd bootstrap)
Expand Down
15 changes: 15 additions & 0 deletions scripts/components/queryWorkbenchDashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ function usage() {
echo -e "-h help"
}

function load_opensearch_dashboards_from_cache() {
if [ ! -d ../OpenSearch-Dashboards ]; then
echo "No OpenSearch-Dashboards folder found, try to load from cache"
if [ -d ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ]; then
echo "Copy OpenSearch-Dashboards from cache"
cp -r ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ../../
else
echo "No correct version OpenSearch-Dashboards found from cache,
please run: ./build.sh manifests/1.1.0/opensearch-dashboards-1.1.0.yml --component=OpenSearch-Dashboards"
exit 1
fi
fi
}

while getopts ":h:v:s:o:p:a:" arg; do
case $arg in
h)
Expand Down Expand Up @@ -67,6 +81,7 @@ 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.
load_opensearch_dashboards_from_cache
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
echo "BUILD MODULES FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && yarn osd bootstrap)
Expand Down
14 changes: 14 additions & 0 deletions scripts/components/reportsDashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ function usage() {
echo -e "-h help"
}

function load_opensearch_dashboards_from_cache() {
if [ ! -d ../OpenSearch-Dashboards ]; then
echo "No OpenSearch-Dashboards folder found, try to load from cache"
if [ -d ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ]; then
echo "Copy OpenSearch-Dashboards from cache"
cp -r ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ../../
else
echo "No correct version OpenSearch-Dashboards found from cache, please build OpenSearch-Dashboards first"
exit 1
fi
fi
}

while getopts ":h:v:s:o:p:a:" arg; do
case $arg in
h)
Expand Down Expand Up @@ -67,6 +80,7 @@ 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.
load_opensearch_dashboards_from_cache
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins
echo "BUILD MODULES FOR $PLUGIN_NAME"
(cd ../../OpenSearch-Dashboards && yarn osd bootstrap)
Expand Down
15 changes: 15 additions & 0 deletions scripts/default/opensearch-dashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ function usage() {
echo -e "-h help"
}

function load_opensearch_dashboards_from_cache() {
if [ ! -d ../OpenSearch-Dashboards ]; then
echo "No OpenSearch-Dashboards folder found, try to load from cache"
if [ -d ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ]; then
echo "Copy OpenSearch-Dashboards from cache"
cp -r ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ../
else
echo "No correct version OpenSearch-Dashboards found from cache,
please run: ./build.sh manifests/1.1.0/opensearch-dashboards-1.1.0.yml --component=OpenSearch-Dashboards"
exit 1
fi
fi
}

while getopts ":h:v:s:o:p:a:" arg; do
case $arg in
h)
Expand Down Expand Up @@ -65,6 +79,7 @@ mkdir -p $OUTPUT/plugins
PLUGIN_NAME=$(basename "$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.
load_opensearch_dashboards_from_cache
cp -r ../$PLUGIN_NAME/ ../OpenSearch-Dashboards/plugins
echo "BUILD MODULES FOR $PLUGIN_NAME"
(cd ../OpenSearch-Dashboards && yarn osd bootstrap)
Expand Down

0 comments on commit 1bf1ed9

Please sign in to comment.