Skip to content

Commit

Permalink
Allow port flexibility (#4)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho authored Mar 14, 2024
1 parent 7937c24 commit 8ff0865
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ jobs:
run: curl http://localhost:9200/_cat/plugins -v
shell: bash

test-no-plugins-port-9201:
strategy:
fail-fast: false
matrix:
platform: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4

- uses: ./ # Use the action
with:
opensearch-version: 3.0.0
security-enabled: false
port: 9201

- name: Checks that OpenSearch is healthy
run: curl http://localhost:9201/_cat/plugins -v
shell: bash

test-with-security:
strategy:
fail-fast: false
Expand Down
16 changes: 8 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ inputs:
description: 'Path to a security config file to replace the default. Leave empty if security is not enabled or using the default config'
required: false

opensearch_yml_file:
description: 'Path to a opensearch.yml file to replace the default. Leave empty to use the default config'
port:
description: 'Port to run OpenSearch. Leave empty to use the default config (9200)'
required: false

runs:
Expand Down Expand Up @@ -127,9 +127,9 @@ runs:
shell: bash

- name: Replace opensearch.yml file if applicable
if: ${{ inputs.opensearch_yml_file != '' }}
if: ${{ inputs.port != '' }}
run: |
mv ${{ inputs.opensearch_yml_file }} ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml
echo -e "\nhttp.port: ${{ inputs.port }}" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml
shell: bash

# Run OpenSearch
Expand All @@ -154,9 +154,9 @@ runs:
if: ${{ runner.os != 'Windows'}}
run: |
if [ "${{ inputs.security-enabled }}" == "true" ]; then
curl https://localhost:9200/_cat/plugins -u 'admin:${{ inputs.admin-password }}' -k -v --fail-with-body
curl https://localhost:${{ inputs.port || 9200 }}/_cat/plugins -u 'admin:${{ inputs.admin-password }}' -k -v --fail-with-body
else
curl http://localhost:9200/_cat/plugins -v
curl http://localhost:${{ inputs.port || 9200 }}/_cat/plugins -v
fi
shell: bash

Expand All @@ -168,10 +168,10 @@ runs:
$encodedCredentials = [Convert]::ToBase64String($credentialBytes)
$baseCredentials = "Basic $encodedCredentials"
$Headers = @{ Authorization = $baseCredentials }
$url = 'https://localhost:9200/_cat/plugins'
$url = 'https://localhost:${{ inputs.port || 9200 }}/_cat/plugins'
} else {
$Headers = @{ }
$url = 'http://localhost:9200/_cat/plugins'
$url = 'http://localhost:${{ inputs.port || 9200 }}/_cat/plugins'
}
Invoke-WebRequest -SkipCertificateCheck -Uri $url -Headers $Headers;
shell: pwsh
Expand Down

0 comments on commit 8ff0865

Please sign in to comment.