Skip to content

Commit

Permalink
docs: add provisioning example (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
fr-ser authored Aug 13, 2024
2 parents f91c038 + 799431b commit 9e68fd5
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 39 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ name: code
on:
push:
branches:
- "**"
- '**'

jobs:
test-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.19
- name: Install go dependencies
Expand All @@ -21,9 +21,9 @@ jobs:
test-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16.20.x
cache: npm
Expand All @@ -34,17 +34,17 @@ jobs:
build-plugin-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.19
- name: Install go dependencies
run: make install-go-dependencies
- name: build all versions
run: make build-backend-all
- name: Upload linux binaries
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: plugin-executables
path: ./dist/
Expand All @@ -55,21 +55,21 @@ jobs:
- test-frontend
- build-plugin-backend
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16.20.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Download plugin backend
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: plugin-executables
path: ./dist/
Expand All @@ -81,19 +81,19 @@ jobs:
run: make test-e2e-no-build
- name: Debug Logs
if: ${{ failure() }}
run: docker-compose logs grafana
run: docker compose logs grafana
verify-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "lts/*"
node-version: 'lts/*'
cache: 'npm'
- name: Install dependencies
run: >
Expand All @@ -117,14 +117,14 @@ jobs:
- test-frontend
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "lts/*"
node-version: 'lts/*'
cache: 'npm'
- name: Install dependencies
run: >
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
create-artifacts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get metadata about the plugin
id: metadata
run: |
Expand All @@ -28,7 +28,7 @@ jobs:
exit 1
fi
- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16.20.x
cache: npm
Expand All @@ -38,7 +38,7 @@ jobs:
run: |
make build-frontend
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.19
- name: Install go dependencies
Expand All @@ -59,7 +59,7 @@ jobs:
# "error: It is not permitted to access the file system.""
# -sourceCodeUri file:///the_app /the_app/${{ steps.metadata.outputs.archive }}
- name: Upload plugin package
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: plugin-package
path: ${{ steps.metadata.outputs.archive }}
Expand All @@ -69,9 +69,9 @@ jobs:
needs:
- create-artifacts
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand All @@ -83,18 +83,18 @@ jobs:
echo "version=${PLUGIN_VERSION}" >> $GITHUB_OUTPUT
echo "archive=${PLUGIN_ARTIFACT}" >> $GITHUB_OUTPUT
- name: Download plugin package
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: plugin-package
path: ./
- name: unzip plugin
run: unzip ${{ steps.metadata.outputs.archive }} && mv frser-sqlite-datasource dist
- name: update Grafana config to production values
run: |
run: |
sed -i 's/allow_loading_unsigned_plugins = true//g' grafana_config/grafana.ini
sed -i 's/app_mode = development/app_mode = production/g' grafana_config/grafana.ini
sed -i 's/app_mode = development/app_mode = production/g' grafana_config/grafana.ini
- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16.20.x
cache: npm
Expand All @@ -106,13 +106,13 @@ jobs:
run: make test-e2e-no-build
- name: Debug Logs
if: ${{ failure() }}
run: docker-compose logs grafana
run: docker compose logs grafana
create-release:
runs-on: ubuntu-latest
needs:
- test-selenium-release-linux
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get metadata about the plugin
id: metadata
run: |
Expand All @@ -121,7 +121,7 @@ jobs:
echo "version=${PLUGIN_VERSION}" >> $GITHUB_OUTPUT
echo "archive=${PLUGIN_ARTIFACT}" >> $GITHUB_OUTPUT
- name: Download plugin package
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: plugin-package
path: ./
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ get an overview of the available commands.

- nodejs
- go
- docker and docker-compose
- docker and docker compose
- make

### (First Time) Installation
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ install-dependencies: install-go-dependencies install-js-dependencies

#: Teardown and start a local Grafana instance
start: teardown
docker-compose up -d grafana
docker compose up -d grafana
@echo "Go to http://localhost:3000/"

#: Teardown the docker resources
teardown:
docker-compose down --remove-orphans --volumes --timeout=2
docker compose down --remove-orphans --volumes --timeout=2

#: Build the backend for the local architecture
build-backend-local:
Expand Down Expand Up @@ -94,11 +94,11 @@ test-e2e: build-backend-docker build-frontend test-e2e-no-build
#: Run the end-to-end tests with Selenium without building the backend for docker. This can be helpful if the packages have already been built and signed
test-e2e-no-build:
@echo
@docker-compose rm --force --stop -v grafana
GRAFANA_VERSION=7.3.3 docker-compose run --rm start-setup
@docker compose rm --force --stop -v grafana
GRAFANA_VERSION=7.3.3 docker compose run --rm start-setup
npx jest --runInBand --testMatch '<rootDir>/selenium/**/*.test.{js,ts}'
@echo
GRAFANA_VERSION=8.1.0 docker-compose run --rm start-setup
GRAFANA_VERSION=8.1.0 docker compose run --rm start-setup
npx jest --runInBand --testMatch '<rootDir>/selenium/**/*.test.{js,ts}'
@echo

Expand Down
21 changes: 21 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,24 @@ It can be useful to run the plugin to connect to an SQLite database on the Grafa

The current ["Grafana Agent"](https://grafana.com/docs/agent/latest/) that is installed on a local machine is only about collecting logs and traces.
No plugins are executed with the agent, which makes it not relevant for this plugin.

## Can I use provisioning with this plugin

Any (backend) plugin supports provisioning; this one included.
The main question is which values to use.
The values can be derived by looking at the configuration of the plugin here:
<https://github.com/fr-ser/grafana-sqlite-datasource/blob/main/src/types.ts>.

An example provisioning file would look like this:

```yaml
apiVersion: 1
datasources:
- name: sqlite
type: frser-sqlite-datasource
access: proxy
isDefault: true
editable: true
jsonData:
path: /app/data.db
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"lint:fix": "npm run lint --fix",
"e2e": "npm exec cypress install && npm exec grafana-e2e run",
"e2e:update": "npm exec cypress install && npm exec grafana-e2e run --update-screenshots",
"server": "docker-compose up --build",
"server": "docker compose up --build",
"sign": "npx --yes @grafana/sign-plugin@latest"
}
}

0 comments on commit 9e68fd5

Please sign in to comment.