-
Notifications
You must be signed in to change notification settings - Fork 1
add documentation for publishing schema via CDN #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jcolladokuri
wants to merge
8
commits into
main
Choose a base branch
from
jck/docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+136
−0
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ea2500c
add docs for publishing schema
jcolladokuri 8b8415d
expand publish schema instructions
jcolladokuri a483e7f
add more instructions on how to run scripts
jcolladokuri a28952e
add instructions on releasing new version of dsconfig
jcolladokuri 26fd479
Merge branch 'main' into jck/docs
jcolladokuri 071c740
update instructions
jcolladokuri 745357f
Merge branch 'main' into jck/docs
jcolladokuri d983568
Merge branch 'main' into jck/docs
jcolladokuri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| ## Setting up your files | ||
|
|
||
| #### Change 1 : Add `pkg/schema/dsconfig.json` | ||
|
|
||
| add the `dsconfig.json` file to the specified location. ( either manually authored / copy the already baselined ones from plugin-ui. | ||
|
|
||
| ```json | ||
| { | ||
| "$schema": "https://raw.githubusercontent.com/grafana/dsconfig/refs/heads/main/dsconfig/schema.json", | ||
| "schemaVersion": "v1", | ||
| "pluginType": "grafana-athena-datasource", | ||
| "pluginName": "Amazon Athena", | ||
| .... | ||
| } | ||
| ``` | ||
|
|
||
| #### Change 2: Install dependencies | ||
|
|
||
| If you have not already, run: | ||
|
|
||
| ``` | ||
| go get github.com/grafana/dsconfig/schema | ||
| ``` | ||
|
|
||
| #### Change 3: IF one does not exist yet, create a `pkg/schema/models/settings.go` | ||
|
|
||
| Use this file to define the go representation of your given datasource settings. | ||
|
|
||
| #### Change 4 : Add `pkg/schema/dsconfig_test.go` | ||
|
|
||
| ```go | ||
| package schema_test | ||
|
|
||
| import ( | ||
| _ "embed" | ||
| "testing" | ||
|
|
||
| "github.com/grafana/athena-datasource/pkg/athena/models" | ||
| "github.com/grafana/dsconfig/schema" | ||
| ) | ||
|
|
||
| //go:embed dsconfig.json | ||
| var configSchemaJSON []byte | ||
|
|
||
| //go:generate go test -run TestPlugin -generateArtifacts | ||
| func TestPlugin(t *testing.T) { | ||
| schema.RunPluginTests(t, schema.PluginUnderTest{ | ||
| ID: "grafana-athena-datasource", | ||
| ConfigSchemaJSON: configSchemaJSON, | ||
| SettingsJSONModel: models.AthenaDataSourceSettings{}, | ||
| SecureKeys: []string{"accessKey", "secretKey", "sessionToken", "proxyPassword"}, | ||
| }) | ||
| } | ||
| ``` | ||
|
|
||
| ### Change 5 : Add / Update `webpack.config.ts` in the root folder | ||
|
|
||
| Add/Update the `webpack.config.ts` in the root folder | ||
|
|
||
| ```ts | ||
| import { type Configuration } from "webpack"; | ||
| import { merge } from "webpack-merge"; | ||
| import CopyWebpackPlugin from "copy-webpack-plugin"; | ||
| import grafanaConfig, { type Env } from "./.config/webpack/webpack.config"; | ||
|
|
||
| const config = async (env: Env): Promise<Configuration> => { | ||
| const baseConfig = await grafanaConfig(env); | ||
| return merge(baseConfig, { | ||
| plugins: [ | ||
| new CopyWebpackPlugin({ | ||
| patterns: [ | ||
| { | ||
| from: "../pkg/schema/dsconfig.json", | ||
| to: "./schema/dsconfig.json", | ||
| noErrorOnMissing: true, | ||
| }, | ||
| { | ||
| from: "../pkg/schema/schema.gen.json", | ||
| to: "./schema/v0alpha1.json", | ||
| noErrorOnMissing: true, | ||
| }, | ||
| { | ||
| from: "../pkg/schema/settings.gen.json", | ||
| to: "./schema/v0alpha1/settings.json", | ||
| noErrorOnMissing: true, | ||
| }, | ||
| { | ||
| from: "../pkg/schema/settings.examples.gen.json", | ||
| to: "./schema/v0alpha1/settings.examples.json", | ||
| noErrorOnMissing: true, | ||
| }, | ||
| ], | ||
| }), | ||
| ], | ||
| }); | ||
| }; | ||
|
|
||
| export default config; | ||
| ``` | ||
|
|
||
| ### Change 6 : Update the package.json script | ||
|
|
||
| ```diff | ||
| - "build": "webpack -c ./.config/webpack/webpack.config.ts --env production", | ||
| + "build": "webpack -c ./webpack.config.ts --env production", | ||
| - "dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development", | ||
| + "dev": "webpack -w -c ./webpack.config.ts --env development", | ||
| ``` | ||
|
|
||
| ## File generation | ||
|
|
||
| 1. run `generate go test -run TestPlugin -generateArtifacts` this will generate all the necessary artifacts for the configuration schema | ||
|
|
||
| 2. To make sure everything looks right run the test that you created above under `dsconfig_test.go`. This will run tests and compare the config schema against the datasource's declared go types to make sure it matches. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simply
go test ./...also does the job.