diff --git a/README.md b/README.md index 66f446f..b455067 100644 --- a/README.md +++ b/README.md @@ -135,3 +135,22 @@ the full field vocabulary. Licensed under the terms of the [LICENSE](./LICENSE) file in this repository. + +# Releasing a new dsconfig SDK version + +Go to https://github.com/grafana/dsconfig/tags to verify the latest version that has been published. + + +From the root folder: + +Pull the latest changes into your local main branch + +`git checkout main && git pull` + +Bump the version you saw above + +`git tag dsconfig/v && git tag schema/v` + +Then push the tags: + +`git push --tags` diff --git a/dsconfig/PUBLISH-SCHEMA.md b/dsconfig/PUBLISH-SCHEMA.md new file mode 100644 index 0000000..67cee8e --- /dev/null +++ b/dsconfig/PUBLISH-SCHEMA.md @@ -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 => { + 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. diff --git a/dsconfig/README.md b/dsconfig/README.md index d2595de..b5e60b5 100644 --- a/dsconfig/README.md +++ b/dsconfig/README.md @@ -696,3 +696,6 @@ Virtual fields are not stored. They derive a value from other fields for UI logi | 5 | How should `secureJsonFields` (read-side boolean map) be modeled in the schema or SDK output? | | 6 | Should validation rule evaluation order, short-circuit behavior, or severity levels be defined? | | 7 | Should groups enforce completeness? (every field must belong to at least one group) | + + +Once done generating your datasource's `dsconfig.json`, go to [PUBLISH-SCHEMA.md](PUBLISH-SCHEMA.md) \ No newline at end of file