Skip to content

Commit

Permalink
Abstract to take in multiple plugins, with or without security
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho committed Feb 17, 2024
1 parent 09f47d9 commit 546f2cb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ inputs:
description: 'The version of OpenSearch that should be used, e.g "3.0.0"'
required: true

plugin-name:
description: 'The name of the plugin to use, such as opensearch-security'
plugin-names:
description: 'A comma separated list of plugins to use, such as opensearch-security,opensearch-job-scheduler'
required: true

setup-script-name:
description: 'The name of the setup script you want to run i.e. "setup" (do not include file extension). Leave empty to indicate one should not be run.'
required: false

admin-password:
description: 'The admin password uses for the cluster'
security-enabled:
description: 'A boolean indicating whether this workflow is setting up OpenSearch with security'
required: true

admin-password:
description: 'The admin password uses for the cluster if security is enabled.'
required: false

runs:
using: "composite"
steps:
Expand Down Expand Up @@ -58,17 +62,22 @@ runs:
shell: pwsh

# Install the plugin
- name: Install Plugin into OpenSearch for Linux
- name: Install Plugin(s) into OpenSearch for Linux
if: ${{ runner.os == 'Linux'}}
run: |
chmod +x ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin
/bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin install file:$(pwd)/${{ inputs.plugin-name }}.zip"
for plugin in ${{ inputs.plugin-names//,/ }}; do
/bin/bash -c "yes | ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/bin/opensearch-plugin install file:$(pwd)/${plugin}.zip"
done
shell: bash

- name: Install Plugin into OpenSearch for Windows
- name: Install Plugin(s) into OpenSearch for Windows
if: ${{ runner.os == 'Windows'}}
run: |
'y' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch-plugin.bat install file:$(pwd)\${{ inputs.plugin-name }}.zip
$pluginNames = "${{ inputs.plugin-names }}" -split ','
foreach ($plugin in $pluginNames) {
'y' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch-plugin.bat install file:$(pwd)\${plugin}.zip
}
shell: pwsh

# Run any configuration scripts
Expand Down Expand Up @@ -109,17 +118,28 @@ runs:
# Verify that the server is operational
- name: Check OpenSearch Running on Linux
if: ${{ runner.os != 'Windows'}}
run: curl https://localhost:9200/_cat/plugins -u 'admin:${{ inputs.admin-password }}' -k -v --fail-with-body
run: |
if [ "${{ inputs.security-enabled }}" == "true" ]; then
curl https://localhost:9200/_cat/plugins -u 'admin:${{ inputs.admin-password }}' -k -v --fail-with-body
else
curl http://localhost:9200/_cat/plugins -v
fi
shell: bash

- name: Check OpenSearch Running on Windows
if: ${{ runner.os == 'Windows'}}
run: |
$credentialBytes = [Text.Encoding]::ASCII.GetBytes("admin:${{ inputs.admin-password }}")
$encodedCredentials = [Convert]::ToBase64String($credentialBytes)
$baseCredentials = "Basic $encodedCredentials"
$Headers = @{ Authorization = $baseCredentials }
Invoke-WebRequest -SkipCertificateCheck -Uri 'https://localhost:9200/_cat/plugins' -Headers $Headers;
if ("${{ inputs.security-enabled }}" -eq "true") {
$credentialBytes = [Text.Encoding]::ASCII.GetBytes("admin:${{ inputs.admin-password }}")
$encodedCredentials = [Convert]::ToBase64String($credentialBytes)
$baseCredentials = "Basic $encodedCredentials"
$Headers = @{ Authorization = $baseCredentials }
$url = 'https://localhost:9200/_cat/plugins'
} else {
$Headers = @{ }
$url = 'http://localhost:9200/_cat/plugins'
}
Invoke-WebRequest -SkipCertificateCheck -Uri $url -Headers $Headers;
shell: pwsh

- if: always()
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/plugin_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ jobs:
Get-Content .\setup.bat
- name: Run Opensearch with A Single Plugin
uses: ./.github/actions/start-opensearch-with-one-plugin
uses: ./.github/actions/start-opensearch-with-plugins
with:
opensearch-version: ${{ env.OPENSEARCH_VERSION }}
plugin-name: ${{ env.PLUGIN_NAME }}
plugin-names: ${{ env.PLUGIN_NAME }}
setup-script-name: setup
admin-password: ${{ steps.random-password.outputs.generated_name }}
security-enabled: true

- name: Run sanity tests
uses: gradle/gradle-build-action@v3
Expand Down

0 comments on commit 546f2cb

Please sign in to comment.