Skip to content

Commit 71e2172

Browse files
authored
Merge pull request #85 from grafana/update-k6registry
Update k6registry v0.3.0
2 parents 2fbdbf6 + 2d1be34 commit 71e2172

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3554
-1832
lines changed

.github/workflows/watch.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ jobs:
6464
uses: grafana/k6-extension-actions/[email protected]
6565

6666
- name: Setup k6registry
67-
uses: grafana/k6-extension-actions/[email protected]
68-
with:
69-
k6registry-version: v0.2.6
67+
run: >
68+
go install github.com/grafana/k6registry/cmd/[email protected]
69+
70+
- name: Setup gomplate
71+
uses: jason-dour/action-setup-gomplate@81b9ca6f49d6594a118d19f0d05f6fd05372e64c # v1.1.0
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7074

7175
- name: Run k6registry
7276
id: generate
@@ -75,12 +79,10 @@ jobs:
7579
run: >
7680
k6registry -v
7781
--lint
78-
--api "${HTDOCS_DIR}"
7982
--ref "${BASE_URL}/registry.json"
80-
--test /registry.json,/catalog.json,/product/oss.json,/product/oss-catalog.json
81-
--test /tier/official.json,/tier/official-catalog.json,/tier/community.json,/tier/community-catalog.json
82-
--test /tier/at-least/official.json,/tier/at-least/official-catalog.json,/tier/at-least/partner.json,/tier/at-least/partner-catalog.json
83-
registry.yaml
83+
registry.yaml --out "${HTDOCS_DIR}/registry.json"
84+
85+
./generate-api-files.sh -b "${HTDOCS_DIR}"
8486
8587
- name: Cache Clean
8688
if: ${{ ( github.ref_name == 'main' && steps.generate.outputs.changed == 'true' ) || inputs.force_changed }}

CONTRIBUTING.md

Lines changed: 67 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,16 @@ Before you begin, make sure to familiarize yourself with the [Code of Conduct](C
99
## Contributing to the registry
1010

1111
> [!IMPORTANT]
12-
> Before registering a new extension, please read the [Registry Requirements](https://grafana.com/docs/k6/latest/extensions/explanations/extensions-registry/#registry-requirements).
12+
> Before registering a new extension, please read the [Registry Requirements](https://grafana.com/docs/k6/latest/extensions/create/extensions-registry/).
1313
1414
The source of the registry can be found in the [registry.yaml] file. To register an extension, simply add a new entry to the end of the file. The data of the already registered extension can be modified accordingly.
1515

1616
After modifying the [registry.yaml], it is advisable to [run the linter](#lint---run-the-linter).
1717

18-
[registry.yaml]: registry.yaml
18+
The schema for the registry [registry.schema.json] file.
1919

20-
## Contribute to the JSON schema
21-
22-
The source of the JSON schema can be found in the [registry.schema.yaml] file. After the modification, the [schema should be converted](#schema---convert-the-schema-to-json) to JSON format and saved in the [registry.schema.json] file.
23-
24-
[registry.schema.yaml]: registry.schema.yaml
25-
[registry.schema.json]: registry.schema.json
20+
> [!IMPORTANT]
21+
> The schema is maintained in [k6registry](https://github.com/grafana/k6registry) it is copied here for convenience but any change in the schema must be done in k6registry's repository.
2622
2723
## Tasks
2824

@@ -33,7 +29,6 @@ The following sections describe the typical tasks of contributing. As long as th
3329
Contributing will require the use of some tools, which can be installed most easily with a well-configured [eget] tool.
3430

3531
```bash
36-
eget mikefarah/yq
3732
eget grafana/k6registry
3833
eget hairyhenderson/gomplate
3934
pip install json-schema-for-humans
@@ -52,14 +47,6 @@ k6registry -q --lint registry.yaml
5247
[lint]: #lint---run-the-linter
5348
[k6registry]: https://github.com/grafana/k6registry
5449

55-
### schema - Convert the schema to JSON
56-
57-
The source of the JSON schema is [registry.schema.yaml], after its modification, the schema should be converted into JSON format and saved in [registry.schema.json].
58-
59-
```bash
60-
yq -o=json -P registry.schema.yaml > registry.schema.json
61-
```
62-
6350
### public - Generate static documentation
6451

6552
```bash
@@ -68,12 +55,74 @@ generate-schema-doc --config with_footer=false --config collapse_long_descriptio
6855
mv public/schema/registry.schema.html public/schema/index.html
6956
```
7057

58+
### wiki - Generate API files
59+
60+
The registry is exposed using and API defined in [openapi.yaml]. This API is served using static files generated from the registry using the [generate-api-files.sh] script. The script takes the registry.json generated from [registry.yaml] using `k6registry` as input to generate the json file to be returned by each endpoint. It also generates a metrics.txt file with metrics for the extensions by tier, grade, and issues found.
61+
62+
```bash
63+
BUILD_DIR=build
64+
k6registry registry.yaml > ${BUILD_DIR}/registry.json
65+
./generate-api-files.sh -b ${BUILD_DIR}
66+
```
67+
68+
Generates the following files
69+
70+
```ascii
71+
build/
72+
├── catalog.json
73+
├── metrics.json
74+
├── metrics.txt
75+
├── registry.json
76+
├── grade
77+
│ ├── A.json
78+
│ ├── B.json
79+
│ ├── C.json
80+
│ ├── D.json
81+
│ ├── E.json
82+
│ └── F.json
83+
├── module
84+
│ ├── github.com
85+
│ │ └── grafana
86+
│ │ ├── xk6-dashboard
87+
│ │ │ ├── badge.svg
88+
│ │ │ ├── extension.json
89+
│ │ │ └── grade.svg
90+
│ │ ├── xk6-disruptor
91+
│ │ │ ├── badge.svg
92+
│ │ │ ├── extension.json
93+
│ │ │ └── grade.svg
94+
│ │ ├── xk6-faker
95+
│ │ │ ├── badge.svg
96+
│ │ │ ├── extension.json
97+
│ │ │ └── grade.svg
98+
│ │ └── xk6-sql
99+
│ │ ├── badge.svg
100+
│ │ ├── extension.json
101+
│ │ └── grade.svg
102+
│ ├── gitlab.com
103+
│ │ └── szkiba
104+
│ │ └── xk6-banner
105+
│ │ ├── badge.svg
106+
│ │ ├── extension.json
107+
│ │ └── grade.svg
108+
│ └── go.k6.io
109+
│ └── k6
110+
│ └── extension.json
111+
└── tier
112+
├── community-catalog.json
113+
├── community.json
114+
├── community-metrics.json
115+
├── official-catalog.json
116+
├── official.json
117+
└── official-metrics.json
118+
```
119+
71120
### wiki - Generate wiki pages
72121

73122
```bash
74123
export BASE_URL=https://registry.k6.io
75124
curl -s -o build/registry.json $BASE_URL/registry.json
76125
curl -s -o build/metrics.json $BASE_URL/metrics.json
77126
curl -s -o build/official-metrics.json $BASE_URL/tier/official-metrics.json
78-
gomplate -c registry=build/registry.json -c metrics=build/metrics.json -c official_metrics=build/official-metrics.json -c schema=registry.schema.json --input-dir wiki --output-map='build/wiki/{{.in|strings.TrimSuffix ".tpl"}}'
127+
gomplate -c registry=build/registry.json -c metrics=build/metrics.json -c official_metrics=build/tier/official-metrics.json -c schema=registry.schema.json --input-dir wiki --output-map='build/wiki/{{.in|strings.TrimSuffix ".tpl"}}'
79128
```

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,6 @@ Refers to the maintainer of the extension. **Optional, defaults to `community`**
6363

6464
Extensions owned by the `grafana` GitHub organization are not officially supported by Grafana by default.
6565

66-
### `products`
67-
68-
Products in which the extension can be used. **Optional, defaults to `["oss"]`**
69-
70-
### `categories`
71-
72-
The categories to which the extension belongs. **Optional, defaults to `["misc"]`**
73-
7466
### `versions`
7567

7668
List of supported versions. **Optional, the default is to query the repository manager API**

api/grade-badge.svg.tpl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- $colors := dict
2+
"A" "#4c1"
3+
"B" "#97ca00"
4+
"C" "#a4a61d"
5+
"D" "#dfb317"
6+
"E" "#fe7d37"
7+
"F" "#e05d44"
8+
"G" "#007ec6"
9+
-}}
10+
{{- $grade := getenv "GRADE" -}}
11+
{{- $color := index $colors $grade -}}
12+
<svg xmlns="http://www.w3.org/2000/svg" width="17" height="20">
13+
<clipPath id="B">
14+
<rect width="17" height="20" rx="3" fill="#fff"/>
15+
</clipPath>
16+
<g clip-path="url(#B)">
17+
<path fill="{{ $color }}" d="M0 0h17v20H0z"/>
18+
<path fill="url(#A)" d="M0 0h17v20H0z"/>
19+
</g>
20+
<g text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
21+
<text x="85" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="70">{{ $grade }}</text>
22+
<text x="85" y="140" transform="scale(.1)" fill="#fff" textLength="70">{{ $grade }}</text>
23+
</g>
24+
</svg>

0 commit comments

Comments
 (0)