From 8ff0865d993ba02ad5cb710a4e987cbd9ba8a78a Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Thu, 14 Mar 2024 17:51:46 -0400 Subject: [PATCH] Allow port flexibility (#4) Signed-off-by: Derek Ho --- .github/workflows/test.yml | 19 +++++++++++++++++++ action.yml | 16 ++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 69dcf4c..8fb1a51 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/action.yml b/action.yml index c8b3da6..b700f4a 100644 --- a/action.yml +++ b/action.yml @@ -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: @@ -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 @@ -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 @@ -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