From ba3fb93570fcaa1a82a1a18d10d8fc4c518151c1 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 4 Jan 2024 11:03:41 -0500 Subject: [PATCH 01/35] Try building OSD core Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 1987875e0..67675d301 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -37,17 +37,6 @@ runs: cypress test - - uses: actions/checkout@v2 - with: - path: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} - - - id: osd-version - run: | - echo "::set-output name=osd-version::$(jq -r '.opensearchDashboards.version | split(".") | .[:2] | join(".")' package.json)" - echo "::set-output name=osd-x-version::$(jq -r '.opensearchDashboards.version | split(".") | .[0]' package.json).x" - working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} - shell: bash - - id: branch-switch-if-possible continue-on-error: true # Defaults onto main if the branch switch doesn't work if: ${{ steps.osd-version.outputs.osd-version }} @@ -76,6 +65,29 @@ runs: yarn add sha.js working-directory: OpenSearch-Dashboards shell: bash + + - id: build-osd + run: | + scripts/use_node scripts/build + working-directory: OpenSearch-Dashboards + shell: bash + + - id: echo + run: | + echo "ls build/" + working-directory: OpenSearch-Dashboards + shell: bash + + - uses: actions/checkout@v2 + with: + path: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} + + - id: osd-version + run: | + echo "::set-output name=osd-version::$(jq -r '.opensearchDashboards.version | split(".") | .[:2] | join(".")' package.json)" + echo "::set-output name=osd-x-version::$(jq -r '.opensearchDashboards.version | split(".") | .[0]' package.json).x" + working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} + shell: bash - name: Bootstrap the OpenSearch Dashboard uses: nick-fields/retry@v2 From 0d54567208c3d3b8449bc5b2890503c139840db0 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 4 Jan 2024 13:33:30 -0500 Subject: [PATCH 02/35] Fix path Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 67675d301..f79958a34 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -69,13 +69,13 @@ runs: - id: build-osd run: | scripts/use_node scripts/build - working-directory: OpenSearch-Dashboards + working-directory: ./OpenSearch-Dashboards shell: bash - id: echo run: | echo "ls build/" - working-directory: OpenSearch-Dashboards + working-directory: ./OpenSearch-Dashboards shell: bash - uses: actions/checkout@v2 From d27c98b127b8813869b67b8b97c6ce18b26e9941 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 4 Jan 2024 14:12:59 -0500 Subject: [PATCH 03/35] Try changing pwd Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index f79958a34..98532e9c2 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -63,20 +63,10 @@ runs: npm i -g yarn@${{ steps.tool-versions.outputs.yarn_version }} yarn cache clean yarn add sha.js + scripts/use_node scripts/build working-directory: OpenSearch-Dashboards shell: bash - - id: build-osd - run: | - scripts/use_node scripts/build - working-directory: ./OpenSearch-Dashboards - shell: bash - - - id: echo - run: | - echo "ls build/" - working-directory: ./OpenSearch-Dashboards - shell: bash - uses: actions/checkout@v2 with: From e3f4b3196daec53ff584e91babda79ff2f53129b Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 4 Jan 2024 14:32:06 -0500 Subject: [PATCH 04/35] try Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 98532e9c2..9a26946f3 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -63,9 +63,11 @@ runs: npm i -g yarn@${{ steps.tool-versions.outputs.yarn_version }} yarn cache clean yarn add sha.js - scripts/use_node scripts/build working-directory: OpenSearch-Dashboards shell: bash + + - name: Setup upterm session + uses: lhotari/action-upterm@v1 - uses: actions/checkout@v2 From 7992e96bd6dac68fabb88b9a43b4dce2ecf55955 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 4 Jan 2024 14:54:52 -0500 Subject: [PATCH 05/35] Build both Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 9a26946f3..e6afb75fe 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -63,17 +63,25 @@ runs: npm i -g yarn@${{ steps.tool-versions.outputs.yarn_version }} yarn cache clean yarn add sha.js + yarn osd bootstrap + scripts/use_node scripts/build working-directory: OpenSearch-Dashboards shell: bash - - - name: Setup upterm session - uses: lhotari/action-upterm@v1 - - uses: actions/checkout@v2 with: path: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} + - name: Build Plugin Zip + run: | + yarn build + with: + path: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} + + - name: Setup upterm session + uses: lhotari/action-upterm@v1 + + - id: osd-version run: | echo "::set-output name=osd-version::$(jq -r '.opensearchDashboards.version | split(".") | .[:2] | join(".")' package.json)" From 545eb2ddd4724a753672fe1202830c0214def0ca Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 4 Jan 2024 14:56:07 -0500 Subject: [PATCH 06/35] Fix syntax Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index e6afb75fe..39d7dadcb 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -75,8 +75,7 @@ runs: - name: Build Plugin Zip run: | yarn build - with: - path: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} + working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} - name: Setup upterm session uses: lhotari/action-upterm@v1 From 71584b4bdf05fe7193e6cc9a51200f14ed9fbf35 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 4 Jan 2024 14:59:12 -0500 Subject: [PATCH 07/35] provide shell Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 39d7dadcb..a17eea3b3 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -76,6 +76,7 @@ runs: run: | yarn build working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} + shell: bash - name: Setup upterm session uses: lhotari/action-upterm@v1 From 8d14f9783a60ffa3efd7bf96a8f0ec23334b55a2 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 4 Jan 2024 15:33:00 -0500 Subject: [PATCH 08/35] successfully install Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index a17eea3b3..214e7db84 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -78,9 +78,9 @@ runs: working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} shell: bash - - name: Setup upterm session - uses: lhotari/action-upterm@v1 - + - name: Install plugin to OSD + run: | + build/opensearch-dashboards/bin/opensearch-dashboards-plugin install file:$(pwd)/plugins/${{ inputs.plugin_name }}/build/*.zip - id: osd-version run: | From d2f02af218c1fcd1ac8f5a5b880a15f2b36f8cba Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 4 Jan 2024 15:33:34 -0500 Subject: [PATCH 09/35] successfully install Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 214e7db84..719de1204 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -81,6 +81,8 @@ runs: - name: Install plugin to OSD run: | build/opensearch-dashboards/bin/opensearch-dashboards-plugin install file:$(pwd)/plugins/${{ inputs.plugin_name }}/build/*.zip + working-directory: OpenSearch-Dashboards + shell: bash - id: osd-version run: | From fdb0dbff4271006f74ef1998e7216c73433c010b Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 12 Jan 2024 14:35:50 -0500 Subject: [PATCH 10/35] try to get it working for linux Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 719de1204..1c3bf474c 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -78,9 +78,10 @@ runs: working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} shell: bash - - name: Install plugin to OSD + - name: Install plugin to OSD Linux + if: ${{ runner.os == 'Linux' }} run: | - build/opensearch-dashboards/bin/opensearch-dashboards-plugin install file:$(pwd)/plugins/${{ inputs.plugin_name }}/build/*.zip + build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64/bin/opensearch-dashboards-plugin install file:$(pwd)/plugins/${{ inputs.plugin_name }}/build/securityDashboards-${{env.OPENSEARCH_VERSION}}.zip working-directory: OpenSearch-Dashboards shell: bash From 84abba5157779421f004ce199c9c917679d69b4e Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 12 Jan 2024 14:56:27 -0500 Subject: [PATCH 11/35] Fix path to linux build Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 1c3bf474c..8fcde2812 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -81,7 +81,7 @@ runs: - name: Install plugin to OSD Linux if: ${{ runner.os == 'Linux' }} run: | - build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64/bin/opensearch-dashboards-plugin install file:$(pwd)/plugins/${{ inputs.plugin_name }}/build/securityDashboards-${{env.OPENSEARCH_VERSION}}.zip + build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64/bin/opensearch-dashboards-plugin install file:$(pwd)/plugins/${{ inputs.plugin_name }}/build/security-Dashboards-${{env.PLUGIN_VERSION}}.zip working-directory: OpenSearch-Dashboards shell: bash From 2f965c533fa4c778aeeb0cda04373de8f6a980fb Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 12 Jan 2024 15:14:24 -0500 Subject: [PATCH 12/35] Fix capital Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 8fcde2812..902e90738 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -81,7 +81,7 @@ runs: - name: Install plugin to OSD Linux if: ${{ runner.os == 'Linux' }} run: | - build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64/bin/opensearch-dashboards-plugin install file:$(pwd)/plugins/${{ inputs.plugin_name }}/build/security-Dashboards-${{env.PLUGIN_VERSION}}.zip + build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64/bin/opensearch-dashboards-plugin install file:$(pwd)/plugins/${{ inputs.plugin_name }}/build/security-dashboards-${{env.PLUGIN_VERSION}}.zip working-directory: OpenSearch-Dashboards shell: bash From 44f55632ca635055e105d0363ca254483b386a95 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 12 Jan 2024 15:22:38 -0500 Subject: [PATCH 13/35] double check env variable Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 902e90738..05173d736 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -14,6 +14,10 @@ outputs: plugin-directory: description: "The directory where the plugin has been configured" value: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} + + dashboards-binary-directory: + description: "The directory where the dashboards binary has been configured" + value: ${{ steps.determine-dashboards-binary-directory.outputs.dashboards-directory }} runs: @@ -23,6 +27,14 @@ runs: run: echo "dashboards-directory=OpenSearch-Dashboards" >> $GITHUB_OUTPUT shell: bash + - id: determine-sdashboards-binary-directory + run: echo OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-${{os.runner@L}}-x64" + shell: bash + + - id: determine-dashboards-binary-directory + run: echo "dashboards-directory=OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-${{os.runner@L}}-x64" >> $GITHUB_OUTPUT + shell: bash + - id: determine-plugin-directory run: echo "::set-output name=plugin-directory::./OpenSearch-Dashboards/plugins/${{ inputs.plugin_name }}" shell: bash From 3636e2bb98bed7afd0cf590977637ea9e2c102b3 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 12 Jan 2024 15:24:06 -0500 Subject: [PATCH 14/35] Fix name Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 05173d736..b92cba8f2 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -28,7 +28,7 @@ runs: shell: bash - id: determine-sdashboards-binary-directory - run: echo OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-${{os.runner@L}}-x64" + run: echo OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-${{runner.os@L}}-x64" shell: bash - id: determine-dashboards-binary-directory From d6e7999970ff82d83558a688f0dad03b41e9e126 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 12 Jan 2024 15:26:43 -0500 Subject: [PATCH 15/35] try different syntax Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index b92cba8f2..faf3b4302 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -28,7 +28,7 @@ runs: shell: bash - id: determine-sdashboards-binary-directory - run: echo OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-${{runner.os@L}}-x64" + run: echo OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-${ runner.os@L }-x64" shell: bash - id: determine-dashboards-binary-directory From c212378dadd2ad5392bd47eff8edba774723e4b1 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 12 Jan 2024 15:30:03 -0500 Subject: [PATCH 16/35] change to same command for both platform Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index faf3b4302..91de343b7 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -27,12 +27,8 @@ runs: run: echo "dashboards-directory=OpenSearch-Dashboards" >> $GITHUB_OUTPUT shell: bash - - id: determine-sdashboards-binary-directory - run: echo OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-${ runner.os@L }-x64" - shell: bash - - id: determine-dashboards-binary-directory - run: echo "dashboards-directory=OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-${{os.runner@L}}-x64" >> $GITHUB_OUTPUT + run: echo "dashboards-directory=OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-${{ runner.os@L }}-x64" >> $GITHUB_OUTPUT shell: bash - id: determine-plugin-directory From 00da94a3999d86e2682eafd0c83b62454fee4b48 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 12 Jan 2024 15:33:49 -0500 Subject: [PATCH 17/35] Get actual name Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 91de343b7..2804f465b 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -28,7 +28,7 @@ runs: shell: bash - id: determine-dashboards-binary-directory - run: echo "dashboards-directory=OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-${{ runner.os@L }}-x64" >> $GITHUB_OUTPUT + run: echo "dashboards-directory=OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-${{ runner.os | lower }}-x64" >> $GITHUB_OUTPUT shell: bash - id: determine-plugin-directory From 28e08fc460df0e4b25e6266b9978c166c274b845 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 12 Jan 2024 15:38:08 -0500 Subject: [PATCH 18/35] fix unit test workflow for windows Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 2 +- .github/workflows/unit-test.yml | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index 2804f465b..d681221de 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -28,7 +28,7 @@ runs: shell: bash - id: determine-dashboards-binary-directory - run: echo "dashboards-directory=OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-${{ runner.os | lower }}-x64" >> $GITHUB_OUTPUT + run: echo "dashboards-directory=OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64" >> $GITHUB_OUTPUT shell: bash - id: determine-plugin-directory diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index de2572654..53a560b3a 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -19,6 +19,14 @@ jobs: - name: Checkout Branch uses: actions/checkout@v2 + - name: Set env + run: | + opensearch_version=$(node -p "require('./package.json').opensearchDashboards.version") + plugin_version=$(node -p "require('./package.json').version") + echo "OPENSEARCH_VERSION=$opensearch_version" >> $GITHUB_ENV + echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV + shell: bash + - id: install-dashboards uses: ./.github/actions/install-dashboards with: From 6cdb7d00e1b5a55b8439ae007c6560946884dfa8 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 12 Jan 2024 16:10:40 -0500 Subject: [PATCH 19/35] Move to new workflow Signed-off-by: Derek Ho --- .github/actions/install-dashboards/action.yml | 45 ++----- .github/workflows/unit-test.yml | 8 -- .../workflows/verify-binary-installation.yml | 116 ++++++++++++++++++ 3 files changed, 127 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/verify-binary-installation.yml diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index d681221de..1987875e0 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -14,10 +14,6 @@ outputs: plugin-directory: description: "The directory where the plugin has been configured" value: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} - - dashboards-binary-directory: - description: "The directory where the dashboards binary has been configured" - value: ${{ steps.determine-dashboards-binary-directory.outputs.dashboards-directory }} runs: @@ -27,10 +23,6 @@ runs: run: echo "dashboards-directory=OpenSearch-Dashboards" >> $GITHUB_OUTPUT shell: bash - - id: determine-dashboards-binary-directory - run: echo "dashboards-directory=OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64" >> $GITHUB_OUTPUT - shell: bash - - id: determine-plugin-directory run: echo "::set-output name=plugin-directory::./OpenSearch-Dashboards/plugins/${{ inputs.plugin_name }}" shell: bash @@ -45,6 +37,17 @@ runs: cypress test + - uses: actions/checkout@v2 + with: + path: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} + + - id: osd-version + run: | + echo "::set-output name=osd-version::$(jq -r '.opensearchDashboards.version | split(".") | .[:2] | join(".")' package.json)" + echo "::set-output name=osd-x-version::$(jq -r '.opensearchDashboards.version | split(".") | .[0]' package.json).x" + working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} + shell: bash + - id: branch-switch-if-possible continue-on-error: true # Defaults onto main if the branch switch doesn't work if: ${{ steps.osd-version.outputs.osd-version }} @@ -71,34 +74,8 @@ runs: npm i -g yarn@${{ steps.tool-versions.outputs.yarn_version }} yarn cache clean yarn add sha.js - yarn osd bootstrap - scripts/use_node scripts/build working-directory: OpenSearch-Dashboards shell: bash - - - uses: actions/checkout@v2 - with: - path: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} - - - name: Build Plugin Zip - run: | - yarn build - working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} - shell: bash - - - name: Install plugin to OSD Linux - if: ${{ runner.os == 'Linux' }} - run: | - build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64/bin/opensearch-dashboards-plugin install file:$(pwd)/plugins/${{ inputs.plugin_name }}/build/security-dashboards-${{env.PLUGIN_VERSION}}.zip - working-directory: OpenSearch-Dashboards - shell: bash - - - id: osd-version - run: | - echo "::set-output name=osd-version::$(jq -r '.opensearchDashboards.version | split(".") | .[:2] | join(".")' package.json)" - echo "::set-output name=osd-x-version::$(jq -r '.opensearchDashboards.version | split(".") | .[0]' package.json).x" - working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} - shell: bash - name: Bootstrap the OpenSearch Dashboard uses: nick-fields/retry@v2 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 53a560b3a..de2572654 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -19,14 +19,6 @@ jobs: - name: Checkout Branch uses: actions/checkout@v2 - - name: Set env - run: | - opensearch_version=$(node -p "require('./package.json').opensearchDashboards.version") - plugin_version=$(node -p "require('./package.json').version") - echo "OPENSEARCH_VERSION=$opensearch_version" >> $GITHUB_ENV - echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV - shell: bash - - id: install-dashboards uses: ./.github/actions/install-dashboards with: diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml new file mode 100644 index 000000000..4d7618dd2 --- /dev/null +++ b/.github/workflows/verify-binary-installation.yml @@ -0,0 +1,116 @@ +name: 'Install Dashboards with Plugin' + +on: [ push, pull_request ] + +jobs: + verify-binary-installation: + name: Run binary installation + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout Branch + uses: actions/checkout@v3 + + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Set env + run: | + opensearch_version=$(node -p "require('./package.json').opensearchDashboards.version") + plugin_version=$(node -p "require('./package.json').version") + echo "OPENSEARCH_VERSION=$opensearch_version" >> $GITHUB_ENV + echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV + shell: bash + + - name: Download security plugin and create setup scripts + uses: ./.github/actions/download-plugin + with: + opensearch-version: ${{ env.OPENSEARCH_VERSION }} + plugin-name: ${{ env.PLUGIN_NAME }} + plugin-version: ${{ env.PLUGIN_VERSION }} + + - name: Run Opensearch with A Single Plugin + uses: opensearch-project/security/.github/actions/start-opensearch-with-one-plugin@main + with: + opensearch-version: ${{ env.OPENSEARCH_VERSION }} + plugin-name: ${{ env.PLUGIN_NAME }} + setup-script-name: setup + admin-password: myStrongPassword123! + + - uses: actions/checkout@v2 + with: + path: OpenSearch-Dashboards + repository: opensearch-project/OpenSearch-Dashboards + ref: 'main' + fetch-depth: 0 + filter: | + cypress + test + + - id: branch-switch-if-possible + continue-on-error: true # Defaults onto main if the branch switch doesn't work + if: ${{ steps.osd-version.outputs.osd-version }} + run: git checkout ${{ steps.osd-version.outputs.osd-version }} || git checkout ${{ steps.osd-version.outputs.osd-x-version }} + working-directory: ./OpenSearch-Dashboards + shell: bash + + - id: tool-versions + run: | + echo "node_version=$(cat .node-version)" >> $GITHUB_OUTPUT + echo "yarn_version=$(jq -r '.engines.yarn' package.json)" >> $GITHUB_OUTPUT + working-directory: OpenSearch-Dashboards + shell: bash + + - uses: actions/setup-node@v1 + with: + node-version: ${{ steps.tool-versions.outputs.node_version }} + registry-url: 'https://registry.npmjs.org' + + - name: Setup Opensearch Dashboards + run: | + npm uninstall -g yarn + echo "Installing yarn ${{ steps.tool-versions.outputs.yarn_version }}" + npm i -g yarn@${{ steps.tool-versions.outputs.yarn_version }} + yarn cache clean + yarn add sha.js + yarn osd bootstrap + scripts/use_node scripts/build + working-directory: OpenSearch-Dashboards + shell: bash + + - uses: actions/checkout@v2 + with: + path: OpenSearch-Dashboards/security-dashboards-plugin + + - name: Build Plugin Zip + run: | + yarn build + working-directory: OpenSearch-Dashboards/security-dashboards-plugin + shell: bash + + - name: Install plugin to OSD Linux + if: ${{ runner.os == 'Linux' }} + run: | + build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64/bin/opensearch-dashboards-plugin install file:$(pwd)/OpenSearch-Dashboards/plugins/security-dashboards-plugin/build/security-dashboards-${{env.PLUGIN_VERSION}}.zip + working-directory: OpenSearch-Dashboards + shell: bash + + - id: osd-version + run: | + echo "::set-output name=osd-version::$(jq -r '.opensearchDashboards.version | split(".") | .[:2] | join(".")' package.json)" + echo "::set-output name=osd-x-version::$(jq -r '.opensearchDashboards.version | split(".") | .[0]' package.json).x" + working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} + shell: bash + + - name: Bootstrap the OpenSearch Dashboard + uses: nick-fields/retry@v2 + with: + timeout_minutes: 20 + max_attempts: 2 + command: yarn --cwd OpenSearch-Dashboards osd bootstrap --oss From c3e6eadfa9f95113d3ca06b03d7d93ddee62ee66 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 12 Jan 2024 16:13:42 -0500 Subject: [PATCH 20/35] fix Signed-off-by: Derek Ho --- .github/workflows/verify-binary-installation.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index 4d7618dd2..dfe3745f0 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -1,4 +1,4 @@ -name: 'Install Dashboards with Plugin' +name: 'Install Dashboards with Plugin via Binary' on: [ push, pull_request ] @@ -114,3 +114,10 @@ jobs: timeout_minutes: 20 max_attempts: 2 command: yarn --cwd OpenSearch-Dashboards osd bootstrap --oss + + - name: Start OpenSearch Dashboards + uses: nick-fields/retry@v2 + with: + timeout_minutes: 20 + max_attempts: 2 + command: ./OpenSearch-Dash From 7936e490c8d02372d8adeb104c1dbc159467d682 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Sun, 14 Jan 2024 10:49:20 -0500 Subject: [PATCH 21/35] indentation Signed-off-by: Derek Ho --- .../workflows/verify-binary-installation.yml | 171 +++++++++--------- 1 file changed, 89 insertions(+), 82 deletions(-) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index dfe3745f0..d2ec686e9 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -1,6 +1,6 @@ name: 'Install Dashboards with Plugin via Binary' -on: [ push, pull_request ] +on: [push, pull_request] jobs: verify-binary-installation: @@ -10,11 +10,10 @@ jobs: matrix: os: [ubuntu-latest] runs-on: ${{ matrix.os }} - - steps: + steps: - name: Checkout Branch uses: actions/checkout@v3 - + - name: Set up JDK uses: actions/setup-java@v1 with: @@ -43,81 +42,89 @@ jobs: setup-script-name: setup admin-password: myStrongPassword123! - - uses: actions/checkout@v2 - with: - path: OpenSearch-Dashboards - repository: opensearch-project/OpenSearch-Dashboards - ref: 'main' - fetch-depth: 0 - filter: | - cypress - test - - - id: branch-switch-if-possible - continue-on-error: true # Defaults onto main if the branch switch doesn't work - if: ${{ steps.osd-version.outputs.osd-version }} - run: git checkout ${{ steps.osd-version.outputs.osd-version }} || git checkout ${{ steps.osd-version.outputs.osd-x-version }} - working-directory: ./OpenSearch-Dashboards - shell: bash - - - id: tool-versions - run: | - echo "node_version=$(cat .node-version)" >> $GITHUB_OUTPUT - echo "yarn_version=$(jq -r '.engines.yarn' package.json)" >> $GITHUB_OUTPUT - working-directory: OpenSearch-Dashboards - shell: bash - - - uses: actions/setup-node@v1 - with: - node-version: ${{ steps.tool-versions.outputs.node_version }} - registry-url: 'https://registry.npmjs.org' - - - name: Setup Opensearch Dashboards - run: | - npm uninstall -g yarn - echo "Installing yarn ${{ steps.tool-versions.outputs.yarn_version }}" - npm i -g yarn@${{ steps.tool-versions.outputs.yarn_version }} - yarn cache clean - yarn add sha.js - yarn osd bootstrap - scripts/use_node scripts/build - working-directory: OpenSearch-Dashboards - shell: bash - - - uses: actions/checkout@v2 - with: - path: OpenSearch-Dashboards/security-dashboards-plugin - - - name: Build Plugin Zip - run: | - yarn build - working-directory: OpenSearch-Dashboards/security-dashboards-plugin - shell: bash - - - name: Install plugin to OSD Linux - if: ${{ runner.os == 'Linux' }} - run: | - build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64/bin/opensearch-dashboards-plugin install file:$(pwd)/OpenSearch-Dashboards/plugins/security-dashboards-plugin/build/security-dashboards-${{env.PLUGIN_VERSION}}.zip - working-directory: OpenSearch-Dashboards - shell: bash - - - id: osd-version - run: | - echo "::set-output name=osd-version::$(jq -r '.opensearchDashboards.version | split(".") | .[:2] | join(".")' package.json)" - echo "::set-output name=osd-x-version::$(jq -r '.opensearchDashboards.version | split(".") | .[0]' package.json).x" - working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} - shell: bash - - - name: Bootstrap the OpenSearch Dashboard - uses: nick-fields/retry@v2 - with: - timeout_minutes: 20 - max_attempts: 2 - command: yarn --cwd OpenSearch-Dashboards osd bootstrap --oss - - - name: Start OpenSearch Dashboards - uses: nick-fields/retry@v2 - with: - timeout_minutes: 20 - max_attempts: 2 - command: ./OpenSearch-Dash + - name: Run Opensearch with A Single Plugin + uses: opensearch-project/security/.github/actions/start-opensearch-with-one-plugin@main + with: + opensearch-version: ${{ env.OPENSEARCH_VERSION }} + plugin-name: ${{ env.PLUGIN_NAME }} + setup-script-name: setup + admin-password: myStrongPassword123! + + - uses: actions/checkout@v2 + with: + path: OpenSearch-Dashboards + repository: opensearch-project/OpenSearch-Dashboards + ref: 'main' + fetch-depth: 0 + filter: | + cypress + test + + - id: branch-switch-if-possible + continue-on-error: true # Defaults onto main if the branch switch doesn't work + if: ${{ steps.osd-version.outputs.osd-version }} + run: git checkout ${{ steps.osd-version.outputs.osd-version }} || git checkout ${{ steps.osd-version.outputs.osd-x-version }} + working-directory: ./OpenSearch-Dashboards + shell: bash + + - id: tool-versions + run: | + echo "node_version=$(cat .node-version)" >> $GITHUB_OUTPUT + echo "yarn_version=$(jq -r '.engines.yarn' package.json)" >> $GITHUB_OUTPUT + working-directory: OpenSearch-Dashboards + shell: bash + + - uses: actions/setup-node@v1 + with: + node-version: ${{ steps.tool-versions.outputs.node_version }} + registry-url: 'https://registry.npmjs.org' + + - name: Setup Opensearch Dashboards + run: | + npm uninstall -g yarn + echo "Installing yarn ${{ steps.tool-versions.outputs.yarn_version }}" + npm i -g yarn@${{ steps.tool-versions.outputs.yarn_version }} + yarn cache clean + yarn add sha.js + yarn osd bootstrap + scripts/use_node scripts/build + working-directory: OpenSearch-Dashboards + shell: bash + + - uses: actions/checkout@v2 + with: + path: OpenSearch-Dashboards/security-dashboards-plugin + + - name: Build Plugin Zip + run: | + yarn build + working-directory: OpenSearch-Dashboards/security-dashboards-plugin + shell: bash + + - name: Install plugin to OSD Linux + if: ${{ runner.os == 'Linux' }} + run: | + build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64/bin/opensearch-dashboards-plugin install file:$(pwd)/OpenSearch-Dashboards/plugins/security-dashboards-plugin/build/security-dashboards-${{env.PLUGIN_VERSION}}.zip + working-directory: OpenSearch-Dashboards + shell: bash + + - id: osd-version + run: | + echo "::set-output name=osd-version::$(jq -r '.opensearchDashboards.version | split(".") | .[:2] | join(".")' package.json)" + echo "::set-output name=osd-x-version::$(jq -r '.opensearchDashboards.version | split(".") | .[0]' package.json).x" + working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} + shell: bash + + - name: Bootstrap the OpenSearch Dashboard + uses: nick-fields/retry@v2 + with: + timeout_minutes: 20 + max_attempts: 2 + command: yarn --cwd OpenSearch-Dashboards osd bootstrap --oss + + - name: Start OpenSearch Dashboards + uses: nick-fields/retry@v2 + with: + timeout_minutes: 20 + max_attempts: 2 + command: ./OpenSearch-Dash From 9949f5b3dbb05fda369a0cec367e8d5a23abf469 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Sun, 14 Jan 2024 10:52:32 -0500 Subject: [PATCH 22/35] Add env Signed-off-by: Derek Ho --- .github/workflows/verify-binary-installation.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index d2ec686e9..06120177e 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -1,6 +1,13 @@ name: 'Install Dashboards with Plugin via Binary' on: [push, pull_request] +env: + OPENSEARCH_VERSION: '3.0.0' + CI: 1 + # avoid warnings like "tput: No value for $TERM and no -T specified" + TERM: xterm + PLUGIN_NAME: opensearch-security + OPENSEARCH_INITIAL_ADMIN_PASSWORD: myStrongPassword123! jobs: verify-binary-installation: From 6e1082f2856b602f57465c2668081009a3c1b9cc Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Sun, 14 Jan 2024 10:57:04 -0500 Subject: [PATCH 23/35] remove dupe Signed-off-by: Derek Ho --- .github/workflows/verify-binary-installation.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index 06120177e..86510141b 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -49,14 +49,6 @@ jobs: setup-script-name: setup admin-password: myStrongPassword123! - - name: Run Opensearch with A Single Plugin - uses: opensearch-project/security/.github/actions/start-opensearch-with-one-plugin@main - with: - opensearch-version: ${{ env.OPENSEARCH_VERSION }} - plugin-name: ${{ env.PLUGIN_NAME }} - setup-script-name: setup - admin-password: myStrongPassword123! - - uses: actions/checkout@v2 with: path: OpenSearch-Dashboards From 22ee8a89413804a830ed9f4e293067956f9c3596 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Mon, 15 Jan 2024 16:43:01 -0500 Subject: [PATCH 24/35] fix path Signed-off-by: Derek Ho --- .github/workflows/verify-binary-installation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index 86510141b..0f50cb9d7 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -92,12 +92,12 @@ jobs: - uses: actions/checkout@v2 with: - path: OpenSearch-Dashboards/security-dashboards-plugin + path: OpenSearch-Dashboards/plugins/security-dashboards-plugin - name: Build Plugin Zip run: | yarn build - working-directory: OpenSearch-Dashboards/security-dashboards-plugin + working-directory: OpenSearch-Dashboards/plugins/security-dashboards-plugin shell: bash - name: Install plugin to OSD Linux From 7f4b5122c1cb0e3e63628bfe9e9ecdbb354c3062 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Mon, 15 Jan 2024 17:10:27 -0500 Subject: [PATCH 25/35] fix path Signed-off-by: Derek Ho --- .github/workflows/verify-binary-installation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index 0f50cb9d7..371340a5e 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -103,7 +103,7 @@ jobs: - name: Install plugin to OSD Linux if: ${{ runner.os == 'Linux' }} run: | - build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64/bin/opensearch-dashboards-plugin install file:$(pwd)/OpenSearch-Dashboards/plugins/security-dashboards-plugin/build/security-dashboards-${{env.PLUGIN_VERSION}}.zip + build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64/bin/opensearch-dashboards-plugin install file:$(pwd)/plugins/security-dashboards-plugin/build/security-dashboards-${{env.PLUGIN_VERSION}}.zip working-directory: OpenSearch-Dashboards shell: bash From bee18f94ebb5f2ad3ef5f688cd91d975d5ba0e58 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 16 Jan 2024 09:42:56 -0500 Subject: [PATCH 26/35] Finalize workflow Signed-off-by: Derek Ho --- .../workflows/verify-binary-installation.yml | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index 371340a5e..42ababdbe 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -101,29 +101,20 @@ jobs: shell: bash - name: Install plugin to OSD Linux - if: ${{ runner.os == 'Linux' }} run: | build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64/bin/opensearch-dashboards-plugin install file:$(pwd)/plugins/security-dashboards-plugin/build/security-dashboards-${{env.PLUGIN_VERSION}}.zip working-directory: OpenSearch-Dashboards shell: bash - - id: osd-version + - name: Start the binary + run: | + nohup ./bin/opensearch-dashboards & + working-directory: OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64 + shell: bash + + + - name: Health check run: | - echo "::set-output name=osd-version::$(jq -r '.opensearchDashboards.version | split(".") | .[:2] | join(".")' package.json)" - echo "::set-output name=osd-x-version::$(jq -r '.opensearchDashboards.version | split(".") | .[0]' package.json).x" - working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} + timeout 300 bash -c 'while [[ "$(curl http://localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done' shell: bash - - name: Bootstrap the OpenSearch Dashboard - uses: nick-fields/retry@v2 - with: - timeout_minutes: 20 - max_attempts: 2 - command: yarn --cwd OpenSearch-Dashboards osd bootstrap --oss - - - name: Start OpenSearch Dashboards - uses: nick-fields/retry@v2 - with: - timeout_minutes: 20 - max_attempts: 2 - command: ./OpenSearch-Dash From 2f16e4e713129ad02abcc1768ffc909b9ee57c0a Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 16 Jan 2024 10:04:19 -0500 Subject: [PATCH 27/35] add admin creds Signed-off-by: Derek Ho --- .github/workflows/verify-binary-installation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index 42ababdbe..3b0b21841 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -115,6 +115,6 @@ jobs: - name: Health check run: | - timeout 300 bash -c 'while [[ "$(curl http://localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done' + timeout 300 bash -c 'while [[ "$(curl -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k http://localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done' shell: bash From 2de58e36d988a7aa601eb69f94b323acedaa1884 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 16 Jan 2024 10:06:35 -0500 Subject: [PATCH 28/35] Revert "fix Cannot find module when import ResourceType in server from public folder (#1705)" This reverts commit 09b2f59453b4b3d356ba7627d1e1af663fb075bd. Signed-off-by: Derek Ho --- common/index.ts | 12 ------------ public/apps/configuration/app-router.tsx | 3 +-- .../audit-logging/audit-logging-edit-settings.tsx | 2 +- .../panels/audit-logging/audit-logging.tsx | 2 +- .../test/audit-logging-edit-settings.test.tsx | 2 +- .../panels/audit-logging/test/audit-logging.test.tsx | 2 +- public/apps/configuration/panels/get-started.tsx | 11 ++++++++--- .../panels/internal-user-edit/internal-user-edit.tsx | 3 +-- .../panels/role-edit/cluster-permission-panel.tsx | 3 +-- .../panels/role-edit/index-permission-panel.tsx | 7 +++---- .../configuration/panels/role-edit/role-edit.tsx | 3 +-- public/apps/configuration/panels/role-list.tsx | 3 +-- .../panels/role-mapping/role-edit-mapped-user.tsx | 3 +-- .../panels/role-mapping/users-panel.tsx | 3 +-- .../panels/role-view/cluster-permission-panel.tsx | 3 +-- .../panels/role-view/index-permission-panel.tsx | 2 +- .../configuration/panels/role-view/role-view.tsx | 2 +- .../configuration/panels/role-view/tenants-panel.tsx | 8 ++++++-- .../role-view/test/cluster-permission-panel.test.tsx | 3 +-- .../role-view/test/index-permission-panel.test.tsx | 3 +-- .../panels/role-view/test/role-view.test.tsx | 3 +-- .../panels/role-view/test/tenants-panel.test.tsx | 3 +-- .../configuration/panels/service-account-list.tsx | 3 +-- .../configuration/panels/tenant-list/manage_tab.tsx | 7 ++++--- .../configuration/panels/test/get-started.test.tsx | 3 +-- .../configuration/panels/test/role-list.test.tsx | 3 +-- .../panels/test/service-account-list.test.tsx | 3 +-- .../configuration/panels/test/user-list.test.tsx | 3 +-- public/apps/configuration/panels/user-list.tsx | 3 +-- public/apps/configuration/types.ts | 12 ++++++++++++ .../configuration/utils/internal-user-list-utils.tsx | 3 +-- public/apps/configuration/utils/url-builder.tsx | 3 +-- server/routes/index.ts | 2 +- 33 files changed, 60 insertions(+), 71 deletions(-) diff --git a/common/index.ts b/common/index.ts index b5e6a475d..9b038a581 100644 --- a/common/index.ts +++ b/common/index.ts @@ -64,18 +64,6 @@ export enum AuthType { ANONYMOUS = 'anonymous', } -export enum ResourceType { - roles = 'roles', - users = 'users', - serviceAccounts = 'serviceAccounts', - permissions = 'permissions', - tenants = 'tenants', - tenantsManageTab = 'tenantsManageTab', - tenantsConfigureTab = 'tenantsConfigureTab', - auth = 'auth', - auditLogging = 'auditLogging', -} - /** * A valid resource name should not containing percent sign (%) as they raise url injection issue. * And also should not be empty. diff --git a/public/apps/configuration/app-router.tsx b/public/apps/configuration/app-router.tsx index 2e4ce7ca3..a10cec08e 100644 --- a/public/apps/configuration/app-router.tsx +++ b/public/apps/configuration/app-router.tsx @@ -36,8 +36,7 @@ import { RoleView } from './panels/role-view/role-view'; import { TenantList } from './panels/tenant-list/tenant-list'; import { UserList } from './panels/user-list'; import { ServiceAccountList } from './panels/service-account-list'; -import { Action, RouteItem, SubAction } from './types'; -import { ResourceType } from '../../../common'; +import { Action, ResourceType, RouteItem, SubAction } from './types'; import { buildHashUrl, buildUrl } from './utils/url-builder'; import { CrossPageToast } from './cross-page-toast'; diff --git a/public/apps/configuration/panels/audit-logging/audit-logging-edit-settings.tsx b/public/apps/configuration/panels/audit-logging/audit-logging-edit-settings.tsx index de5d0086f..972442978 100644 --- a/public/apps/configuration/panels/audit-logging/audit-logging-edit-settings.tsx +++ b/public/apps/configuration/panels/audit-logging/audit-logging-edit-settings.tsx @@ -31,7 +31,7 @@ import { SETTING_GROUPS, SettingMapItem } from './constants'; import { EditSettingGroup } from './edit-setting-group'; import { AuditLoggingSettings } from './types'; import { buildHashUrl, buildUrl } from '../../utils/url-builder'; -import { ResourceType } from '../../../../../common'; +import { ResourceType } from '../../types'; import { getAuditLogging, updateAuditLogging } from '../../utils/audit-logging-utils'; import { useToastState } from '../../utils/toast-utils'; import { setCrossPageToast } from '../../utils/storage-utils'; diff --git a/public/apps/configuration/panels/audit-logging/audit-logging.tsx b/public/apps/configuration/panels/audit-logging/audit-logging.tsx index 5ca10c84c..e920c32e0 100644 --- a/public/apps/configuration/panels/audit-logging/audit-logging.tsx +++ b/public/apps/configuration/panels/audit-logging/audit-logging.tsx @@ -31,7 +31,7 @@ import { import React from 'react'; import { FormattedMessage } from '@osd/i18n/react'; import { AppDependencies } from '../../../types'; -import { ResourceType } from '../../../../../common'; +import { ResourceType } from '../../types'; import { getAuditLogging, updateAuditLogging } from '../../utils/audit-logging-utils'; import { displayBoolean, ExternalLink } from '../../utils/display-utils'; import { buildHashUrl } from '../../utils/url-builder'; diff --git a/public/apps/configuration/panels/audit-logging/test/audit-logging-edit-settings.test.tsx b/public/apps/configuration/panels/audit-logging/test/audit-logging-edit-settings.test.tsx index a7b52d428..038b0c5c8 100644 --- a/public/apps/configuration/panels/audit-logging/test/audit-logging-edit-settings.test.tsx +++ b/public/apps/configuration/panels/audit-logging/test/audit-logging-edit-settings.test.tsx @@ -18,7 +18,7 @@ import { AuditLoggingEditSettings } from '../audit-logging-edit-settings'; import React from 'react'; import { ComplianceSettings, GeneralSettings } from '../types'; import { buildHashUrl } from '../../../utils/url-builder'; -import { ResourceType } from '../../../../../../common'; +import { ResourceType } from '../../../types'; jest.mock('../../../utils/audit-logging-utils'); diff --git a/public/apps/configuration/panels/audit-logging/test/audit-logging.test.tsx b/public/apps/configuration/panels/audit-logging/test/audit-logging.test.tsx index 2bc5d4881..35e6d0273 100644 --- a/public/apps/configuration/panels/audit-logging/test/audit-logging.test.tsx +++ b/public/apps/configuration/panels/audit-logging/test/audit-logging.test.tsx @@ -18,7 +18,7 @@ import { AuditLogging, renderComplianceSettings, renderGeneralSettings } from '. import React from 'react'; import { EuiSwitch } from '@elastic/eui'; import { buildHashUrl } from '../../../utils/url-builder'; -import { ResourceType } from '../../../../../../common'; +import { ResourceType } from '../../../types'; import { SUB_URL_FOR_COMPLIANCE_SETTINGS_EDIT, SUB_URL_FOR_GENERAL_SETTINGS_EDIT, diff --git a/public/apps/configuration/panels/get-started.tsx b/public/apps/configuration/panels/get-started.tsx index dcf4fed41..b2c562e35 100644 --- a/public/apps/configuration/panels/get-started.tsx +++ b/public/apps/configuration/panels/get-started.tsx @@ -27,12 +27,17 @@ import { } from '@elastic/eui'; import React from 'react'; import { FormattedMessage } from '@osd/i18n/react'; +import { flow } from 'lodash'; +import { HashRouter as Router, Route } from 'react-router-dom'; import { AppDependencies } from '../../types'; -import { buildHashUrl } from '../utils/url-builder'; -import { Action } from '../types'; -import { ResourceType } from '../../../../common'; +import { buildHashUrl, buildUrl } from '../utils/url-builder'; +import { Action, ResourceType, RouteItem } from '../types'; import { API_ENDPOINT_CACHE, DocLinks } from '../constants'; import { ExternalLink, ExternalLinkButton } from '../utils/display-utils'; +import { TenantList } from './tenant-list/tenant-list'; +import { getBreadcrumbs } from '../app-router'; + +import { CrossPageToast } from '../cross-page-toast'; const addBackendStep = { title: 'Add backends', diff --git a/public/apps/configuration/panels/internal-user-edit/internal-user-edit.tsx b/public/apps/configuration/panels/internal-user-edit/internal-user-edit.tsx index 1237ef9f3..f93ef0407 100644 --- a/public/apps/configuration/panels/internal-user-edit/internal-user-edit.tsx +++ b/public/apps/configuration/panels/internal-user-edit/internal-user-edit.tsx @@ -26,8 +26,7 @@ import { } from '@elastic/eui'; import React, { useState } from 'react'; import { BreadcrumbsPageDependencies } from '../../../types'; -import { InternalUserUpdate } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { InternalUserUpdate, ResourceType } from '../../types'; import { getUserDetail, updateUser } from '../../utils/internal-user-detail-utils'; import { PanelWithHeader } from '../../utils/panel-with-header'; import { PasswordEditPanel } from '../../utils/password-edit-panel'; diff --git a/public/apps/configuration/panels/role-edit/cluster-permission-panel.tsx b/public/apps/configuration/panels/role-edit/cluster-permission-panel.tsx index 3ac52f6d3..e80d0d0e1 100644 --- a/public/apps/configuration/panels/role-edit/cluster-permission-panel.tsx +++ b/public/apps/configuration/panels/role-edit/cluster-permission-panel.tsx @@ -15,8 +15,7 @@ import React, { Dispatch, SetStateAction } from 'react'; import { EuiForm, EuiFlexGroup, EuiFlexItem, EuiComboBox } from '@elastic/eui'; -import { ComboBoxOptions } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { ComboBoxOptions, ResourceType } from '../../types'; import { PanelWithHeader } from '../../utils/panel-with-header'; import { FormRow } from '../../utils/form-row'; import { LIMIT_WIDTH_INPUT_CLASS } from '../../constants'; diff --git a/public/apps/configuration/panels/role-edit/index-permission-panel.tsx b/public/apps/configuration/panels/role-edit/index-permission-panel.tsx index e52cb9128..75e2856e4 100644 --- a/public/apps/configuration/panels/role-edit/index-permission-panel.tsx +++ b/public/apps/configuration/panels/role-edit/index-permission-panel.tsx @@ -25,8 +25,7 @@ import { } from '@elastic/eui'; import React, { Dispatch, Fragment, SetStateAction } from 'react'; import { isEmpty } from 'lodash'; -import { RoleIndexPermission } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { RoleIndexPermission, ResourceType } from '../../types'; import { appendElementToArray, removeElementFromArray, @@ -142,9 +141,9 @@ export function IndexPermissionRow(props: { return ( diff --git a/public/apps/configuration/panels/role-edit/role-edit.tsx b/public/apps/configuration/panels/role-edit/role-edit.tsx index a3364fe0b..936d5774b 100644 --- a/public/apps/configuration/panels/role-edit/role-edit.tsx +++ b/public/apps/configuration/panels/role-edit/role-edit.tsx @@ -46,8 +46,7 @@ import { } from './tenant-panel'; import { RoleIndexPermissionStateClass, RoleTenantPermissionStateClass } from './types'; import { buildHashUrl, buildUrl } from '../../utils/url-builder'; -import { ComboBoxOptions, Action, ActionGroupItem } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { ComboBoxOptions, ResourceType, Action, ActionGroupItem } from '../../types'; import { useToastState, createUnknownErrorToast, diff --git a/public/apps/configuration/panels/role-list.tsx b/public/apps/configuration/panels/role-list.tsx index c9ecab34b..1fb27a228 100644 --- a/public/apps/configuration/panels/role-list.tsx +++ b/public/apps/configuration/panels/role-list.tsx @@ -41,8 +41,7 @@ import { fetchRoleMapping, buildSearchFilterOptions, } from '../utils/role-list-utils'; -import { Action } from '../types'; -import { ResourceType } from '../../../../common'; +import { ResourceType, Action } from '../types'; import { buildHashUrl } from '../utils/url-builder'; import { ExternalLink, diff --git a/public/apps/configuration/panels/role-mapping/role-edit-mapped-user.tsx b/public/apps/configuration/panels/role-mapping/role-edit-mapped-user.tsx index 44909bef5..9b2a859da 100644 --- a/public/apps/configuration/panels/role-mapping/role-edit-mapped-user.tsx +++ b/public/apps/configuration/panels/role-mapping/role-edit-mapped-user.tsx @@ -35,8 +35,7 @@ import { ExternalIdentityStateClass } from './types'; import { ComboBoxOptions } from '../../types'; import { stringToComboBoxOption, comboBoxOptionToString } from '../../utils/combo-box-utils'; import { buildHashUrl, buildUrl } from '../../utils/url-builder'; -import { RoleMappingDetail, SubAction, Action } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { ResourceType, RoleMappingDetail, SubAction, Action } from '../../types'; import { fetchUserNameList } from '../../utils/internal-user-list-utils'; import { updateRoleMapping, getRoleMappingData } from '../../utils/role-mapping-utils'; import { createErrorToast, createUnknownErrorToast, useToastState } from '../../utils/toast-utils'; diff --git a/public/apps/configuration/panels/role-mapping/users-panel.tsx b/public/apps/configuration/panels/role-mapping/users-panel.tsx index 6c65a152b..39cec7538 100644 --- a/public/apps/configuration/panels/role-mapping/users-panel.tsx +++ b/public/apps/configuration/panels/role-mapping/users-panel.tsx @@ -19,8 +19,7 @@ import { ComboBoxOptions } from '../../types'; import { PanelWithHeader } from '../../utils/panel-with-header'; import { FormRow } from '../../utils/form-row'; import { buildHashUrl } from '../../utils/url-builder'; -import { Action } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { ResourceType, Action } from '../../types'; import { ExternalLinkButton } from '../../utils/display-utils'; import { DocLinks } from '../../constants'; import { appendOptionToComboBoxHandler } from '../../utils/combo-box-utils'; diff --git a/public/apps/configuration/panels/role-view/cluster-permission-panel.tsx b/public/apps/configuration/panels/role-view/cluster-permission-panel.tsx index 659f98c13..3d4a02df5 100644 --- a/public/apps/configuration/panels/role-view/cluster-permission-panel.tsx +++ b/public/apps/configuration/panels/role-view/cluster-permission-panel.tsx @@ -17,8 +17,7 @@ import React from 'react'; import { EuiEmptyPrompt, EuiButton } from '@elastic/eui'; import { PanelWithHeader } from '../../utils/panel-with-header'; import { PermissionTree } from '../permission-tree'; -import { ActionGroupItem, DataObject, Action } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { ActionGroupItem, DataObject, ResourceType, Action } from '../../types'; import { buildHashUrl } from '../../utils/url-builder'; import { loadingSpinner } from '../../utils/loading-spinner-utils'; import { DocLinks } from '../../constants'; diff --git a/public/apps/configuration/panels/role-view/index-permission-panel.tsx b/public/apps/configuration/panels/role-view/index-permission-panel.tsx index 8c622afd3..b04583522 100644 --- a/public/apps/configuration/panels/role-view/index-permission-panel.tsx +++ b/public/apps/configuration/panels/role-view/index-permission-panel.tsx @@ -30,9 +30,9 @@ import { ActionGroupItem, ExpandedRowMapInterface, RoleIndexPermissionView, + ResourceType, Action, } from '../../types'; -import { ResourceType } from '../../../../../common'; import { truncatedListView, displayArray, tableItemsUIProps } from '../../utils/display-utils'; import { PermissionTree } from '../permission-tree'; import { getFieldLevelSecurityMethod } from '../../utils/index-permission-utils'; diff --git a/public/apps/configuration/panels/role-view/role-view.tsx b/public/apps/configuration/panels/role-view/role-view.tsx index 723d546da..04e5d1f99 100644 --- a/public/apps/configuration/panels/role-view/role-view.tsx +++ b/public/apps/configuration/panels/role-view/role-view.tsx @@ -39,6 +39,7 @@ import { difference } from 'lodash'; import { BreadcrumbsPageDependencies } from '../../../types'; import { buildHashUrl, buildUrl } from '../../utils/url-builder'; import { + ResourceType, Action, SubAction, RoleMappingDetail, @@ -47,7 +48,6 @@ import { RoleIndexPermissionView, RoleTenantPermissionView, } from '../../types'; -import { ResourceType } from '../../../../../common'; import { getRoleMappingData, MappedUsersListing, diff --git a/public/apps/configuration/panels/role-view/tenants-panel.tsx b/public/apps/configuration/panels/role-view/tenants-panel.tsx index 45d19bb2b..667b34f45 100644 --- a/public/apps/configuration/panels/role-view/tenants-panel.tsx +++ b/public/apps/configuration/panels/role-view/tenants-panel.tsx @@ -26,8 +26,12 @@ import { import { CoreStart } from 'opensearch-dashboards/public'; import { getCurrentUser } from '../../../../utils/auth-info-utils'; import { PanelWithHeader } from '../../utils/panel-with-header'; -import { RoleTenantPermissionView, RoleTenantPermissionDetail, Action } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { + RoleTenantPermissionView, + RoleTenantPermissionDetail, + ResourceType, + Action, +} from '../../types'; import { truncatedListView, tableItemsUIProps } from '../../utils/display-utils'; import { fetchTenants, diff --git a/public/apps/configuration/panels/role-view/test/cluster-permission-panel.test.tsx b/public/apps/configuration/panels/role-view/test/cluster-permission-panel.test.tsx index 8e7d5be0c..5891ac502 100644 --- a/public/apps/configuration/panels/role-view/test/cluster-permission-panel.test.tsx +++ b/public/apps/configuration/panels/role-view/test/cluster-permission-panel.test.tsx @@ -18,8 +18,7 @@ import { shallow } from 'enzyme'; import { ClusterPermissionPanel } from '../cluster-permission-panel'; import { EuiButton, EuiEmptyPrompt, EuiLoadingSpinner } from '@elastic/eui'; import { PermissionTree } from '../../permission-tree'; -import { Action } from '../../../types'; -import { ResourceType } from '../../../../../../common'; +import { Action, ResourceType } from '../../../types'; import { buildHashUrl } from '../../../utils/url-builder'; describe('Role view - cluster permission panel', () => { diff --git a/public/apps/configuration/panels/role-view/test/index-permission-panel.test.tsx b/public/apps/configuration/panels/role-view/test/index-permission-panel.test.tsx index dc9632eb2..4c2f25555 100644 --- a/public/apps/configuration/panels/role-view/test/index-permission-panel.test.tsx +++ b/public/apps/configuration/panels/role-view/test/index-permission-panel.test.tsx @@ -15,8 +15,7 @@ import React from 'react'; import { shallow, mount } from 'enzyme'; -import { Action, RoleIndexPermissionView } from '../../../types'; -import { ResourceType } from '../../../../../../common'; +import { Action, ResourceType, RoleIndexPermissionView } from '../../../types'; import { renderFieldLevelSecurity, renderRowExpanstionArrow, diff --git a/public/apps/configuration/panels/role-view/test/role-view.test.tsx b/public/apps/configuration/panels/role-view/test/role-view.test.tsx index 424154348..d793172ca 100644 --- a/public/apps/configuration/panels/role-view/test/role-view.test.tsx +++ b/public/apps/configuration/panels/role-view/test/role-view.test.tsx @@ -30,8 +30,7 @@ import { getRoleDetail } from '../../../utils/role-detail-utils'; import { transformRoleIndexPermissions } from '../../../utils/index-permission-utils'; import { useDeleteConfirmState } from '../../../utils/delete-confirm-modal-utils'; import { requestDeleteRoles } from '../../../utils/role-list-utils'; -import { Action, SubAction } from '../../../types'; -import { ResourceType } from '../../../../../../common'; +import { Action, ResourceType, SubAction } from '../../../types'; import { buildHashUrl } from '../../../utils/url-builder'; import { createUnknownErrorToast } from '../../../utils/toast-utils'; diff --git a/public/apps/configuration/panels/role-view/test/tenants-panel.test.tsx b/public/apps/configuration/panels/role-view/test/tenants-panel.test.tsx index 5f5bb933d..75cd9452e 100644 --- a/public/apps/configuration/panels/role-view/test/tenants-panel.test.tsx +++ b/public/apps/configuration/panels/role-view/test/tenants-panel.test.tsx @@ -18,8 +18,7 @@ import { mount, shallow } from 'enzyme'; import { TenantsPanel } from '../tenants-panel'; import { EuiEmptyPrompt, EuiInMemoryTable, EuiTableFieldDataColumnType } from '@elastic/eui'; import { buildHashUrl } from '../../../utils/url-builder'; -import { Action, RoleTenantPermissionDetail } from '../../../types'; -import { ResourceType } from '../../../../../../common'; +import { Action, ResourceType, RoleTenantPermissionDetail } from '../../../types'; import { RoleViewTenantInvalidText } from '../../../constants'; jest.mock('../../../utils/tenant-utils'); diff --git a/public/apps/configuration/panels/service-account-list.tsx b/public/apps/configuration/panels/service-account-list.tsx index 9feebba4a..61c21a9e5 100644 --- a/public/apps/configuration/panels/service-account-list.tsx +++ b/public/apps/configuration/panels/service-account-list.tsx @@ -34,8 +34,7 @@ import React, { useState } from 'react'; import { getAuthInfo } from '../../../utils/auth-info-utils'; import { AppDependencies } from '../../types'; import { API_ENDPOINT_SERVICEACCOUNTS, DocLinks } from '../constants'; -import { Action } from '../types'; -import { ResourceType } from '../../../../common'; +import { Action, ResourceType } from '../types'; import { EMPTY_FIELD_VALUE } from '../ui-constants'; import { useContextMenuState } from '../utils/context-menu'; import { ExternalLink, tableItemsUIProps, truncatedListView } from '../utils/display-utils'; diff --git a/public/apps/configuration/panels/tenant-list/manage_tab.tsx b/public/apps/configuration/panels/tenant-list/manage_tab.tsx index b235bd3ba..8f813f82b 100644 --- a/public/apps/configuration/panels/tenant-list/manage_tab.tsx +++ b/public/apps/configuration/panels/tenant-list/manage_tab.tsx @@ -39,10 +39,10 @@ import React, { ReactNode, useState, useCallback } from 'react'; import { difference } from 'lodash'; import { HashRouter as Router, Route } from 'react-router-dom'; import { flow } from 'lodash'; +import { TenancyConfigSettings } from '../tenancy-config/types'; import { getCurrentUser } from '../../../../utils/auth-info-utils'; import { AppDependencies } from '../../../types'; -import { Action, Tenant } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { Action, ResourceType, Tenant } from '../../types'; import { ExternalLink, renderCustomization, tableItemsUIProps } from '../../utils/display-utils'; import { fetchTenants, @@ -481,7 +481,8 @@ export function ManageTab(props: AppDependencies) { return ( <> {/*{tenancyDisabledWarning}*/} - + + diff --git a/public/apps/configuration/panels/test/get-started.test.tsx b/public/apps/configuration/panels/test/get-started.test.tsx index e51af78f0..a3eb65bf1 100644 --- a/public/apps/configuration/panels/test/get-started.test.tsx +++ b/public/apps/configuration/panels/test/get-started.test.tsx @@ -16,8 +16,7 @@ import { shallow } from 'enzyme'; import React from 'react'; import { EuiSteps } from '@elastic/eui'; -import { Action } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { Action, ResourceType } from '../../types'; import { buildHashUrl } from '../../utils/url-builder'; import { GetStarted } from '../get-started'; diff --git a/public/apps/configuration/panels/test/role-list.test.tsx b/public/apps/configuration/panels/test/role-list.test.tsx index a70dac666..445cdac43 100644 --- a/public/apps/configuration/panels/test/role-list.test.tsx +++ b/public/apps/configuration/panels/test/role-list.test.tsx @@ -18,8 +18,7 @@ import { mount, shallow } from 'enzyme'; import React from 'react'; import { EuiInMemoryTable, EuiTableFieldDataColumnType } from '@elastic/eui'; import { buildHashUrl } from '../../utils/url-builder'; -import { Action } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { Action, ResourceType } from '../../types'; import { RoleListing } from '../../utils/role-list-utils'; import { useDeleteConfirmState } from '../../utils/delete-confirm-modal-utils'; diff --git a/public/apps/configuration/panels/test/service-account-list.test.tsx b/public/apps/configuration/panels/test/service-account-list.test.tsx index d5407aeae..2ffe595e8 100644 --- a/public/apps/configuration/panels/test/service-account-list.test.tsx +++ b/public/apps/configuration/panels/test/service-account-list.test.tsx @@ -32,8 +32,7 @@ jest.mock('../../utils/context-menu', () => ({ import { getAuthInfo } from '../../../../utils/auth-info-utils'; import { buildHashUrl } from '../../utils/url-builder'; -import { Action } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { ResourceType, Action } from '../../types'; describe('User list', () => { describe('dictView', () => { diff --git a/public/apps/configuration/panels/test/user-list.test.tsx b/public/apps/configuration/panels/test/user-list.test.tsx index 32455fa53..fd28e74cf 100644 --- a/public/apps/configuration/panels/test/user-list.test.tsx +++ b/public/apps/configuration/panels/test/user-list.test.tsx @@ -40,8 +40,7 @@ jest.mock('../../utils/context-menu', () => ({ import { getAuthInfo } from '../../../../utils/auth-info-utils'; import { buildHashUrl } from '../../utils/url-builder'; -import { Action } from '../../types'; -import { ResourceType } from '../../../../../common'; +import { ResourceType, Action } from '../../types'; describe('User list', () => { describe('dictView', () => { diff --git a/public/apps/configuration/panels/user-list.tsx b/public/apps/configuration/panels/user-list.tsx index b75f62283..eb369f7ad 100644 --- a/public/apps/configuration/panels/user-list.tsx +++ b/public/apps/configuration/panels/user-list.tsx @@ -35,8 +35,7 @@ import React, { useState } from 'react'; import { getAuthInfo } from '../../../utils/auth-info-utils'; import { AppDependencies } from '../../types'; import { API_ENDPOINT_INTERNALUSERS, DocLinks } from '../constants'; -import { Action } from '../types'; -import { ResourceType } from '../../../../common'; +import { Action, ResourceType } from '../types'; import { EMPTY_FIELD_VALUE } from '../ui-constants'; import { useContextMenuState } from '../utils/context-menu'; import { useDeleteConfirmState } from '../utils/delete-confirm-modal-utils'; diff --git a/public/apps/configuration/types.ts b/public/apps/configuration/types.ts index 967072d18..fd64e1095 100644 --- a/public/apps/configuration/types.ts +++ b/public/apps/configuration/types.ts @@ -19,6 +19,18 @@ export type ComboBoxOptions = EuiComboBoxOptionOption[]; export type FieldLevelSecurityMethod = 'exclude' | 'include'; +export enum ResourceType { + roles = 'roles', + users = 'users', + serviceAccounts = 'serviceAccounts', + permissions = 'permissions', + tenants = 'tenants', + tenantsManageTab = 'tenantsManageTab', + tenantsConfigureTab = 'tenantsConfigureTab', + auth = 'auth', + auditLogging = 'auditLogging', +} + export enum Action { view = 'view', create = 'create', diff --git a/public/apps/configuration/utils/internal-user-list-utils.tsx b/public/apps/configuration/utils/internal-user-list-utils.tsx index 19b0488c7..02042e928 100644 --- a/public/apps/configuration/utils/internal-user-list-utils.tsx +++ b/public/apps/configuration/utils/internal-user-list-utils.tsx @@ -20,8 +20,7 @@ import { API_ENDPOINT_INTERNALUSERS, API_ENDPOINT_SERVICEACCOUNTS, } from '../constants'; -import { DataObject, InternalUser, ObjectsMessage } from '../types'; -import { ResourceType } from '../../../../common'; +import { DataObject, InternalUser, ObjectsMessage, ResourceType } from '../types'; import { httpDelete, httpGet } from './request-utils'; import { getResourceUrl } from './resource-utils'; diff --git a/public/apps/configuration/utils/url-builder.tsx b/public/apps/configuration/utils/url-builder.tsx index e15aa7975..5337f627d 100644 --- a/public/apps/configuration/utils/url-builder.tsx +++ b/public/apps/configuration/utils/url-builder.tsx @@ -13,8 +13,7 @@ * permissions and limitations under the License. */ -import { Action } from '../types'; -import { ResourceType } from '../../../../common'; +import { ResourceType, Action } from '../types'; /** * Build hash based url, encode the resourceId part diff --git a/server/routes/index.ts b/server/routes/index.ts index 934c63da7..ad3dfbd58 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -21,7 +21,7 @@ import { OpenSearchDashboardsResponseFactory, } from 'opensearch-dashboards/server'; import { API_PREFIX, CONFIGURATION_API_PREFIX, isValidResourceName } from '../../common'; -import { ResourceType } from '../../common'; +import { ResourceType } from '../../public/apps/configuration/types'; // TODO: consider to extract entity CRUD operations and put it into a client class export function defineRoutes(router: IRouter) { From be162f8dcee91df80d0aa11d4e91dfe85082817a Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 16 Jan 2024 10:07:02 -0500 Subject: [PATCH 29/35] Revert "Revert "fix Cannot find module when import ResourceType in server from public folder (#1705)"" This reverts commit 2de58e36d988a7aa601eb69f94b323acedaa1884. Signed-off-by: Derek Ho --- common/index.ts | 12 ++++++++++++ public/apps/configuration/app-router.tsx | 3 ++- .../audit-logging/audit-logging-edit-settings.tsx | 2 +- .../panels/audit-logging/audit-logging.tsx | 2 +- .../test/audit-logging-edit-settings.test.tsx | 2 +- .../panels/audit-logging/test/audit-logging.test.tsx | 2 +- public/apps/configuration/panels/get-started.tsx | 11 +++-------- .../panels/internal-user-edit/internal-user-edit.tsx | 3 ++- .../panels/role-edit/cluster-permission-panel.tsx | 3 ++- .../panels/role-edit/index-permission-panel.tsx | 7 ++++--- .../configuration/panels/role-edit/role-edit.tsx | 3 ++- public/apps/configuration/panels/role-list.tsx | 3 ++- .../panels/role-mapping/role-edit-mapped-user.tsx | 3 ++- .../panels/role-mapping/users-panel.tsx | 3 ++- .../panels/role-view/cluster-permission-panel.tsx | 3 ++- .../panels/role-view/index-permission-panel.tsx | 2 +- .../configuration/panels/role-view/role-view.tsx | 2 +- .../configuration/panels/role-view/tenants-panel.tsx | 8 ++------ .../role-view/test/cluster-permission-panel.test.tsx | 3 ++- .../role-view/test/index-permission-panel.test.tsx | 3 ++- .../panels/role-view/test/role-view.test.tsx | 3 ++- .../panels/role-view/test/tenants-panel.test.tsx | 3 ++- .../configuration/panels/service-account-list.tsx | 3 ++- .../configuration/panels/tenant-list/manage_tab.tsx | 7 +++---- .../configuration/panels/test/get-started.test.tsx | 3 ++- .../configuration/panels/test/role-list.test.tsx | 3 ++- .../panels/test/service-account-list.test.tsx | 3 ++- .../configuration/panels/test/user-list.test.tsx | 3 ++- public/apps/configuration/panels/user-list.tsx | 3 ++- public/apps/configuration/types.ts | 12 ------------ .../configuration/utils/internal-user-list-utils.tsx | 3 ++- public/apps/configuration/utils/url-builder.tsx | 3 ++- server/routes/index.ts | 2 +- 33 files changed, 71 insertions(+), 60 deletions(-) diff --git a/common/index.ts b/common/index.ts index 9b038a581..b5e6a475d 100644 --- a/common/index.ts +++ b/common/index.ts @@ -64,6 +64,18 @@ export enum AuthType { ANONYMOUS = 'anonymous', } +export enum ResourceType { + roles = 'roles', + users = 'users', + serviceAccounts = 'serviceAccounts', + permissions = 'permissions', + tenants = 'tenants', + tenantsManageTab = 'tenantsManageTab', + tenantsConfigureTab = 'tenantsConfigureTab', + auth = 'auth', + auditLogging = 'auditLogging', +} + /** * A valid resource name should not containing percent sign (%) as they raise url injection issue. * And also should not be empty. diff --git a/public/apps/configuration/app-router.tsx b/public/apps/configuration/app-router.tsx index a10cec08e..2e4ce7ca3 100644 --- a/public/apps/configuration/app-router.tsx +++ b/public/apps/configuration/app-router.tsx @@ -36,7 +36,8 @@ import { RoleView } from './panels/role-view/role-view'; import { TenantList } from './panels/tenant-list/tenant-list'; import { UserList } from './panels/user-list'; import { ServiceAccountList } from './panels/service-account-list'; -import { Action, ResourceType, RouteItem, SubAction } from './types'; +import { Action, RouteItem, SubAction } from './types'; +import { ResourceType } from '../../../common'; import { buildHashUrl, buildUrl } from './utils/url-builder'; import { CrossPageToast } from './cross-page-toast'; diff --git a/public/apps/configuration/panels/audit-logging/audit-logging-edit-settings.tsx b/public/apps/configuration/panels/audit-logging/audit-logging-edit-settings.tsx index 972442978..de5d0086f 100644 --- a/public/apps/configuration/panels/audit-logging/audit-logging-edit-settings.tsx +++ b/public/apps/configuration/panels/audit-logging/audit-logging-edit-settings.tsx @@ -31,7 +31,7 @@ import { SETTING_GROUPS, SettingMapItem } from './constants'; import { EditSettingGroup } from './edit-setting-group'; import { AuditLoggingSettings } from './types'; import { buildHashUrl, buildUrl } from '../../utils/url-builder'; -import { ResourceType } from '../../types'; +import { ResourceType } from '../../../../../common'; import { getAuditLogging, updateAuditLogging } from '../../utils/audit-logging-utils'; import { useToastState } from '../../utils/toast-utils'; import { setCrossPageToast } from '../../utils/storage-utils'; diff --git a/public/apps/configuration/panels/audit-logging/audit-logging.tsx b/public/apps/configuration/panels/audit-logging/audit-logging.tsx index e920c32e0..5ca10c84c 100644 --- a/public/apps/configuration/panels/audit-logging/audit-logging.tsx +++ b/public/apps/configuration/panels/audit-logging/audit-logging.tsx @@ -31,7 +31,7 @@ import { import React from 'react'; import { FormattedMessage } from '@osd/i18n/react'; import { AppDependencies } from '../../../types'; -import { ResourceType } from '../../types'; +import { ResourceType } from '../../../../../common'; import { getAuditLogging, updateAuditLogging } from '../../utils/audit-logging-utils'; import { displayBoolean, ExternalLink } from '../../utils/display-utils'; import { buildHashUrl } from '../../utils/url-builder'; diff --git a/public/apps/configuration/panels/audit-logging/test/audit-logging-edit-settings.test.tsx b/public/apps/configuration/panels/audit-logging/test/audit-logging-edit-settings.test.tsx index 038b0c5c8..a7b52d428 100644 --- a/public/apps/configuration/panels/audit-logging/test/audit-logging-edit-settings.test.tsx +++ b/public/apps/configuration/panels/audit-logging/test/audit-logging-edit-settings.test.tsx @@ -18,7 +18,7 @@ import { AuditLoggingEditSettings } from '../audit-logging-edit-settings'; import React from 'react'; import { ComplianceSettings, GeneralSettings } from '../types'; import { buildHashUrl } from '../../../utils/url-builder'; -import { ResourceType } from '../../../types'; +import { ResourceType } from '../../../../../../common'; jest.mock('../../../utils/audit-logging-utils'); diff --git a/public/apps/configuration/panels/audit-logging/test/audit-logging.test.tsx b/public/apps/configuration/panels/audit-logging/test/audit-logging.test.tsx index 35e6d0273..2bc5d4881 100644 --- a/public/apps/configuration/panels/audit-logging/test/audit-logging.test.tsx +++ b/public/apps/configuration/panels/audit-logging/test/audit-logging.test.tsx @@ -18,7 +18,7 @@ import { AuditLogging, renderComplianceSettings, renderGeneralSettings } from '. import React from 'react'; import { EuiSwitch } from '@elastic/eui'; import { buildHashUrl } from '../../../utils/url-builder'; -import { ResourceType } from '../../../types'; +import { ResourceType } from '../../../../../../common'; import { SUB_URL_FOR_COMPLIANCE_SETTINGS_EDIT, SUB_URL_FOR_GENERAL_SETTINGS_EDIT, diff --git a/public/apps/configuration/panels/get-started.tsx b/public/apps/configuration/panels/get-started.tsx index b2c562e35..dcf4fed41 100644 --- a/public/apps/configuration/panels/get-started.tsx +++ b/public/apps/configuration/panels/get-started.tsx @@ -27,17 +27,12 @@ import { } from '@elastic/eui'; import React from 'react'; import { FormattedMessage } from '@osd/i18n/react'; -import { flow } from 'lodash'; -import { HashRouter as Router, Route } from 'react-router-dom'; import { AppDependencies } from '../../types'; -import { buildHashUrl, buildUrl } from '../utils/url-builder'; -import { Action, ResourceType, RouteItem } from '../types'; +import { buildHashUrl } from '../utils/url-builder'; +import { Action } from '../types'; +import { ResourceType } from '../../../../common'; import { API_ENDPOINT_CACHE, DocLinks } from '../constants'; import { ExternalLink, ExternalLinkButton } from '../utils/display-utils'; -import { TenantList } from './tenant-list/tenant-list'; -import { getBreadcrumbs } from '../app-router'; - -import { CrossPageToast } from '../cross-page-toast'; const addBackendStep = { title: 'Add backends', diff --git a/public/apps/configuration/panels/internal-user-edit/internal-user-edit.tsx b/public/apps/configuration/panels/internal-user-edit/internal-user-edit.tsx index f93ef0407..1237ef9f3 100644 --- a/public/apps/configuration/panels/internal-user-edit/internal-user-edit.tsx +++ b/public/apps/configuration/panels/internal-user-edit/internal-user-edit.tsx @@ -26,7 +26,8 @@ import { } from '@elastic/eui'; import React, { useState } from 'react'; import { BreadcrumbsPageDependencies } from '../../../types'; -import { InternalUserUpdate, ResourceType } from '../../types'; +import { InternalUserUpdate } from '../../types'; +import { ResourceType } from '../../../../../common'; import { getUserDetail, updateUser } from '../../utils/internal-user-detail-utils'; import { PanelWithHeader } from '../../utils/panel-with-header'; import { PasswordEditPanel } from '../../utils/password-edit-panel'; diff --git a/public/apps/configuration/panels/role-edit/cluster-permission-panel.tsx b/public/apps/configuration/panels/role-edit/cluster-permission-panel.tsx index e80d0d0e1..3ac52f6d3 100644 --- a/public/apps/configuration/panels/role-edit/cluster-permission-panel.tsx +++ b/public/apps/configuration/panels/role-edit/cluster-permission-panel.tsx @@ -15,7 +15,8 @@ import React, { Dispatch, SetStateAction } from 'react'; import { EuiForm, EuiFlexGroup, EuiFlexItem, EuiComboBox } from '@elastic/eui'; -import { ComboBoxOptions, ResourceType } from '../../types'; +import { ComboBoxOptions } from '../../types'; +import { ResourceType } from '../../../../../common'; import { PanelWithHeader } from '../../utils/panel-with-header'; import { FormRow } from '../../utils/form-row'; import { LIMIT_WIDTH_INPUT_CLASS } from '../../constants'; diff --git a/public/apps/configuration/panels/role-edit/index-permission-panel.tsx b/public/apps/configuration/panels/role-edit/index-permission-panel.tsx index 75e2856e4..e52cb9128 100644 --- a/public/apps/configuration/panels/role-edit/index-permission-panel.tsx +++ b/public/apps/configuration/panels/role-edit/index-permission-panel.tsx @@ -25,7 +25,8 @@ import { } from '@elastic/eui'; import React, { Dispatch, Fragment, SetStateAction } from 'react'; import { isEmpty } from 'lodash'; -import { RoleIndexPermission, ResourceType } from '../../types'; +import { RoleIndexPermission } from '../../types'; +import { ResourceType } from '../../../../../common'; import { appendElementToArray, removeElementFromArray, @@ -141,9 +142,9 @@ export function IndexPermissionRow(props: { return ( diff --git a/public/apps/configuration/panels/role-edit/role-edit.tsx b/public/apps/configuration/panels/role-edit/role-edit.tsx index 936d5774b..a3364fe0b 100644 --- a/public/apps/configuration/panels/role-edit/role-edit.tsx +++ b/public/apps/configuration/panels/role-edit/role-edit.tsx @@ -46,7 +46,8 @@ import { } from './tenant-panel'; import { RoleIndexPermissionStateClass, RoleTenantPermissionStateClass } from './types'; import { buildHashUrl, buildUrl } from '../../utils/url-builder'; -import { ComboBoxOptions, ResourceType, Action, ActionGroupItem } from '../../types'; +import { ComboBoxOptions, Action, ActionGroupItem } from '../../types'; +import { ResourceType } from '../../../../../common'; import { useToastState, createUnknownErrorToast, diff --git a/public/apps/configuration/panels/role-list.tsx b/public/apps/configuration/panels/role-list.tsx index 1fb27a228..c9ecab34b 100644 --- a/public/apps/configuration/panels/role-list.tsx +++ b/public/apps/configuration/panels/role-list.tsx @@ -41,7 +41,8 @@ import { fetchRoleMapping, buildSearchFilterOptions, } from '../utils/role-list-utils'; -import { ResourceType, Action } from '../types'; +import { Action } from '../types'; +import { ResourceType } from '../../../../common'; import { buildHashUrl } from '../utils/url-builder'; import { ExternalLink, diff --git a/public/apps/configuration/panels/role-mapping/role-edit-mapped-user.tsx b/public/apps/configuration/panels/role-mapping/role-edit-mapped-user.tsx index 9b2a859da..44909bef5 100644 --- a/public/apps/configuration/panels/role-mapping/role-edit-mapped-user.tsx +++ b/public/apps/configuration/panels/role-mapping/role-edit-mapped-user.tsx @@ -35,7 +35,8 @@ import { ExternalIdentityStateClass } from './types'; import { ComboBoxOptions } from '../../types'; import { stringToComboBoxOption, comboBoxOptionToString } from '../../utils/combo-box-utils'; import { buildHashUrl, buildUrl } from '../../utils/url-builder'; -import { ResourceType, RoleMappingDetail, SubAction, Action } from '../../types'; +import { RoleMappingDetail, SubAction, Action } from '../../types'; +import { ResourceType } from '../../../../../common'; import { fetchUserNameList } from '../../utils/internal-user-list-utils'; import { updateRoleMapping, getRoleMappingData } from '../../utils/role-mapping-utils'; import { createErrorToast, createUnknownErrorToast, useToastState } from '../../utils/toast-utils'; diff --git a/public/apps/configuration/panels/role-mapping/users-panel.tsx b/public/apps/configuration/panels/role-mapping/users-panel.tsx index 39cec7538..6c65a152b 100644 --- a/public/apps/configuration/panels/role-mapping/users-panel.tsx +++ b/public/apps/configuration/panels/role-mapping/users-panel.tsx @@ -19,7 +19,8 @@ import { ComboBoxOptions } from '../../types'; import { PanelWithHeader } from '../../utils/panel-with-header'; import { FormRow } from '../../utils/form-row'; import { buildHashUrl } from '../../utils/url-builder'; -import { ResourceType, Action } from '../../types'; +import { Action } from '../../types'; +import { ResourceType } from '../../../../../common'; import { ExternalLinkButton } from '../../utils/display-utils'; import { DocLinks } from '../../constants'; import { appendOptionToComboBoxHandler } from '../../utils/combo-box-utils'; diff --git a/public/apps/configuration/panels/role-view/cluster-permission-panel.tsx b/public/apps/configuration/panels/role-view/cluster-permission-panel.tsx index 3d4a02df5..659f98c13 100644 --- a/public/apps/configuration/panels/role-view/cluster-permission-panel.tsx +++ b/public/apps/configuration/panels/role-view/cluster-permission-panel.tsx @@ -17,7 +17,8 @@ import React from 'react'; import { EuiEmptyPrompt, EuiButton } from '@elastic/eui'; import { PanelWithHeader } from '../../utils/panel-with-header'; import { PermissionTree } from '../permission-tree'; -import { ActionGroupItem, DataObject, ResourceType, Action } from '../../types'; +import { ActionGroupItem, DataObject, Action } from '../../types'; +import { ResourceType } from '../../../../../common'; import { buildHashUrl } from '../../utils/url-builder'; import { loadingSpinner } from '../../utils/loading-spinner-utils'; import { DocLinks } from '../../constants'; diff --git a/public/apps/configuration/panels/role-view/index-permission-panel.tsx b/public/apps/configuration/panels/role-view/index-permission-panel.tsx index b04583522..8c622afd3 100644 --- a/public/apps/configuration/panels/role-view/index-permission-panel.tsx +++ b/public/apps/configuration/panels/role-view/index-permission-panel.tsx @@ -30,9 +30,9 @@ import { ActionGroupItem, ExpandedRowMapInterface, RoleIndexPermissionView, - ResourceType, Action, } from '../../types'; +import { ResourceType } from '../../../../../common'; import { truncatedListView, displayArray, tableItemsUIProps } from '../../utils/display-utils'; import { PermissionTree } from '../permission-tree'; import { getFieldLevelSecurityMethod } from '../../utils/index-permission-utils'; diff --git a/public/apps/configuration/panels/role-view/role-view.tsx b/public/apps/configuration/panels/role-view/role-view.tsx index 04e5d1f99..723d546da 100644 --- a/public/apps/configuration/panels/role-view/role-view.tsx +++ b/public/apps/configuration/panels/role-view/role-view.tsx @@ -39,7 +39,6 @@ import { difference } from 'lodash'; import { BreadcrumbsPageDependencies } from '../../../types'; import { buildHashUrl, buildUrl } from '../../utils/url-builder'; import { - ResourceType, Action, SubAction, RoleMappingDetail, @@ -48,6 +47,7 @@ import { RoleIndexPermissionView, RoleTenantPermissionView, } from '../../types'; +import { ResourceType } from '../../../../../common'; import { getRoleMappingData, MappedUsersListing, diff --git a/public/apps/configuration/panels/role-view/tenants-panel.tsx b/public/apps/configuration/panels/role-view/tenants-panel.tsx index 667b34f45..45d19bb2b 100644 --- a/public/apps/configuration/panels/role-view/tenants-panel.tsx +++ b/public/apps/configuration/panels/role-view/tenants-panel.tsx @@ -26,12 +26,8 @@ import { import { CoreStart } from 'opensearch-dashboards/public'; import { getCurrentUser } from '../../../../utils/auth-info-utils'; import { PanelWithHeader } from '../../utils/panel-with-header'; -import { - RoleTenantPermissionView, - RoleTenantPermissionDetail, - ResourceType, - Action, -} from '../../types'; +import { RoleTenantPermissionView, RoleTenantPermissionDetail, Action } from '../../types'; +import { ResourceType } from '../../../../../common'; import { truncatedListView, tableItemsUIProps } from '../../utils/display-utils'; import { fetchTenants, diff --git a/public/apps/configuration/panels/role-view/test/cluster-permission-panel.test.tsx b/public/apps/configuration/panels/role-view/test/cluster-permission-panel.test.tsx index 5891ac502..8e7d5be0c 100644 --- a/public/apps/configuration/panels/role-view/test/cluster-permission-panel.test.tsx +++ b/public/apps/configuration/panels/role-view/test/cluster-permission-panel.test.tsx @@ -18,7 +18,8 @@ import { shallow } from 'enzyme'; import { ClusterPermissionPanel } from '../cluster-permission-panel'; import { EuiButton, EuiEmptyPrompt, EuiLoadingSpinner } from '@elastic/eui'; import { PermissionTree } from '../../permission-tree'; -import { Action, ResourceType } from '../../../types'; +import { Action } from '../../../types'; +import { ResourceType } from '../../../../../../common'; import { buildHashUrl } from '../../../utils/url-builder'; describe('Role view - cluster permission panel', () => { diff --git a/public/apps/configuration/panels/role-view/test/index-permission-panel.test.tsx b/public/apps/configuration/panels/role-view/test/index-permission-panel.test.tsx index 4c2f25555..dc9632eb2 100644 --- a/public/apps/configuration/panels/role-view/test/index-permission-panel.test.tsx +++ b/public/apps/configuration/panels/role-view/test/index-permission-panel.test.tsx @@ -15,7 +15,8 @@ import React from 'react'; import { shallow, mount } from 'enzyme'; -import { Action, ResourceType, RoleIndexPermissionView } from '../../../types'; +import { Action, RoleIndexPermissionView } from '../../../types'; +import { ResourceType } from '../../../../../../common'; import { renderFieldLevelSecurity, renderRowExpanstionArrow, diff --git a/public/apps/configuration/panels/role-view/test/role-view.test.tsx b/public/apps/configuration/panels/role-view/test/role-view.test.tsx index d793172ca..424154348 100644 --- a/public/apps/configuration/panels/role-view/test/role-view.test.tsx +++ b/public/apps/configuration/panels/role-view/test/role-view.test.tsx @@ -30,7 +30,8 @@ import { getRoleDetail } from '../../../utils/role-detail-utils'; import { transformRoleIndexPermissions } from '../../../utils/index-permission-utils'; import { useDeleteConfirmState } from '../../../utils/delete-confirm-modal-utils'; import { requestDeleteRoles } from '../../../utils/role-list-utils'; -import { Action, ResourceType, SubAction } from '../../../types'; +import { Action, SubAction } from '../../../types'; +import { ResourceType } from '../../../../../../common'; import { buildHashUrl } from '../../../utils/url-builder'; import { createUnknownErrorToast } from '../../../utils/toast-utils'; diff --git a/public/apps/configuration/panels/role-view/test/tenants-panel.test.tsx b/public/apps/configuration/panels/role-view/test/tenants-panel.test.tsx index 75cd9452e..5f5bb933d 100644 --- a/public/apps/configuration/panels/role-view/test/tenants-panel.test.tsx +++ b/public/apps/configuration/panels/role-view/test/tenants-panel.test.tsx @@ -18,7 +18,8 @@ import { mount, shallow } from 'enzyme'; import { TenantsPanel } from '../tenants-panel'; import { EuiEmptyPrompt, EuiInMemoryTable, EuiTableFieldDataColumnType } from '@elastic/eui'; import { buildHashUrl } from '../../../utils/url-builder'; -import { Action, ResourceType, RoleTenantPermissionDetail } from '../../../types'; +import { Action, RoleTenantPermissionDetail } from '../../../types'; +import { ResourceType } from '../../../../../../common'; import { RoleViewTenantInvalidText } from '../../../constants'; jest.mock('../../../utils/tenant-utils'); diff --git a/public/apps/configuration/panels/service-account-list.tsx b/public/apps/configuration/panels/service-account-list.tsx index 61c21a9e5..9feebba4a 100644 --- a/public/apps/configuration/panels/service-account-list.tsx +++ b/public/apps/configuration/panels/service-account-list.tsx @@ -34,7 +34,8 @@ import React, { useState } from 'react'; import { getAuthInfo } from '../../../utils/auth-info-utils'; import { AppDependencies } from '../../types'; import { API_ENDPOINT_SERVICEACCOUNTS, DocLinks } from '../constants'; -import { Action, ResourceType } from '../types'; +import { Action } from '../types'; +import { ResourceType } from '../../../../common'; import { EMPTY_FIELD_VALUE } from '../ui-constants'; import { useContextMenuState } from '../utils/context-menu'; import { ExternalLink, tableItemsUIProps, truncatedListView } from '../utils/display-utils'; diff --git a/public/apps/configuration/panels/tenant-list/manage_tab.tsx b/public/apps/configuration/panels/tenant-list/manage_tab.tsx index 8f813f82b..b235bd3ba 100644 --- a/public/apps/configuration/panels/tenant-list/manage_tab.tsx +++ b/public/apps/configuration/panels/tenant-list/manage_tab.tsx @@ -39,10 +39,10 @@ import React, { ReactNode, useState, useCallback } from 'react'; import { difference } from 'lodash'; import { HashRouter as Router, Route } from 'react-router-dom'; import { flow } from 'lodash'; -import { TenancyConfigSettings } from '../tenancy-config/types'; import { getCurrentUser } from '../../../../utils/auth-info-utils'; import { AppDependencies } from '../../../types'; -import { Action, ResourceType, Tenant } from '../../types'; +import { Action, Tenant } from '../../types'; +import { ResourceType } from '../../../../../common'; import { ExternalLink, renderCustomization, tableItemsUIProps } from '../../utils/display-utils'; import { fetchTenants, @@ -481,8 +481,7 @@ export function ManageTab(props: AppDependencies) { return ( <> {/*{tenancyDisabledWarning}*/} - - + diff --git a/public/apps/configuration/panels/test/get-started.test.tsx b/public/apps/configuration/panels/test/get-started.test.tsx index a3eb65bf1..e51af78f0 100644 --- a/public/apps/configuration/panels/test/get-started.test.tsx +++ b/public/apps/configuration/panels/test/get-started.test.tsx @@ -16,7 +16,8 @@ import { shallow } from 'enzyme'; import React from 'react'; import { EuiSteps } from '@elastic/eui'; -import { Action, ResourceType } from '../../types'; +import { Action } from '../../types'; +import { ResourceType } from '../../../../../common'; import { buildHashUrl } from '../../utils/url-builder'; import { GetStarted } from '../get-started'; diff --git a/public/apps/configuration/panels/test/role-list.test.tsx b/public/apps/configuration/panels/test/role-list.test.tsx index 445cdac43..a70dac666 100644 --- a/public/apps/configuration/panels/test/role-list.test.tsx +++ b/public/apps/configuration/panels/test/role-list.test.tsx @@ -18,7 +18,8 @@ import { mount, shallow } from 'enzyme'; import React from 'react'; import { EuiInMemoryTable, EuiTableFieldDataColumnType } from '@elastic/eui'; import { buildHashUrl } from '../../utils/url-builder'; -import { Action, ResourceType } from '../../types'; +import { Action } from '../../types'; +import { ResourceType } from '../../../../../common'; import { RoleListing } from '../../utils/role-list-utils'; import { useDeleteConfirmState } from '../../utils/delete-confirm-modal-utils'; diff --git a/public/apps/configuration/panels/test/service-account-list.test.tsx b/public/apps/configuration/panels/test/service-account-list.test.tsx index 2ffe595e8..d5407aeae 100644 --- a/public/apps/configuration/panels/test/service-account-list.test.tsx +++ b/public/apps/configuration/panels/test/service-account-list.test.tsx @@ -32,7 +32,8 @@ jest.mock('../../utils/context-menu', () => ({ import { getAuthInfo } from '../../../../utils/auth-info-utils'; import { buildHashUrl } from '../../utils/url-builder'; -import { ResourceType, Action } from '../../types'; +import { Action } from '../../types'; +import { ResourceType } from '../../../../../common'; describe('User list', () => { describe('dictView', () => { diff --git a/public/apps/configuration/panels/test/user-list.test.tsx b/public/apps/configuration/panels/test/user-list.test.tsx index fd28e74cf..32455fa53 100644 --- a/public/apps/configuration/panels/test/user-list.test.tsx +++ b/public/apps/configuration/panels/test/user-list.test.tsx @@ -40,7 +40,8 @@ jest.mock('../../utils/context-menu', () => ({ import { getAuthInfo } from '../../../../utils/auth-info-utils'; import { buildHashUrl } from '../../utils/url-builder'; -import { ResourceType, Action } from '../../types'; +import { Action } from '../../types'; +import { ResourceType } from '../../../../../common'; describe('User list', () => { describe('dictView', () => { diff --git a/public/apps/configuration/panels/user-list.tsx b/public/apps/configuration/panels/user-list.tsx index eb369f7ad..b75f62283 100644 --- a/public/apps/configuration/panels/user-list.tsx +++ b/public/apps/configuration/panels/user-list.tsx @@ -35,7 +35,8 @@ import React, { useState } from 'react'; import { getAuthInfo } from '../../../utils/auth-info-utils'; import { AppDependencies } from '../../types'; import { API_ENDPOINT_INTERNALUSERS, DocLinks } from '../constants'; -import { Action, ResourceType } from '../types'; +import { Action } from '../types'; +import { ResourceType } from '../../../../common'; import { EMPTY_FIELD_VALUE } from '../ui-constants'; import { useContextMenuState } from '../utils/context-menu'; import { useDeleteConfirmState } from '../utils/delete-confirm-modal-utils'; diff --git a/public/apps/configuration/types.ts b/public/apps/configuration/types.ts index fd64e1095..967072d18 100644 --- a/public/apps/configuration/types.ts +++ b/public/apps/configuration/types.ts @@ -19,18 +19,6 @@ export type ComboBoxOptions = EuiComboBoxOptionOption[]; export type FieldLevelSecurityMethod = 'exclude' | 'include'; -export enum ResourceType { - roles = 'roles', - users = 'users', - serviceAccounts = 'serviceAccounts', - permissions = 'permissions', - tenants = 'tenants', - tenantsManageTab = 'tenantsManageTab', - tenantsConfigureTab = 'tenantsConfigureTab', - auth = 'auth', - auditLogging = 'auditLogging', -} - export enum Action { view = 'view', create = 'create', diff --git a/public/apps/configuration/utils/internal-user-list-utils.tsx b/public/apps/configuration/utils/internal-user-list-utils.tsx index 02042e928..19b0488c7 100644 --- a/public/apps/configuration/utils/internal-user-list-utils.tsx +++ b/public/apps/configuration/utils/internal-user-list-utils.tsx @@ -20,7 +20,8 @@ import { API_ENDPOINT_INTERNALUSERS, API_ENDPOINT_SERVICEACCOUNTS, } from '../constants'; -import { DataObject, InternalUser, ObjectsMessage, ResourceType } from '../types'; +import { DataObject, InternalUser, ObjectsMessage } from '../types'; +import { ResourceType } from '../../../../common'; import { httpDelete, httpGet } from './request-utils'; import { getResourceUrl } from './resource-utils'; diff --git a/public/apps/configuration/utils/url-builder.tsx b/public/apps/configuration/utils/url-builder.tsx index 5337f627d..e15aa7975 100644 --- a/public/apps/configuration/utils/url-builder.tsx +++ b/public/apps/configuration/utils/url-builder.tsx @@ -13,7 +13,8 @@ * permissions and limitations under the License. */ -import { ResourceType, Action } from '../types'; +import { Action } from '../types'; +import { ResourceType } from '../../../../common'; /** * Build hash based url, encode the resourceId part diff --git a/server/routes/index.ts b/server/routes/index.ts index ad3dfbd58..934c63da7 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -21,7 +21,7 @@ import { OpenSearchDashboardsResponseFactory, } from 'opensearch-dashboards/server'; import { API_PREFIX, CONFIGURATION_API_PREFIX, isValidResourceName } from '../../common'; -import { ResourceType } from '../../public/apps/configuration/types'; +import { ResourceType } from '../../common'; // TODO: consider to extract entity CRUD operations and put it into a client class export function defineRoutes(router: IRouter) { From ed9c66d38ce31731e7fe30f01db2411a4c524bf3 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 16 Jan 2024 10:22:55 -0500 Subject: [PATCH 30/35] fix indentation Signed-off-by: Derek Ho --- .github/workflows/verify-binary-installation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index 3b0b21841..cb0107fb6 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -115,6 +115,6 @@ jobs: - name: Health check run: | - timeout 300 bash -c 'while [[ "$(curl -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k http://localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done' + timeout 300 bash -c 'while [[ "$(curl -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k http://localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done' shell: bash From 6db26c9f85552236e7b18e8e47bceafe6f87f88f Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 16 Jan 2024 10:41:04 -0500 Subject: [PATCH 31/35] Remove bash Signed-off-by: Derek Ho --- .github/workflows/verify-binary-installation.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index cb0107fb6..d9402aed7 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -116,5 +116,4 @@ jobs: - name: Health check run: | timeout 300 bash -c 'while [[ "$(curl -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k http://localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done' - shell: bash From 320cd6523140b8222b4b76d69fbbe05a6729ccbe Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 16 Jan 2024 11:08:07 -0500 Subject: [PATCH 32/35] try removing line Signed-off-by: Derek Ho --- .github/workflows/verify-binary-installation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index d9402aed7..f983c8333 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -112,8 +112,8 @@ jobs: working-directory: OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64 shell: bash - - name: Health check run: | timeout 300 bash -c 'while [[ "$(curl -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k http://localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done' + shell: bash From 54ca1f99be289b07192ccc5d1f5f8493da18d6e9 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 16 Jan 2024 11:16:50 -0500 Subject: [PATCH 33/35] Add security settings into OSD Signed-off-by: Derek Ho --- .../workflows/verify-binary-installation.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index f983c8333..6de067edf 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -106,6 +106,25 @@ jobs: working-directory: OpenSearch-Dashboards shell: bash + - name: Write security settings into OSD yml file + run: | + rm -rf ./config/opensearch_dashboards.yml + cat << 'EOT' > ./config/opensearch_dashboards.yml + server.host: "0.0.0.0" + opensearch.hosts: ["https://localhost:9200"] + opensearch.ssl.verificationMode: none + opensearch.username: "kibanaserver" + opensearch.password: "kibanaserver" + opensearch.requestHeadersWhitelist: [ authorization,securitytenant ] + opensearch_security.multitenancy.enabled: true + opensearch_security.multitenancy.tenants.preferred: ["Private", "Global"] + opensearch_security.readonly_mode.roles: ["kibana_read_only"] + + # Use this setting if you are running opensearch-dashboards without https + opensearch_security.cookie.secure: false + working-directory: OpenSearch-Dashboards/build/opensearch-dashboards-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT-linux-x64 + + - name: Start the binary run: | nohup ./bin/opensearch-dashboards & From 623dcb3a7c0168ad5a8ccbc31ac16bc98031b242 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 16 Jan 2024 11:30:33 -0500 Subject: [PATCH 34/35] Apply PR feedback Signed-off-by: Derek Ho --- .github/workflows/verify-binary-installation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index 6de067edf..62e1f5e29 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -47,7 +47,7 @@ jobs: opensearch-version: ${{ env.OPENSEARCH_VERSION }} plugin-name: ${{ env.PLUGIN_NAME }} setup-script-name: setup - admin-password: myStrongPassword123! + admin-password: ${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} - uses: actions/checkout@v2 with: From 7932eb69174eb5863cf30bbd09949c97ab628fac Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 16 Jan 2024 11:43:10 -0500 Subject: [PATCH 35/35] add a TODO Signed-off-by: Derek Ho --- .github/workflows/verify-binary-installation.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml index 62e1f5e29..04e9dc21c 100644 --- a/.github/workflows/verify-binary-installation.yml +++ b/.github/workflows/verify-binary-installation.yml @@ -16,6 +16,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] + # TODO: add windows support when OSD core is stable on windows runs-on: ${{ matrix.os }} steps: - name: Checkout Branch