Skip to content

Commit

Permalink
Factorize login logic
Browse files Browse the repository at this point in the history
Signed-off-by: Antoine THEBAUD <[email protected]>
  • Loading branch information
Antoine THEBAUD committed Dec 9, 2024
1 parent b303ca3 commit ff5c136
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 30 deletions.
20 changes: 10 additions & 10 deletions actions/apply_resources/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ runs:
using: composite
steps:
- name: Login to the Perses API
run: |
percli login ${{ inputs.url }} \
$([[ -n "${{ inputs.username }}" ]] && echo "-u ${{ inputs.username }}") \
$([[ -n "${{ inputs.password }}" ]] && echo "-p ${{ inputs.password }}") \
$([[ -n "${{ inputs.token }}" ]] && echo "--token ${{ inputs.token }}") \
$([[ -n "${{ inputs.provider }}" ]] && echo "--provider ${{ inputs.provider }}") \
$([[ -n "${{ inputs.client-id }}" ]] && echo "--client-id ${{ inputs.client-id }}") \
$([[ -n "${{ inputs.client-secret }}" ]] && echo "--client-secret ${{ inputs.client-secret }}") \
$([[ "${{ inputs.insecure-skip-tls-verify}}" == "true" ]] && echo "--insecure-skip-tls-verify")
shell: bash
uses: ./actions/login
with:
url: ${{ inputs.url }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
token: ${{ inputs.token }}
provider: ${{ inputs.provider }}
client-id: ${{ inputs.client-id }}
client-secret: ${{ inputs.client-secret }}
insecure-skip-tls-verify: ${{ inputs.insecure-skip-tls-verify }}

- name: Run the `apply` command
run: |
Expand Down
20 changes: 10 additions & 10 deletions actions/diff_dashboards/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ runs:
using: composite
steps:
- name: Login to the Perses API
run: |
percli login ${{ inputs.url }} \
$([[ -n "${{ inputs.username }}" ]] && echo "-u ${{ inputs.username }}") \
$([[ -n "${{ inputs.password }}" ]] && echo "-p ${{ inputs.password }}") \
$([[ -n "${{ inputs.token }}" ]] && echo "--token ${{ inputs.token }}") \
$([[ -n "${{ inputs.provider }}" ]] && echo "--provider ${{ inputs.provider }}") \
$([[ -n "${{ inputs.client-id }}" ]] && echo "--client-id ${{ inputs.client-id }}") \
$([[ -n "${{ inputs.client-secret }}" ]] && echo "--client-secret ${{ inputs.client-secret }}") \
$([[ "${{ inputs.insecure-skip-tls-verify}}" == "true" ]] && echo "--insecure-skip-tls-verify")
shell: bash
uses: ./actions/login
with:
url: ${{ inputs.url }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
token: ${{ inputs.token }}
provider: ${{ inputs.provider }}
client-id: ${{ inputs.client-id }}
client-secret: ${{ inputs.client-secret }}
insecure-skip-tls-verify: ${{ inputs.insecure-skip-tls-verify }}

- name: Run the `dac diff` command
run: |
Expand Down
47 changes: 47 additions & 0 deletions actions/login/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Login to Perses
description: Run the `login` command of percli to authenticate to the API server
inputs:
url:
description: The URL of the Perses API server where to deploy the dashboard preview.
required: true
directory:
description: Path to the directory containing the resources consumed by the command (mutually exclusive with `file`).
required: false
file:
description: Path to the file that contains the resources consumed by the command (mutually exclusive with `directory`).
required: false
username:
description: Username for basic authentication to the API server.
required: false
password:
description: Password for basic authentication to the API server.
required: false
token:
description: Bearer token for authentication to the API server.
required: false
provider:
description: External authentication provider identifier. (slug_id)
required: false
client-id:
description: Client ID used for robotic access when using external authentication provider.
required: false
client-secret:
description: Client Secret used for robotic access when using external authentication provider.
required: false
insecure-skip-tls-verify:
description: If true the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
required: false
runs:
using: composite
steps:
- name: Login to the Perses API
run: |
percli login ${{ inputs.url }} \
$([[ -n "${{ inputs.username }}" ]] && echo "-u ${{ inputs.username }}") \
$([[ -n "${{ inputs.password }}" ]] && echo "-p ${{ inputs.password }}") \
$([[ -n "${{ inputs.token }}" ]] && echo "--token ${{ inputs.token }}") \
$([[ -n "${{ inputs.provider }}" ]] && echo "--provider ${{ inputs.provider }}") \
$([[ -n "${{ inputs.client-id }}" ]] && echo "--client-id ${{ inputs.client-id }}") \
$([[ -n "${{ inputs.client-secret }}" ]] && echo "--client-secret ${{ inputs.client-secret }}") \
$([[ "${{ inputs.insecure-skip-tls-verify}}" == "true" ]] && echo "--insecure-skip-tls-verify")
shell: bash
20 changes: 10 additions & 10 deletions actions/preview_dashboards/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ runs:
using: composite
steps:
- name: Login to the Perses API
run: |
percli login ${{ inputs.url }} \
$([[ -n "${{ inputs.username }}" ]] && echo "-u ${{ inputs.username }}") \
$([[ -n "${{ inputs.password }}" ]] && echo "-p ${{ inputs.password }}") \
$([[ -n "${{ inputs.token }}" ]] && echo "--token ${{ inputs.token }}") \
$([[ -n "${{ inputs.provider }}" ]] && echo "--provider ${{ inputs.provider }}") \
$([[ -n "${{ inputs.client-id }}" ]] && echo "--client-id ${{ inputs.client-id }}") \
$([[ -n "${{ inputs.client-secret }}" ]] && echo "--client-secret ${{ inputs.client-secret }}") \
$([[ "${{ inputs.insecure-skip-tls-verify}}" == "true" ]] && echo "--insecure-skip-tls-verify")
shell: bash
uses: ./actions/login
with:
url: ${{ inputs.url }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
token: ${{ inputs.token }}
provider: ${{ inputs.provider }}
client-id: ${{ inputs.client-id }}
client-secret: ${{ inputs.client-secret }}
insecure-skip-tls-verify: ${{ inputs.insecure-skip-tls-verify }}

- name: Run the `dac preview` command
run: |
Expand Down

0 comments on commit ff5c136

Please sign in to comment.