Skip to content

Commit 2172fb5

Browse files
Merge pull request #3 from NeedleInAJayStack/feature/deployment
Deployment script for private distribution
2 parents 8c5e0f2 + 8461fcc commit 2172fb5

4 files changed

Lines changed: 94 additions & 4 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ e2e-results/
3333

3434
.eslintcache
3535
pkg/.env
36+
37+
# Private plugin releases
38+
release/

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ This is a [Grafana](https://grafana.com/grafana/) plugin that supports direct co
55
and supports standard Haystack API operations as well as custom Axon execution, which is supported by
66
[SkySpark](https://skyfoundry.com/product) and [Haxall](https://haxall.io/).
77

8+
## Installation
9+
10+
Long term, the goal is to get this into the Grafana plugin repository. Until then, I must manually sign the plugin
11+
for your particular Grafana URL. If interested, please contact me at NeedleInAJayStack@protonmail.com.
12+
813
## Usage
914

1015
To use this package, you should already have a working Grafana server. For instructions on how to install and configure
@@ -19,5 +24,7 @@ Contributions are very welcome! For details on how to develop this plugin, see t
1924

2025
## Continuing Work
2126

27+
* [ ] Check variable support
28+
* [ ] Add alert support
2229
* [ ] Publish plugin
2330
* [ ] Consider enabling multi-point hisRead (through filters)

package.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#! /bin/bash
2+
3+
# This creates a deploy-able plugin zip file in the release directory.
4+
#
5+
# Installation instructions:
6+
# 1. Determine the Grafana server URL. This may not be the public URL, and are defined in the `server` section
7+
# of the Settings page or grafana.ini file. For example, the server URL may be http://localhost:3000.
8+
# 2. Run this script with the server URL.
9+
# 3. Copy the zip file to the machine hosting grafana and unzip into the grafana plugins directory
10+
# (/var/lib/grafana/plugins on linux).
11+
# 4. Restart grafana.
12+
13+
set -eo pipefail
14+
15+
usage() {
16+
cat << EOF
17+
Usage: $0 -u [root_urls] -k [api_key]
18+
19+
Packages the project as a "private" plugin so it may be used on a grafana server.
20+
The end result is a zip file in the 'release' directory containing the plugin.
21+
22+
Unfortunately, only NeedleInAJayStack can run this since the API key cloud account must match the datasource name.
23+
This is a workaround until the package is approved as a "public" plugin by Grafana.
24+
25+
-u root_urls: Comma separated list of root urls for the grafana server.
26+
-k api_key: API key for the grafana server.
27+
EOF
28+
exit 1
29+
}
30+
31+
# This follows the gitlab release.yml file.
32+
main() {
33+
export GRAFANA_API_KEY=${api_key}
34+
35+
# Install dependencies
36+
yarn install --immutable --prefer-offline
37+
38+
# Build and test frontend
39+
yarn build
40+
41+
# Test backend
42+
mage coverage
43+
44+
# Build backend
45+
mage buildAll
46+
47+
# Sign plugin
48+
npx --yes @grafana/sign-plugin --rootUrls ${rootUrls}
49+
50+
# Get plugin metadata
51+
plugin_id=$(cat dist/plugin.json | jq -r .id)
52+
archive=${plugin_id}.zip
53+
54+
# Package plugin
55+
mv -f dist ${plugin_id}
56+
57+
if [ ! -d "release" ]; then
58+
mkdir release
59+
fi
60+
zip release/${archive} ${plugin_id} -r
61+
62+
# Cleanup
63+
rm -r ${plugin_id}
64+
}
65+
66+
while getopts ":k:u:" option; do
67+
case "$option" in
68+
k)
69+
readonly api_key=${OPTARG}
70+
;;
71+
u)
72+
readonly rootUrls=${OPTARG}
73+
;;
74+
*)
75+
usage
76+
;;
77+
esac
78+
done
79+
80+
if [ -z "${rootUrls}" ] || [ -z "${api_key}" ]; then
81+
usage
82+
fi
83+
84+
main

src/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ and supports standard Haystack API operations as well as custom Axon execution,
99

1010
## Usage
1111

12-
### Installation
13-
14-
TODO
15-
1612
### Create a Data Source
1713

1814
To create a new data source, select `Data Sources` from the Configuration menu represented by the gear icon on the left

0 commit comments

Comments
 (0)