add script to download and extract latest grafana flight sql plugin (#4866)

pull/4871/head
Scott Anderson 2023-04-14 10:10:25 -06:00 committed by GitHub
parent 84cd778ebb
commit 7df5b6ef33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 16 deletions

View File

@ -51,31 +51,46 @@ Because Grafana Flight SQL Plugin is a custom plugin, you can't use it with Graf
For more information, see [Find and Use Plugins in the Grafana Cloud documentation](https://grafana.com/docs/grafana-cloud/fundamentals/find-and-use-plugins/)
{{% /warn %}}
## Create a custom plugins director
Create a **custom plugins directory** to store the Flight SQL plugin in and
navigate into the directory.
_The custom plugins directory can be anywhere in your filesystem that Grafana can access._
{{% code-callout "/custom/plugins/directory" %}}
```sh
mkdir -p /custom/plugins/directory/ && cd $_
```
{{% /code-callout %}}
## Download the Grafana Flight SQL plugin
Download the latest release from [influxdata/grafana-flightsql-datasource releases](https://github.com/influxdata/grafana-flightsql-datasource/releases).
Download the latest [Grafana Flight SQL plugin (influxdata/grafana-flightsql-datasource)](https://github.com/influxdata/grafana-flightsql-datasource/releases).
The following shell script downloads and extracts the latest Flight SQL plugin
source code into the the current working directory.
**Run the following inside your [custom plugin directory](#create-a-custom-plugins-directory):**
```sh
curl -s https://docs.influxdata.com/downloads/download-grafana-flightsql-plugin.sh | bash
```
{{< expand-wrapper >}}
{{% expand "View the script source code" %}}
```sh
{{% readfile "/static/downloads/download-grafana-flightsql-plugin.sh" %}}
```
{{% /expand %}}
{{< /expand-wrapper >}}
{{% warn %}}
The Grafana Flight SQL plugin is experimental and subject to change.
{{% /warn %}}
```sh
curl -L https://github.com/influxdata/grafana-flightsql-datasource/releases/download/v0.1.9/influxdata-flightsql-datasource-0.1.9.zip --output influxdata-flightsql-datasource.zip
```
<span id="custom-grafana-plugins-directory"></span>
## Extract the Flight SQL plugin
Extract the Flight SQL plugin archive to your Grafana **custom plugins directory**.
The custom plugins directory can be any filesystem location that Grafana can access.
{{% code-callout "/custom/plugins/directory" %}}
```sh
unzip influxdata-flightsql-datasource.zip -d /custom/plugins/directory/
```
{{% /code-callout %}}
## Install the Grafana Flight SQL plugin
Install the custom-built Flight SQL plugin in a local or Docker-based instance

View File

@ -79,6 +79,7 @@ exports.handler = (event, context, callback) => {
'.zip': true,
'.md5': true,
'.sha256': true,
'.sh':true,
};
// Remove index.html from path

View File

@ -0,0 +1 @@
{{ readFile (.Get 0) | safeHTML }}

View File

@ -0,0 +1,28 @@
#!/bin/bash
# Set repository information
REPO_OWNER="influxdata"
REPO_NAME="grafana-flightsql-datasource"
API_URL="https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases"
# Fetch all release information
ALL_RELEASES=$(curl -s $API_URL)
# Check if a valid release list is found
if [[ $ALL_RELEASES == *"Not Found"* ]]; then
echo "Releases not found for the $REPO_NAME repository."
exit 1
fi
# Extract the latest pre-release tag from the release information
LATEST_RELEASE_TAG=$(echo "$ALL_RELEASES" | grep -Eo '"tag_name": "[^"]*' | sed -E 's/"tag_name": "//' | head -n 1)
VERSION=$(echo "$LATEST_RELEASE_TAG" | sed 's/^v//')
if [[ -z "$LATEST_RELEASE_TAG" ]]; then
echo "No pre-release found for the $REPO_NAME repository."
exit 1
fi
echo "The latest release tag of $REPO_NAME is: $LATEST_RELEASE_TAG"
curl -L https://github.com/influxdata/grafana-flightsql-datasource/releases/download/$LATEST_RELEASE_TAG/influxdata-flightsql-datasource-$VERSION.zip --output influxdata-flightsql-datasource.zip
unzip influxdata-flightsql-datasource.zip -d .