Skip to content

Commit

Permalink
Add windows specific plugin installation for dashboards (opensearch-p…
Browse files Browse the repository at this point in the history
…roject#2730)

* Add windows specific plugin installation for dashboards

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Add tests

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Remove .swp

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
Signed-off-by: Monu Singh <msnghgw@amazon.com>
  • Loading branch information
peterzhuamazon authored and monusingh-1 committed Nov 2, 2022
1 parent 69362ae commit e07cd98
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
17 changes: 15 additions & 2 deletions scripts/components/OpenSearch-Dashboards/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in
EXTRA_PARAMS="--skip-os-packages"
SUFFIX="$PLATFORM-arm64"
;;
windows-zip-x64)
TARGET="--all-platforms"
EXT="$DISTRIBUTION"
BUILD_PARAMS="build-platform"
EXTRA_PARAMS="--skip-os-packages"
SUFFIX="$PLATFORM-x64"
;;
linux-rpm-x64)
TARGET="--$DISTRIBUTION"
EXT="$DISTRIBUTION"
Expand All @@ -110,8 +117,14 @@ case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in
esac

echo "Setting node version"
source $NVM_DIR/nvm.sh
nvm use

if [ "$PLATFORM" != "windows" ]; then
source $NVM_DIR/nvm.sh
nvm use
else
volta install node@`cat .nvmrc`
volta install yarn
fi

echo "Building node modules for core with $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"
yarn osd bootstrap
Expand Down
7 changes: 6 additions & 1 deletion src/assemble_workflow/bundle_opensearch_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@

from assemble_workflow.bundle import Bundle
from manifests.build_manifest import BuildComponent
from system.os import current_platform


class BundleOpenSearchDashboards(Bundle):
@property
def install_plugin_script(self) -> str:
return "opensearch-dashboards-plugin.bat" if current_platform() == "windows" else "opensearch-dashboards-plugin"

def install_plugin(self, plugin: BuildComponent) -> None:
tmp_path = self._copy_component(plugin, "plugins")
cli_path = os.path.join(self.min_dist.archive_path, "bin", "opensearch-dashboards-plugin")
cli_path = os.path.join(self.min_dist.archive_path, "bin", self.install_plugin_script)
self._execute(f"{cli_path} --allow-root install file:{tmp_path}")
super().install_plugin(plugin)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from assemble_workflow.bundle_opensearch_dashboards import BundleOpenSearchDashboards
from manifests.build_manifest import BuildManifest
from paths.script_finder import ScriptFinder
from system.os import current_platform


class TestBundleOpenSearchDashboards(unittest.TestCase):
Expand Down Expand Up @@ -73,7 +74,8 @@ def test_bundle_install_plugin(self, path_isfile: Mock) -> None:
self.assertEqual(mock_copyfile.call_count, 1)
self.assertEqual(mock_check_call.call_count, 2)

install_plugin_bin = os.path.join(bundle.min_dist.archive_path, "bin", "opensearch-dashboards-plugin")
script = "opensearch-dashboards-plugin.bat" if current_platform() == "windows" else "opensearch-dashboards-plugin"
install_plugin_bin = os.path.join(bundle.min_dist.archive_path, "bin", script)
mock_check_call.assert_has_calls(
[
call(
Expand Down

0 comments on commit e07cd98

Please sign in to comment.