From 3111757fc1cd4c28148db6ff8bb885ac45666924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20SZKIBA?= Date: Fri, 16 Aug 2024 16:37:15 +0200 Subject: [PATCH] refactor: 'tier' and 'product' properties are introduced instead of 'official' and 'cloud' properties --- CONTRIBUTING.md | 3 +- README.md | 326 +++++++++++++++++++++++++++++++++++++- cmd/legacy.go | 22 ++- cmd/load.go | 18 ++- docs/example.json | 304 +++++++++++++++++++++++++++++++++++ docs/example.yaml | 8 +- docs/legacy.yaml | 24 +-- docs/registry.md | 43 +++-- docs/registry.schema.json | 35 +++- docs/registry.schema.yaml | 79 +++++++-- registry.go | 4 +- registry_gen.go | 74 ++++++--- 12 files changed, 853 insertions(+), 87 deletions(-) create mode 100644 docs/example.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5a979ed..000615f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,6 +55,7 @@ go-jsonschema -p k6registry --only-models -o registry_gen.go docs/registry.schem The example registry can be found in [example.yaml] file, the documentation ([registry.md], [README.md]) must be updated after modification. ```bash +go run ./cmd/k6registry --lint docs/example.yaml > docs/example.json mdcode update docs/registry.md mdcode update README.md ``` @@ -147,5 +148,5 @@ Requires ## legacy - Convert legacy registry ```bash - go run ./cmd/k6registry . --legacy | yq '.[]|= pick(["module","description","official","cloud","imports","outputs","repo"])|sort_by(.module)' > ./docs/legacy.yaml + go run ./cmd/k6registry . --legacy | yq '.[]|= pick(["module","description","tier","product","imports","outputs","repo"])|sort_by(.module)' > ./docs/legacy.yaml ``` \ No newline at end of file diff --git a/README.md b/README.md index 74c052f..c8ba7e6 100644 --- a/README.md +++ b/README.md @@ -13,20 +13,20 @@ Check [k6 Extension Registry Concept](docs/registry.md) for information on desig description: Web-based metrics dashboard for k6 outputs: - dashboard - official: true + tier: official - module: github.com/grafana/xk6-sql description: Load test SQL Servers imports: - k6/x/sql - cloud: true - official: true + tier: official + product: ["cloud", "oss"] - module: github.com/grafana/xk6-disruptor description: Inject faults to test imports: - k6/x/disruptor - official: true + tier: official - module: github.com/szkiba/xk6-faker description: Generate random fake data @@ -34,6 +34,320 @@ Check [k6 Extension Registry Concept](docs/registry.md) for information on desig - k6/x/faker ``` +
+Example registry + +Registry generated from the source above. + +```json file=docs/example.json +[ + { + "description": "Web-based metrics dashboard for k6", + "module": "github.com/grafana/xk6-dashboard", + "outputs": [ + "dashboard" + ], + "product": [ + "oss" + ], + "repo": { + "description": "A k6 extension that makes k6 metrics available on a web-based dashboard.", + "homepage": "https://github.com/grafana/xk6-dashboard", + "license": "AGPL-3.0", + "name": "xk6-dashboard", + "owner": "grafana", + "public": true, + "stars": 320, + "topics": [ + "xk6", + "xk6-official", + "xk6-output-dashboard" + ], + "url": "https://github.com/grafana/xk6-dashboard", + "versions": [ + "v0.7.5", + "v0.7.4", + "v0.7.3", + "v0.7.3-alpha.1", + "v0.7.2", + "v0.7.1", + "v0.7.0", + "v0.7.0-apha.3", + "v0.7.0-alpha.5", + "v0.7.0-alpha.4", + "v0.7.0-alpha.3", + "v0.7.0-alpha.2", + "v0.7.0-alpha.1", + "v0.6.1", + "v0.6.0", + "v0.5.5", + "v0.5.4", + "v0.5.3", + "v0.5.2", + "v0.5.1", + "v0.5.0", + "v0.4.4", + "v0.4.3", + "v0.4.2", + "v0.4.1", + "v0.4.0", + "v0.3.2", + "v0.3.1", + "v0.3.0", + "v0.2.0", + "v0.1.3", + "v0.1.2", + "v0.1.1", + "v0.1.0" + ] + }, + "tier": "official" + }, + { + "description": "Load test SQL Servers", + "imports": [ + "k6/x/sql" + ], + "module": "github.com/grafana/xk6-sql", + "product": [ + "cloud", + "oss" + ], + "repo": { + "description": "k6 extension to load test RDBMSs (PostgreSQL, MySQL, MS SQL and SQLite3)", + "homepage": "https://github.com/grafana/xk6-sql", + "license": "Apache-2.0", + "name": "xk6-sql", + "owner": "grafana", + "public": true, + "stars": 102, + "topics": [ + "k6", + "sql", + "xk6" + ], + "url": "https://github.com/grafana/xk6-sql", + "versions": [ + "v0.4.0", + "v0.3.0", + "v0.2.1", + "v0.2.0", + "v0.1.1", + "v0.1.0", + "v0.0.1" + ] + }, + "tier": "official" + }, + { + "description": "Inject faults to test", + "imports": [ + "k6/x/disruptor" + ], + "module": "github.com/grafana/xk6-disruptor", + "product": [ + "oss" + ], + "repo": { + "description": "Extension for injecting faults into k6 tests", + "homepage": "https://k6.io/docs/javascript-api/xk6-disruptor/", + "license": "AGPL-3.0", + "name": "xk6-disruptor", + "owner": "grafana", + "public": true, + "stars": 87, + "topics": [ + "chaos-engineering", + "fault-injection", + "k6", + "testing", + "xk6" + ], + "url": "https://github.com/grafana/xk6-disruptor", + "versions": [ + "v0.3.11", + "v0.3.10", + "v0.3.9", + "v0.3.8", + "v0.3.7", + "v0.3.6", + "v0.3.5", + "v0.3.5-rc2", + "v0.3.5-rc1", + "v0.3.4", + "v0.3.3", + "v0.3.2", + "v0.3.1", + "v0.3.0", + "v0.2.1", + "v0.2.0", + "v0.1.3", + "v0.1.2", + "v0.1.1", + "v0.1.0" + ] + }, + "tier": "official" + }, + { + "description": "Generate random fake data", + "imports": [ + "k6/x/faker" + ], + "module": "github.com/szkiba/xk6-faker", + "product": [ + "oss" + ], + "repo": { + "description": "Random fake data generator for k6.", + "homepage": "http://ivan.szkiba.hu/xk6-faker/", + "license": "AGPL-3.0", + "name": "xk6-faker", + "owner": "szkiba", + "public": true, + "stars": 49, + "topics": [ + "xk6", + "xk6-javascript-k6-x-faker" + ], + "url": "https://github.com/szkiba/xk6-faker", + "versions": [ + "v0.3.0", + "v0.3.0-alpha.1", + "v0.2.2", + "v0.2.1", + "v0.2.0", + "v0.1.0" + ] + }, + "tier": "community" + }, + { + "description": "A modern load testing tool, using Go and JavaScript", + "module": "go.k6.io/k6", + "product": [ + "cloud", + "oss" + ], + "repo": { + "description": "A modern load testing tool, using Go and JavaScript - https://k6.io", + "homepage": "https://github.com/grafana/k6", + "license": "AGPL-3.0", + "name": "k6", + "owner": "grafana", + "public": true, + "stars": 24184, + "topics": [ + "es6", + "go", + "golang", + "hacktoberfest", + "javascript", + "load-generator", + "load-testing", + "performance" + ], + "url": "https://github.com/grafana/k6", + "versions": [ + "v0.53.0", + "v0.52.0", + "v0.51.0", + "v0.50.0", + "v0.49.0", + "v0.48.0", + "v0.47.0", + "v0.46.0", + "v0.45.1", + "v0.45.0", + "v0.44.1", + "v0.44.0", + "v0.43.1", + "v0.43.0", + "v0.42.0", + "v0.41.0", + "v0.40.0", + "v0.39.0", + "v0.38.3", + "v0.38.2", + "v0.38.1", + "v0.38.0", + "v0.37.0", + "v0.36.0", + "v0.35.0", + "v0.34.1", + "v0.34.0", + "v0.33.0", + "v0.32.0", + "v0.31.1", + "v0.31.0", + "v0.30.0", + "v0.29.0", + "v0.28.0", + "v0.27.1", + "v0.27.0", + "v0.26.2", + "v0.26.1", + "v0.26.0", + "v0.25.1", + "v0.25.0", + "v0.24.0", + "v0.23.1", + "v0.23.0", + "v0.22.1", + "v0.22.0", + "v0.21.1", + "v0.21.0", + "v0.20.0", + "v0.19.0", + "v0.18.2", + "v0.18.1", + "v0.18.0", + "v0.17.2", + "v0.17.1", + "v0.17.0", + "v0.16.0", + "v0.15.0", + "v0.14.0", + "v0.13.0", + "v0.12.2", + "v0.12.1", + "v0.11.0", + "v0.10.0", + "v0.9.3", + "v0.9.2", + "v0.9.1", + "v0.9.0", + "v0.8.5", + "v0.8.4", + "v0.8.3", + "v0.8.2", + "v0.8.1", + "v0.8.0", + "v0.7.0", + "v0.6.0", + "v0.5.2", + "v0.5.1", + "v0.5.0", + "v0.4.5", + "v0.4.4", + "v0.4.3", + "v0.4.2", + "v0.4.1", + "v0.4.0", + "v0.3.0", + "v0.2.1", + "v0.2.0", + "v0.0.2", + "v0.0.1" + ] + }, + "tier": "official" + } +] +``` + +
+ A [legacy extension registry](docs/legacy.yaml) converted to the new format is also a good example. ## Install @@ -82,11 +396,11 @@ changed | `true` if the output has changed compared to `ref`, otherwise `false` ```yaml - name: Generate registry in JSON format - uses: grafana/k6registry@v0.1.4 + uses: grafana/k6registry@v0.1.10 with: in: "registry.yaml" out: "registry.json" - filter: "." + lint: "true" ``` ## CLI diff --git a/cmd/legacy.go b/cmd/legacy.go index f4bc991..fb0c70e 100644 --- a/cmd/legacy.go +++ b/cmd/legacy.go @@ -57,12 +57,7 @@ func legacyConvert(ctx context.Context) error { ext.Module = strings.TrimPrefix(legacyExt.URL, "https://") ext.Description = legacyExt.Description - - for _, tier := range legacyExt.Tiers { - if strings.ToLower(tier) == "official" { - ext.Official = true - } - } + ext.Tier = legacyTierToTier(legacyExt.Tiers) for _, legacyType := range legacyExt.Type { typ := strings.ToLower(legacyType) @@ -105,6 +100,21 @@ func legacyConvert(ctx context.Context) error { return nil } +func legacyTierToTier(tiers []string) k6registry.Tier { + for _, tier := range tiers { + switch strings.ToLower(tier) { + case "official": + return k6registry.TierOfficial + case "partner": + return k6registry.TierPartner + default: + return "" + } + } + + return "" +} + func legacyPatch(ext *k6registry.Extension) { override, found := extOverrides[ext.Module] if !found { diff --git a/cmd/load.go b/cmd/load.go index 24650ba..04f6678 100644 --- a/cmd/load.go +++ b/cmd/load.go @@ -37,9 +37,25 @@ func load(ctx context.Context, in io.Reader, loose bool, lint bool) (interface{} } registry = append(registry, - k6registry.Extension{Module: k6Module, Description: k6Description, Cloud: true, Official: true}) + k6registry.Extension{ + Module: k6Module, + Description: k6Description, + Tier: k6registry.TierOfficial, + Product: []k6registry.Product{ + k6registry.ProductCloud, + k6registry.ProductOss, + }, + }) for idx, ext := range registry { + if len(ext.Tier) == 0 { + registry[idx].Tier = k6registry.TierCommunity + } + + if len(ext.Product) == 0 { + registry[idx].Product = append(registry[idx].Product, k6registry.ProductOss) + } + if ext.Repo != nil { continue } diff --git a/docs/example.json b/docs/example.json new file mode 100644 index 0000000..a28c545 --- /dev/null +++ b/docs/example.json @@ -0,0 +1,304 @@ +[ + { + "description": "Web-based metrics dashboard for k6", + "module": "github.com/grafana/xk6-dashboard", + "outputs": [ + "dashboard" + ], + "product": [ + "oss" + ], + "repo": { + "description": "A k6 extension that makes k6 metrics available on a web-based dashboard.", + "homepage": "https://github.com/grafana/xk6-dashboard", + "license": "AGPL-3.0", + "name": "xk6-dashboard", + "owner": "grafana", + "public": true, + "stars": 320, + "topics": [ + "xk6", + "xk6-official", + "xk6-output-dashboard" + ], + "url": "https://github.com/grafana/xk6-dashboard", + "versions": [ + "v0.7.5", + "v0.7.4", + "v0.7.3", + "v0.7.3-alpha.1", + "v0.7.2", + "v0.7.1", + "v0.7.0", + "v0.7.0-apha.3", + "v0.7.0-alpha.5", + "v0.7.0-alpha.4", + "v0.7.0-alpha.3", + "v0.7.0-alpha.2", + "v0.7.0-alpha.1", + "v0.6.1", + "v0.6.0", + "v0.5.5", + "v0.5.4", + "v0.5.3", + "v0.5.2", + "v0.5.1", + "v0.5.0", + "v0.4.4", + "v0.4.3", + "v0.4.2", + "v0.4.1", + "v0.4.0", + "v0.3.2", + "v0.3.1", + "v0.3.0", + "v0.2.0", + "v0.1.3", + "v0.1.2", + "v0.1.1", + "v0.1.0" + ] + }, + "tier": "official" + }, + { + "description": "Load test SQL Servers", + "imports": [ + "k6/x/sql" + ], + "module": "github.com/grafana/xk6-sql", + "product": [ + "cloud", + "oss" + ], + "repo": { + "description": "k6 extension to load test RDBMSs (PostgreSQL, MySQL, MS SQL and SQLite3)", + "homepage": "https://github.com/grafana/xk6-sql", + "license": "Apache-2.0", + "name": "xk6-sql", + "owner": "grafana", + "public": true, + "stars": 102, + "topics": [ + "k6", + "sql", + "xk6" + ], + "url": "https://github.com/grafana/xk6-sql", + "versions": [ + "v0.4.0", + "v0.3.0", + "v0.2.1", + "v0.2.0", + "v0.1.1", + "v0.1.0", + "v0.0.1" + ] + }, + "tier": "official" + }, + { + "description": "Inject faults to test", + "imports": [ + "k6/x/disruptor" + ], + "module": "github.com/grafana/xk6-disruptor", + "product": [ + "oss" + ], + "repo": { + "description": "Extension for injecting faults into k6 tests", + "homepage": "https://k6.io/docs/javascript-api/xk6-disruptor/", + "license": "AGPL-3.0", + "name": "xk6-disruptor", + "owner": "grafana", + "public": true, + "stars": 87, + "topics": [ + "chaos-engineering", + "fault-injection", + "k6", + "testing", + "xk6" + ], + "url": "https://github.com/grafana/xk6-disruptor", + "versions": [ + "v0.3.11", + "v0.3.10", + "v0.3.9", + "v0.3.8", + "v0.3.7", + "v0.3.6", + "v0.3.5", + "v0.3.5-rc2", + "v0.3.5-rc1", + "v0.3.4", + "v0.3.3", + "v0.3.2", + "v0.3.1", + "v0.3.0", + "v0.2.1", + "v0.2.0", + "v0.1.3", + "v0.1.2", + "v0.1.1", + "v0.1.0" + ] + }, + "tier": "official" + }, + { + "description": "Generate random fake data", + "imports": [ + "k6/x/faker" + ], + "module": "github.com/szkiba/xk6-faker", + "product": [ + "oss" + ], + "repo": { + "description": "Random fake data generator for k6.", + "homepage": "http://ivan.szkiba.hu/xk6-faker/", + "license": "AGPL-3.0", + "name": "xk6-faker", + "owner": "szkiba", + "public": true, + "stars": 49, + "topics": [ + "xk6", + "xk6-javascript-k6-x-faker" + ], + "url": "https://github.com/szkiba/xk6-faker", + "versions": [ + "v0.3.0", + "v0.3.0-alpha.1", + "v0.2.2", + "v0.2.1", + "v0.2.0", + "v0.1.0" + ] + }, + "tier": "community" + }, + { + "description": "A modern load testing tool, using Go and JavaScript", + "module": "go.k6.io/k6", + "product": [ + "cloud", + "oss" + ], + "repo": { + "description": "A modern load testing tool, using Go and JavaScript - https://k6.io", + "homepage": "https://github.com/grafana/k6", + "license": "AGPL-3.0", + "name": "k6", + "owner": "grafana", + "public": true, + "stars": 24184, + "topics": [ + "es6", + "go", + "golang", + "hacktoberfest", + "javascript", + "load-generator", + "load-testing", + "performance" + ], + "url": "https://github.com/grafana/k6", + "versions": [ + "v0.53.0", + "v0.52.0", + "v0.51.0", + "v0.50.0", + "v0.49.0", + "v0.48.0", + "v0.47.0", + "v0.46.0", + "v0.45.1", + "v0.45.0", + "v0.44.1", + "v0.44.0", + "v0.43.1", + "v0.43.0", + "v0.42.0", + "v0.41.0", + "v0.40.0", + "v0.39.0", + "v0.38.3", + "v0.38.2", + "v0.38.1", + "v0.38.0", + "v0.37.0", + "v0.36.0", + "v0.35.0", + "v0.34.1", + "v0.34.0", + "v0.33.0", + "v0.32.0", + "v0.31.1", + "v0.31.0", + "v0.30.0", + "v0.29.0", + "v0.28.0", + "v0.27.1", + "v0.27.0", + "v0.26.2", + "v0.26.1", + "v0.26.0", + "v0.25.1", + "v0.25.0", + "v0.24.0", + "v0.23.1", + "v0.23.0", + "v0.22.1", + "v0.22.0", + "v0.21.1", + "v0.21.0", + "v0.20.0", + "v0.19.0", + "v0.18.2", + "v0.18.1", + "v0.18.0", + "v0.17.2", + "v0.17.1", + "v0.17.0", + "v0.16.0", + "v0.15.0", + "v0.14.0", + "v0.13.0", + "v0.12.2", + "v0.12.1", + "v0.11.0", + "v0.10.0", + "v0.9.3", + "v0.9.2", + "v0.9.1", + "v0.9.0", + "v0.8.5", + "v0.8.4", + "v0.8.3", + "v0.8.2", + "v0.8.1", + "v0.8.0", + "v0.7.0", + "v0.6.0", + "v0.5.2", + "v0.5.1", + "v0.5.0", + "v0.4.5", + "v0.4.4", + "v0.4.3", + "v0.4.2", + "v0.4.1", + "v0.4.0", + "v0.3.0", + "v0.2.1", + "v0.2.0", + "v0.0.2", + "v0.0.1" + ] + }, + "tier": "official" + } +] diff --git a/docs/example.yaml b/docs/example.yaml index f13981a..71c5ddc 100644 --- a/docs/example.yaml +++ b/docs/example.yaml @@ -2,20 +2,20 @@ description: Web-based metrics dashboard for k6 outputs: - dashboard - official: true + tier: official - module: github.com/grafana/xk6-sql description: Load test SQL Servers imports: - k6/x/sql - cloud: true - official: true + tier: official + product: ["cloud", "oss"] - module: github.com/grafana/xk6-disruptor description: Inject faults to test imports: - k6/x/disruptor - official: true + tier: official - module: github.com/szkiba/xk6-faker description: Generate random fake data diff --git a/docs/legacy.yaml b/docs/legacy.yaml index 145ce91..2f0f82d 100644 --- a/docs/legacy.yaml +++ b/docs/legacy.yaml @@ -80,62 +80,62 @@ - k6/x/smtp - module: github.com/grafana/xk6-client-prometheus-remote description: Test Prometheus Remote Write performance - official: true + tier: official imports: - k6/x/remotewrite - module: github.com/grafana/xk6-client-tracing description: Client for load testing distributed tracing backends - official: true + tier: official imports: - k6/x/tracing - module: github.com/grafana/xk6-dashboard description: Create a web-based metrics dashboard - official: true + tier: official outputs: - dashboard - module: github.com/grafana/xk6-disruptor description: "Inject faults to test \U0001F4A3" - official: true + tier: official imports: - k6/x/disruptor - module: github.com/grafana/xk6-exec description: Run external commands - official: true + tier: official imports: - k6/x/exec - module: github.com/grafana/xk6-kubernetes description: Interact with Kubernetes clusters - official: true + tier: official imports: - k6/x/kubernetes - module: github.com/grafana/xk6-notification description: Create notifications - official: true + tier: official imports: - k6/x/notification - module: github.com/grafana/xk6-output-influxdb description: Export results to InfluxDB v2 - official: true + tier: official outputs: - xk6-influxdb - module: github.com/grafana/xk6-output-kafka description: Export k6 results in real-time to Kafka - official: true + tier: official outputs: - xk6-kafka - module: github.com/grafana/xk6-output-timescaledb description: Export k6 results to TimescaleDB - official: true + tier: official outputs: - timescaledb - module: github.com/grafana/xk6-sql description: Load-test SQL Servers (PostgreSQL, MySQL and SQLite3 for now) - official: true + tier: official imports: - k6/x/sql - module: github.com/grafana/xk6-ssh description: SSH - official: true + tier: official imports: - k6/x/ssh - module: github.com/grafana/xk6-ts diff --git a/docs/registry.md b/docs/registry.md index 35c4dce..88783aa 100644 --- a/docs/registry.md +++ b/docs/registry.md @@ -37,13 +37,34 @@ The JavaScript module names implemented by the extension can be specified in the The output names implemented by the extension can be specified in the `outputs` property. An extension can register multiple output names, so this is an array property. -### Cloud +### Tier -The `true` value of the `cloud` flag indicates that the extension is also available in the Grafana k6 cloud. The use of certain extensions is not supported in a cloud environment. There may be a technological reason for this, or the extension's functionality is meaningless in the cloud. +Extensions can be classified according to who maintains the extension. This usually also specifies who the user can get support from. -### Official +The `tier` property refers to the maintainer of the extension. -The `true` value of the `official` flag indicates that the extension is officially supported by Grafana. Extensions owned by the `grafana` GitHub organization are not officially supported by Grafana by default. There are several k6 extensions owned by the `grafana` GitHub organization, which were created for experimental or example purposes only. The `official` flag is needed so that officially supported extensions can be distinguished from them. +Possible values: + + - **official**: Extensions owned, maintained, and designated by Grafana as "official" + - **partner**: Extensions written, maintained, validated, and published by third-party companies against their own projects. + - **community**: Extensions are listed on the Registry by individual maintainers, groups of maintainers, or other members of the k6 community. + +Extensions owned by the `grafana` GitHub organization are not officially supported by Grafana by default. There are several k6 extensions owned by the `grafana` GitHub organization, which were created for experimental or example purposes only. The `official` tier value is needed so that officially supported extensions can be distinguished from them. + +If it is missing from the registry source, it will be set with the default `community` value during generation. + +### Product + +The `product` property contains the names of the k6 products in which the extension is available. + +Some extensions are not available in all k6 products. This may be for a technological or business reason, or the functionality of the extension may not make sense in the given product. + +Possible values: + + - **oss**: Extensions are available in *k6 OSS* + - **cloud**: Extensions are available in *Grafana Cloud k6* + +If the property is missing or empty in the source of the registry, it means that the extension is only available in the *k6 OSS* product. In this case, the registry will be filled in accordingly during generation. ### Example registry @@ -52,20 +73,20 @@ The `true` value of the `official` flag indicates that the extension is official description: Web-based metrics dashboard for k6 outputs: - dashboard - official: true + tier: official - module: github.com/grafana/xk6-sql description: Load test SQL Servers imports: - k6/x/sql - cloud: true - official: true + tier: official + product: ["cloud", "oss"] -- module: github.com/grafana/xk6-distruptor +- module: github.com/grafana/xk6-disruptor description: Inject faults to test imports: - - k6/x/distruptor - official: true + - k6/x/disruptor + tier: official - module: github.com/szkiba/xk6-faker description: Generate random fake data @@ -151,6 +172,4 @@ Custom linter checks the following for each extension: - Is the xk6 topic set for the repository? - Is the repository not archived? -Schema based validation is always done before processing. The noop filter ('.') can be used for validation only by ignoring (or muting) the output. - It is strongly recommended to lint the extension registry after each modification, but at least before approving the change. diff --git a/docs/registry.schema.json b/docs/registry.schema.json index 719fd2a..5264023 100644 --- a/docs/registry.schema.json +++ b/docs/registry.schema.json @@ -62,15 +62,17 @@ "$ref": "#/$defs/repository", "description": "Repository metadata.\n\nMetadata provided by the extension's git repository manager. Repository metadata are not registered, they are queried at runtime using the repository manager API.\n" }, - "official": { - "type": "boolean", - "default": "false", - "description": "Officially supported extension flag.\n\nThe `true` value of the `official` flag indicates that the extension is officially supported by Grafana.\n\nExtensions owned by the `grafana` GitHub organization are not officially supported by Grafana by default. There are several k6 extensions owned by the `grafana` GitHub organization, which were created for experimental or example purposes only. The `official` flag is needed so that officially supported extensions can be distinguished from them.\n" + "tier": { + "$ref": "#/$defs/tier", + "default": "community", + "description": "Maintainer of the extension.\n\nPossible values:\n\n - official: Extensions owned, maintained, and designated by Grafana as \"official\"\n - partner: Extensions written, maintained, validated, and published by third-party companies against their own projects.\n - community: Extensions are listed on the Registry by individual maintainers, groups of maintainers, or other members of the k6 community.\n\nExtensions owned by the `grafana` GitHub organization are not officially supported by Grafana by default.\nThere are several k6 extensions owned by the `grafana` GitHub organization, which were created for experimental or example purposes only.\nThe `official` tier value is needed so that officially supported extensions can be distinguished from them.\n" }, - "cloud": { - "type": "boolean", - "default": "false", - "description": "Cloud-enabled extension flag.\n\nThe `true` value of the `cloud` flag indicates that the extension is also available in the Grafana k6 cloud.\n\nThe use of certain extensions is not supported in a cloud environment. There may be a technological reason for this, or the extension's functionality is meaningless in the cloud.\n" + "product": { + "type": "array", + "items": { + "$ref": "#/$defs/product" + }, + "description": "Products in which the extension can be used.\n\nSome extensions are not available in all k6 products.\nThis may be for a technological or business reason, or the functionality of the extension may not make sense in the given product.\n\nPossible values:\n\n - oss: Extensions are available in k6 OSS\n - cloud: Extensions are available in Grafana Cloud k6\n\nIf the property is missing or empty in the source of the registry, it means that the extension is only available in the k6 OSS product.\nIn this case, the registry will be filled in accordingly during generation.\n" } }, "required": [ @@ -145,6 +147,23 @@ "description": "Archived repository flag.\n\nA `true` value indicates that the repository is archived, read only.\n\nIf a repository is archived, it usually means that the owner has no intention of maintaining it. Such extensions should be removed from the registry.\n" } } + }, + "tier": { + "type": "string", + "enum": [ + "official", + "partner", + "community" + ], + "description": "Maintainer of the extension.\n\nExtensions can be classified according to who maintains the extension.\nThis usually also specifies who the user can get support from.\n\nPossible values:\n\n - official: Extensions owned, maintained, and designated by Grafana as \"official\"\n - partner: Extensions written, maintained, validated, and published by third-party companies against their own projects.\n - community: Extensions are listed on the Registry by individual maintainers, groups of maintainers, or other members of the k6 community.\n\nExtensions owned by the `grafana` GitHub organization are not officially supported by Grafana by default.\nThere are several k6 extensions owned by the `grafana` GitHub organization, which were created for experimental or example purposes only.\nThe `official` tier value is needed so that officially supported extensions can be distinguished from them.\n" + }, + "product": { + "type": "string", + "enum": [ + "oss", + "cloud" + ], + "description": "Products in which the extension can be used.\n\nSome extensions are not available in all k6 products.\nThis may be for a technological or business reason, or the functionality of the extension may not make sense in the given product.\n\nPossible values:\n\n - oss: Extensions are available in k6 OSS\n - cloud: Extensions are available in Grafana Cloud k6\n\nIf the property is missing or empty in the source of the registry, it means that the extension is only available in the k6 OSS product.\nIn this case, the registry will be filled in accordingly during generation.\n" } } } diff --git a/docs/registry.schema.yaml b/docs/registry.schema.yaml index 085e59c..79efcc1 100644 --- a/docs/registry.schema.yaml +++ b/docs/registry.schema.yaml @@ -70,24 +70,42 @@ $defs: Repository metadata. Metadata provided by the extension's git repository manager. Repository metadata are not registered, they are queried at runtime using the repository manager API. - official: - type: boolean - default: "false" + tier: + $ref: "#/$defs/tier" + default: "community" description: | - Officially supported extension flag. + Maintainer of the extension. - The `true` value of the `official` flag indicates that the extension is officially supported by Grafana. + Possible values: - Extensions owned by the `grafana` GitHub organization are not officially supported by Grafana by default. There are several k6 extensions owned by the `grafana` GitHub organization, which were created for experimental or example purposes only. The `official` flag is needed so that officially supported extensions can be distinguished from them. - cloud: - type: boolean - default: "false" + - official: Extensions owned, maintained, and designated by Grafana as "official" + - partner: Extensions written, maintained, validated, and published by third-party companies against their own projects. + - community: Extensions are listed on the Registry by individual maintainers, groups of maintainers, or other members of the k6 community. + + Extensions owned by the `grafana` GitHub organization are not officially supported by Grafana by default. + There are several k6 extensions owned by the `grafana` GitHub organization, which were created for experimental or example purposes only. + The `official` tier value is needed so that officially supported extensions can be distinguished from them. + + If it is missing from the registry source, it will be set with the default "community" value during generation. + + product: + type: array + items: + $ref: "#/$defs/product" description: | - Cloud-enabled extension flag. + Products in which the extension can be used. + + Some extensions are not available in all k6 products. + This may be for a technological or business reason, or the functionality of the extension may not make sense in the given product. + + Possible values: + + - oss: Extensions are available in k6 OSS + - cloud: Extensions are available in Grafana Cloud k6 - The `true` value of the `cloud` flag indicates that the extension is also available in the Grafana k6 cloud. + If the property is missing or empty in the source of the registry, it means that the extension is only available in the k6 OSS product. + In this case, the registry will be filled in accordingly during generation. - The use of certain extensions is not supported in a cloud environment. There may be a technological reason for this, or the extension's functionality is meaningless in the cloud. required: - module - description @@ -175,3 +193,40 @@ $defs: A `true` value indicates that the repository is archived, read only. If a repository is archived, it usually means that the owner has no intention of maintaining it. Such extensions should be removed from the registry. + tier: + type: string + enum: ["official", "partner", "community"] + description: | + Maintainer of the extension. + + Extensions can be classified according to who maintains the extension. + This usually also specifies who the user can get support from. + + Possible values: + + - official: Extensions owned, maintained, and designated by Grafana as "official" + - partner: Extensions written, maintained, validated, and published by third-party companies against their own projects. + - community: Extensions are listed on the Registry by individual maintainers, groups of maintainers, or other members of the k6 community. + + Extensions owned by the `grafana` GitHub organization are not officially supported by Grafana by default. + There are several k6 extensions owned by the `grafana` GitHub organization, which were created for experimental or example purposes only. + The `official` tier value is needed so that officially supported extensions can be distinguished from them. + + If it is missing from the registry source, it will be set with the default "community" value during generation. + + product: + type: string + enum: ["oss", "cloud"] + description: | + Products in which the extension can be used. + + Some extensions are not available in all k6 products. + This may be for a technological or business reason, or the functionality of the extension may not make sense in the given product. + + Possible values: + + - oss: Extensions are available in k6 OSS + - cloud: Extensions are available in Grafana Cloud k6 + + If the property is missing or empty in the source of the registry, it means that the extension is only available in the k6 OSS product. + In this case, the registry will be filled in accordingly during generation. diff --git a/registry.go b/registry.go index f76656d..582773a 100644 --- a/registry.go +++ b/registry.go @@ -1,7 +1,9 @@ // Package k6registry contains the data model of the k6 extensions registry. package k6registry -import _ "embed" +import ( + _ "embed" +) // Schema contains JSON schema for registry JSON. // diff --git a/registry_gen.go b/registry_gen.go index 125a429..ef15ebd 100644 --- a/registry_gen.go +++ b/registry_gen.go @@ -16,17 +16,6 @@ package k6registry // documentation site without approval. Therefore, these properties are registered // (eg `description`) type Extension struct { - // Cloud-enabled extension flag. - // - // The `true` value of the `cloud` flag indicates that the extension is also - // available in the Grafana k6 cloud. - // - // The use of certain extensions is not supported in a cloud environment. There - // may be a technological reason for this, or the extension's functionality is - // meaningless in the cloud. - // - Cloud bool `json:"cloud,omitempty" yaml:"cloud,omitempty" mapstructure:"cloud,omitempty"` - // Brief description of the extension. // Description string `json:"description" yaml:"description" mapstructure:"description"` @@ -57,19 +46,6 @@ type Extension struct { // Module string `json:"module" yaml:"module" mapstructure:"module"` - // Officially supported extension flag. - // - // The `true` value of the `official` flag indicates that the extension is - // officially supported by Grafana. - // - // Extensions owned by the `grafana` GitHub organization are not officially - // supported by Grafana by default. There are several k6 extensions owned by the - // `grafana` GitHub organization, which were created for experimental or example - // purposes only. The `official` flag is needed so that officially supported - // extensions can be distinguished from them. - // - Official bool `json:"official,omitempty" yaml:"official,omitempty" mapstructure:"official,omitempty"` - // List of output names registered by the extension. // // The extensions used by k6 scripts are automatically detected based on the @@ -78,6 +54,24 @@ type Extension struct { // Outputs []string `json:"outputs,omitempty" yaml:"outputs,omitempty" mapstructure:"outputs,omitempty"` + // Products in which the extension can be used. + // + // Some extensions are not available in all k6 products. + // This may be for a technological or business reason, or the functionality of the + // extension may not make sense in the given product. + // + // Possible values: + // + // - oss: Extensions are available in k6 OSS + // - cloud: Extensions are available in Grafana Cloud k6 + // + // If the property is missing or empty in the source of the registry, it means + // that the extension is only available in the k6 OSS product. + // In this case, the registry will be filled in accordingly during generation. + // + // + Product []Product `json:"product,omitempty" yaml:"product,omitempty" mapstructure:"product,omitempty"` + // Repository metadata. // // Metadata provided by the extension's git repository manager. Repository @@ -85,8 +79,34 @@ type Extension struct { // manager API. // Repo *Repository `json:"repo,omitempty" yaml:"repo,omitempty" mapstructure:"repo,omitempty"` + + // Maintainer of the extension. + // + // Possible values: + // + // - official: Extensions owned, maintained, and designated by Grafana as + // "official" + // - partner: Extensions written, maintained, validated, and published by + // third-party companies against their own projects. + // - community: Extensions are listed on the Registry by individual maintainers, + // groups of maintainers, or other members of the k6 community. + // + // Extensions owned by the `grafana` GitHub organization are not officially + // supported by Grafana by default. + // There are several k6 extensions owned by the `grafana` GitHub organization, + // which were created for experimental or example purposes only. + // The `official` tier value is needed so that officially supported extensions can + // be distinguished from them. + // + // + Tier Tier `json:"tier,omitempty" yaml:"tier,omitempty" mapstructure:"tier,omitempty"` } +type Product string + +const ProductCloud Product = "cloud" +const ProductOss Product = "oss" + // k6 Extension Registry. // // The k6 extension registry contains the most important properties of registered @@ -167,3 +187,9 @@ type Repository struct { // Versions []string `json:"versions,omitempty" yaml:"versions,omitempty" mapstructure:"versions,omitempty"` } + +type Tier string + +const TierCommunity Tier = "community" +const TierOfficial Tier = "official" +const TierPartner Tier = "partner"