mirror of
https://github.com/grafana/grafana.git
synced 2026-01-01 22:15:10 +08:00
Compare commits
343 Commits
sriram/pos
...
instant
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
446054a61d | ||
|
|
046134db22 | ||
|
|
f7a1398cd4 | ||
|
|
0cb6e3fe93 | ||
|
|
5b9cb1f568 | ||
|
|
e3422c415f | ||
|
|
1a09c13770 | ||
|
|
eed6e4b62b | ||
|
|
579e412d19 | ||
|
|
25d06e8d78 | ||
|
|
d5f47d2a6b | ||
|
|
52c91254cc | ||
|
|
a4cf41de4a | ||
|
|
4fb464ccdc | ||
|
|
35884fa9a4 | ||
|
|
960b0e770b | ||
|
|
43280a6dab | ||
|
|
5cf48294f7 | ||
|
|
ca1ecf0764 | ||
|
|
bf4940f677 | ||
|
|
3fad863fd1 | ||
|
|
8acdc7e37b | ||
|
|
4b1558b3ea | ||
|
|
08afd73c0c | ||
|
|
6089780b73 | ||
|
|
ed1b6af28d | ||
|
|
d3ee5f3cda | ||
|
|
0e01fc1437 | ||
|
|
d9e099d480 | ||
|
|
08e8a71ad6 | ||
|
|
f6ed9e6ff0 | ||
|
|
8548530dc4 | ||
|
|
bccc980b90 | ||
|
|
810868c156 | ||
|
|
58eb0ec954 | ||
|
|
1c8a24c489 | ||
|
|
b95c00a80f | ||
|
|
4b217c601a | ||
|
|
c6ebefdfb6 | ||
|
|
4e9c670a00 | ||
|
|
8dfb4cdfc9 | ||
|
|
807264428e | ||
|
|
47ce658154 | ||
|
|
4b94009a10 | ||
|
|
aa169a123e | ||
|
|
f7891a27d2 | ||
|
|
c6a6b9fdd2 | ||
|
|
3e29ca786d | ||
|
|
8e663b50e9 | ||
|
|
3fb0e8cd2c | ||
|
|
d4fc2399d0 | ||
|
|
54d6140e6d | ||
|
|
1f880c8857 | ||
|
|
208df33e04 | ||
|
|
433a5fd464 | ||
|
|
6c69ae244e | ||
|
|
a0873736aa | ||
|
|
ae4dc181d1 | ||
|
|
0d1534e43c | ||
|
|
0d2657e2f0 | ||
|
|
c7aa83f8d3 | ||
|
|
6b266ebc50 | ||
|
|
1ee0690079 | ||
|
|
a94647d5cc | ||
|
|
032ea5d5b8 | ||
|
|
91a54d0e0e | ||
|
|
2444fb1caf | ||
|
|
7a88a64121 | ||
|
|
a0085b6cab | ||
|
|
9c15662cf6 | ||
|
|
974103c6fa | ||
|
|
2202c99d70 | ||
|
|
45d176a672 | ||
|
|
01692bc876 | ||
|
|
602e327769 | ||
|
|
e40341ffe8 | ||
|
|
7186aa4bd7 | ||
|
|
6fd75ebc54 | ||
|
|
6715369a78 | ||
|
|
9db64b55be | ||
|
|
b4738c57e4 | ||
|
|
2fcb86f031 | ||
|
|
10cbebf9c2 | ||
|
|
4588c6c11c | ||
|
|
b232ba5396 | ||
|
|
f657fc0236 | ||
|
|
5b0ebb1693 | ||
|
|
d87f7ecfc1 | ||
|
|
2c4bbf8b1d | ||
|
|
4cc4c6c666 | ||
|
|
3cda233468 | ||
|
|
56543db16a | ||
|
|
4a779c4ccb | ||
|
|
5b82e05697 | ||
|
|
332601320c | ||
|
|
1143cf130e | ||
|
|
b691b3288d | ||
|
|
a977aa9d03 | ||
|
|
e42c45c30f | ||
|
|
cd1f086d33 | ||
|
|
bf6b4c695e | ||
|
|
6fa3c196d4 | ||
|
|
ab51794bdb | ||
|
|
469f94028f | ||
|
|
2f8ec01c6c | ||
|
|
1200b684c6 | ||
|
|
b839090de5 | ||
|
|
14cb6aea92 | ||
|
|
da0f1d7b18 | ||
|
|
5751b441e1 | ||
|
|
930c5a7024 | ||
|
|
8cb6993fe6 | ||
|
|
c06c1b1e8a | ||
|
|
d602e79e9a | ||
|
|
b017f42278 | ||
|
|
d39a47a89b | ||
|
|
68b9a5f57c | ||
|
|
3d9228f296 | ||
|
|
5b5cce3243 | ||
|
|
8480862854 | ||
|
|
24ebb27ebe | ||
|
|
92d098fdfd | ||
|
|
4954822cbb | ||
|
|
62fd3ba36f | ||
|
|
71a425f912 | ||
|
|
ac6f65923d | ||
|
|
683a27bf8b | ||
|
|
db7087fdfc | ||
|
|
67573d5513 | ||
|
|
868791d751 | ||
|
|
2c0cfb0dc7 | ||
|
|
6c907fd955 | ||
|
|
58c990b2ca | ||
|
|
f19b2ef429 | ||
|
|
12f05a8553 | ||
|
|
403d6380fa | ||
|
|
015b2f6b0a | ||
|
|
7ad6358e40 | ||
|
|
d4670b1cee | ||
|
|
e079cb3738 | ||
|
|
d1f785c8bf | ||
|
|
8eef17cb37 | ||
|
|
baa89f3eac | ||
|
|
afe6cd8a6d | ||
|
|
32fecb9483 | ||
|
|
12ec94c325 | ||
|
|
9f76564f51 | ||
|
|
84a4ed612b | ||
|
|
4260dea554 | ||
|
|
75a6aa7838 | ||
|
|
fe7cc4c9a7 | ||
|
|
e22ace4031 | ||
|
|
4c4abd72e7 | ||
|
|
e33a4b147b | ||
|
|
7344c1c555 | ||
|
|
b0e85a637f | ||
|
|
b49b103f42 | ||
|
|
eab8c1db07 | ||
|
|
4b8e565a16 | ||
|
|
1912c4ccc3 | ||
|
|
cff66e8b45 | ||
|
|
acd6df6b89 | ||
|
|
05a2d26787 | ||
|
|
a33b634a9f | ||
|
|
f9f04c2a55 | ||
|
|
2cd0be3cbd | ||
|
|
db3ab6a0a7 | ||
|
|
c20067d70a | ||
|
|
fd269ce041 | ||
|
|
9c1b2fb792 | ||
|
|
9786389ae8 | ||
|
|
180a901c7d | ||
|
|
7002ab90ae | ||
|
|
519e0449e7 | ||
|
|
40da94cf74 | ||
|
|
98995922f9 | ||
|
|
e4f78c462e | ||
|
|
602b7826c4 | ||
|
|
73ab088804 | ||
|
|
9d0a23e1f5 | ||
|
|
39d7fbd66e | ||
|
|
f94722e1e3 | ||
|
|
ce73e5126a | ||
|
|
c9b2126c4a | ||
|
|
c238016532 | ||
|
|
31a7f79efd | ||
|
|
16183d794c | ||
|
|
d6f52d5d9b | ||
|
|
66b79fb221 | ||
|
|
0a0d926531 | ||
|
|
453a791db1 | ||
|
|
b6580ccb10 | ||
|
|
ea0ddb3fc9 | ||
|
|
a314b99589 | ||
|
|
ac86126a57 | ||
|
|
dcea36dffc | ||
|
|
b1c50d6354 | ||
|
|
a01b4c31a1 | ||
|
|
a1e4280603 | ||
|
|
1cd6ef6b84 | ||
|
|
82e380ed90 | ||
|
|
a3af6023c3 | ||
|
|
06c00e4fa7 | ||
|
|
13a89d4ae3 | ||
|
|
18b5a9eb8d | ||
|
|
86aa70322b | ||
|
|
b1fcdb9c09 | ||
|
|
2b8c5bea1a | ||
|
|
15e59a0ca7 | ||
|
|
0c76b52e8b | ||
|
|
7e0848294e | ||
|
|
9df15d120d | ||
|
|
a027575435 | ||
|
|
190b9e1b06 | ||
|
|
84ef5bc744 | ||
|
|
ac7a411c53 | ||
|
|
441f56f6ce | ||
|
|
1f3dc0533c | ||
|
|
01269c5dd1 | ||
|
|
d74aac3da5 | ||
|
|
a8733f9a05 | ||
|
|
ff8a9fa462 | ||
|
|
8fd5739576 | ||
|
|
2e568ef672 | ||
|
|
325863ba94 | ||
|
|
c788b35dae | ||
|
|
5ec1bd91df | ||
|
|
956ae0b283 | ||
|
|
106206ae93 | ||
|
|
b0df15c770 | ||
|
|
2484402f7a | ||
|
|
4386085aa9 | ||
|
|
bd81243bbb | ||
|
|
b41b233d7d | ||
|
|
b6dd08da2f | ||
|
|
befc947fee | ||
|
|
fccda2440e | ||
|
|
b6c4788c2a | ||
|
|
e4650d3d8f | ||
|
|
85a6a7b9c1 | ||
|
|
5d0f519c0d | ||
|
|
38db533e6e | ||
|
|
0e53749906 | ||
|
|
58e0c05150 | ||
|
|
421352f251 | ||
|
|
0012345a7e | ||
|
|
a63a9357bb | ||
|
|
ebe494c7e6 | ||
|
|
37bfea8685 | ||
|
|
9aaaa87bcf | ||
|
|
5612edd8b5 | ||
|
|
889cf57055 | ||
|
|
0cde9e4f3f | ||
|
|
a7aed23d47 | ||
|
|
21f305c6a0 | ||
|
|
d9bf13e33f | ||
|
|
4bb6926eee | ||
|
|
0e253721b0 | ||
|
|
4228ed789b | ||
|
|
9d2eadcfd2 | ||
|
|
5108225785 | ||
|
|
4ab519c825 | ||
|
|
1e0fd825eb | ||
|
|
1d252de1e9 | ||
|
|
2e58ce7980 | ||
|
|
5d92f3eee5 | ||
|
|
8283d35e56 | ||
|
|
ded7912ea3 | ||
|
|
f34a9fc0c2 | ||
|
|
c5fbf6217c | ||
|
|
b249942b61 | ||
|
|
0f3edd3b5f | ||
|
|
d786316766 | ||
|
|
99f3dc859d | ||
|
|
89c09a14b8 | ||
|
|
92121a1030 | ||
|
|
07ca8ca3e7 | ||
|
|
ae7a3db917 | ||
|
|
ca73093573 | ||
|
|
df3bb9fba4 | ||
|
|
c3eeb1fcd9 | ||
|
|
e78411f17a | ||
|
|
aa17dd8056 | ||
|
|
3f502f305d | ||
|
|
39904d7b9b | ||
|
|
d7f7a19c56 | ||
|
|
e4743a9092 | ||
|
|
20c700dd52 | ||
|
|
5e1d7cbd2e | ||
|
|
6c20ad0013 | ||
|
|
869094bb37 | ||
|
|
79ebe2dc10 | ||
|
|
dd1fce5c8a | ||
|
|
efe46c8aad | ||
|
|
68ee251c5c | ||
|
|
412415ab39 | ||
|
|
0b28a53923 | ||
|
|
fdc6a0d774 | ||
|
|
1eef358deb | ||
|
|
0fdcae4e26 | ||
|
|
0459382b25 | ||
|
|
56dcb6c08a | ||
|
|
7728a51972 | ||
|
|
53537148e1 | ||
|
|
0f23988132 | ||
|
|
4830969305 | ||
|
|
e920bd2d29 | ||
|
|
dbbd9f23d1 | ||
|
|
1e1fd3db38 | ||
|
|
15967cb7ab | ||
|
|
2e3c2df6bf | ||
|
|
e33047bdf1 | ||
|
|
047349638d | ||
|
|
35bf093201 | ||
|
|
6c1ff32501 | ||
|
|
d5a1781fb6 | ||
|
|
feedb5c0a6 | ||
|
|
a9e70d4a1d | ||
|
|
d27d8f02b6 | ||
|
|
2fabedc363 | ||
|
|
95d4909475 | ||
|
|
5d2bbfd3ee | ||
|
|
2de7f424f5 | ||
|
|
365234c2fe | ||
|
|
285c69c487 | ||
|
|
d22842b52b | ||
|
|
89e8a03859 | ||
|
|
509990ca89 | ||
|
|
de50c5a497 | ||
|
|
5b7f06c24e | ||
|
|
6c2574848f | ||
|
|
1244f5c53d | ||
|
|
0f2284d5e6 | ||
|
|
7181f8d89d | ||
|
|
34c7ea9c28 | ||
|
|
c93fd3ee9e | ||
|
|
d15e1ad8d0 | ||
|
|
757886c704 | ||
|
|
381cd95932 | ||
|
|
31b71f79dd | ||
|
|
a2a28b207c | ||
|
|
37c480def4 | ||
|
|
14eaa3975b |
@@ -7,7 +7,6 @@ exclude_unchanged = true
|
||||
follow_symlink = true
|
||||
include_dir = ["apps", "conf", "devenv/dev-dashboards", "pkg", "public/views"]
|
||||
include_ext = ["go", "ini", "toml", "html", "json"]
|
||||
pre_cmd = ["make gen-go"]
|
||||
stop_on_error = true
|
||||
send_interrupt = true
|
||||
kill_delay = 500
|
||||
|
||||
@@ -35,7 +35,7 @@ module.exports = [
|
||||
'data/',
|
||||
'deployment_tools_config.json',
|
||||
'devenv',
|
||||
'e2e/test-plugins',
|
||||
'e2e-playwright/test-plugins',
|
||||
'e2e/tmp',
|
||||
'packages/grafana-ui/src/components/Icon/iconBundle.ts',
|
||||
'pkg',
|
||||
@@ -104,6 +104,7 @@ module.exports = [
|
||||
'**/__mocks__/**',
|
||||
'**/public/test/**',
|
||||
'**/mocks.{ts,tsx}',
|
||||
'**/mocks/**/*.{ts,tsx}',
|
||||
'**/spec/**/*.{ts,tsx}',
|
||||
],
|
||||
rules: {
|
||||
|
||||
@@ -476,8 +476,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"]
|
||||
],
|
||||
"packages/grafana-prometheus/src/querybuilder/shared/types.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"packages/grafana-prometheus/src/resource_clients.test.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@@ -489,9 +488,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
|
||||
],
|
||||
"packages/grafana-prometheus/src/test/mocks/datasource.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-prometheus/src/types.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
@@ -961,9 +957,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not re-export imported variable (\`profiler\`)", "6"],
|
||||
[0, 0, 0, "Do not re-export imported variable (\`updateLegendValues\`)", "7"]
|
||||
],
|
||||
"public/app/core/navigation/mocks/routeProps.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/core/navigation/types.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
@@ -1287,9 +1280,6 @@ exports[`better eslint`] = {
|
||||
"public/app/features/alerting/unified/components/rule-editor/AnnotationKeyInput.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/alerting/unified/components/rule-editor/AnnotationsStep.tsx:5381": [
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "0"]
|
||||
],
|
||||
"public/app/features/alerting/unified/components/rule-editor/CloudEvaluationBehavior.tsx:5381": [
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "0"],
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "1"]
|
||||
@@ -1555,9 +1545,6 @@ exports[`better eslint`] = {
|
||||
"public/app/features/correlations/components/EmptyCorrelationsCTA.tsx:5381": [
|
||||
[0, 0, 0, "Add noMargin prop to Card components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "0"]
|
||||
],
|
||||
"public/app/features/correlations/mocks/useCorrelations.mocks.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/correlations/types.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
@@ -1696,15 +1683,6 @@ exports[`better eslint`] = {
|
||||
"public/app/features/dashboard-scene/serialization/transformToV1TypesUtils.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/features/dashboard-scene/settings/GeneralSettingsEditView.tsx:5381": [
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "0"],
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "1"],
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "2"],
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "3"],
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "4"],
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "5"],
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "6"]
|
||||
],
|
||||
"public/app/features/dashboard-scene/settings/annotations/AnnotationSettingsEdit.tsx:5381": [
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "0"],
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "1"],
|
||||
@@ -2355,8 +2333,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/features/geo/utils/frameVectorSource.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/inspector/InspectDataOptions.tsx:5381": [
|
||||
[0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"],
|
||||
@@ -2522,16 +2499,6 @@ exports[`better eslint`] = {
|
||||
"public/app/features/plugins/admin/components/PluginDetailsPage.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/plugins/admin/mocks/catalogPlugin.mock.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
],
|
||||
"public/app/features/plugins/admin/mocks/localPlugin.mock.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/plugins/admin/mocks/remotePlugin.mock.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/plugins/admin/pages/Browse.tsx:5381": [
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "0"],
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "1"],
|
||||
@@ -2566,10 +2533,10 @@ exports[`better eslint`] = {
|
||||
"public/app/features/plugins/loader/sharedDependencies.ts:5381": [
|
||||
[0, 0, 0, "* import is invalid because \'Layout,HorizontalGroup,VerticalGroup\' from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"]
|
||||
],
|
||||
"public/app/features/plugins/sandbox/distortion_map.ts:5381": [
|
||||
"public/app/features/plugins/sandbox/distortions.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/plugins/sandbox/sandbox_plugin_loader.ts:5381": [
|
||||
"public/app/features/plugins/sandbox/sandboxPluginLoader.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"]
|
||||
@@ -2813,10 +2780,6 @@ exports[`better eslint`] = {
|
||||
"public/app/features/transformers/editors/CalculateFieldTransformerEditor/WindowOptionsEditor.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/features/transformers/editors/CalculateFieldTransformerEditor/index.ts:5381": [
|
||||
[0, 0, 0, "Do not re-export imported variable (\`CalculateFieldTransformerEditor\`)", "0"],
|
||||
[0, 0, 0, "Do not re-export imported variable (\`calculateFieldTransformRegistryItem\`)", "1"]
|
||||
],
|
||||
"public/app/features/transformers/editors/ConvertFieldTypeTransformerEditor.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
@@ -2882,12 +2845,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"]
|
||||
],
|
||||
"public/app/features/users/mocks/userMocks.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"]
|
||||
],
|
||||
"public/app/features/variables/adapters.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
@@ -2922,10 +2879,7 @@ exports[`better eslint`] = {
|
||||
],
|
||||
"public/app/features/variables/inspect/NetworkGraph.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/features/variables/inspect/VariablesUnknownTable.tsx:5381": [
|
||||
[0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"],
|
||||
@@ -3108,21 +3062,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "5"],
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "6"]
|
||||
],
|
||||
"public/app/plugins/datasource/azuremonitor/mocks/datasource.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/azuremonitor/mocks/panelData.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"]
|
||||
],
|
||||
"public/app/plugins/datasource/azuremonitor/mocks/utils.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
],
|
||||
"public/app/plugins/datasource/azuremonitor/mocks/variables.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/azuremonitor/types/query.ts:5381": [
|
||||
[0, 0, 0, "Do not re-export imported variable (\`../dataquery.gen\`)", "0"],
|
||||
[0, 0, 0, "Do not re-export imported variable (\`../dataquery.gen\`)", "1"],
|
||||
@@ -3165,14 +3104,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloud-monitoring/mocks/cloudMonitoringDatasource.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloud-monitoring/mocks/cloudMonitoringInstanceSettings.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloud-monitoring/types/query.ts:5381": [
|
||||
[0, 0, 0, "Do not re-export imported variable (\`../dataquery.gen\`)", "0"],
|
||||
[0, 0, 0, "Do not re-export imported variable (\`../dataquery.gen\`)", "1"],
|
||||
@@ -3181,9 +3112,6 @@ exports[`better eslint`] = {
|
||||
"public/app/plugins/datasource/cloud-monitoring/types/types.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloud-monitoring/webpack.config.ts:5381": [
|
||||
[0, 0, 0, "Do not re-export imported variable (\`config\`)", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/components/ConfigEditor/ConfigEditor.tsx:5381": [
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "0"],
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "1"],
|
||||
@@ -3221,124 +3149,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/CloudWatchVariables.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-sql-test-data/commentOnlyQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-sql-test-data/multiLineFullQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-sql-test-data/multiLineFullQueryWithCaseClause.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-sql-test-data/partialQueryWithFunction.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-sql-test-data/partialQueryWithSubquery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-sql-test-data/singleLineFullQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-sql-test-data/whitespaceQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-test-data/commentOnlyQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-test-data/filterQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-test-data/multiLineFullQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-test-data/newCommandQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-test-data/singleLineFullQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-test-data/sortQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-logs-test-data/whitespaceQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-ppl-test-data/multilineQueries.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-ppl-test-data/newCommandQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-ppl-test-data/singleLineQueries.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "6"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "7"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "8"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "9"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "10"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "11"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "12"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "13"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "14"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "15"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "16"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "17"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-sql-test-data/multiLineFullQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-sql-test-data/multiLineIncompleteQueryWithoutNamespace.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-sql-test-data/singleLineEmptyQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-sql-test-data/singleLineFullQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/cloudwatch-sql-test-data/singleLineTwoQueries.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/dashboardOnLoadedEvent.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/dynamic-label-test-data/afterLabelValue.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/dynamic-label-test-data/insideLabelValue.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/metric-math-test-data/afterFunctionQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/metric-math-test-data/secondArgAfterSearchQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/metric-math-test-data/secondArgQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/metric-math-test-data/singleLineEmptyQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/metric-math-test-data/thirdArgAfterSearchQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/metric-math-test-data/withinStringQuery.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/mocks/monarch/Monaco.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
],
|
||||
"public/app/plugins/datasource/cloudwatch/types.ts:5381": [
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
@@ -3411,9 +3221,6 @@ exports[`better eslint`] = {
|
||||
"public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/state/reducer.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/elasticsearch/configuration/mocks/configOptions.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/elasticsearch/datasource.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
@@ -3471,9 +3278,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/plugins/datasource/grafana-testdata-datasource/webpack.config.ts:5381": [
|
||||
[0, 0, 0, "Do not re-export imported variable (\`config\`)", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/grafana/components/AnnotationQueryEditor.tsx:5381": [
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "0"],
|
||||
[0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "1"],
|
||||
@@ -3623,10 +3427,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"]
|
||||
],
|
||||
"public/app/plugins/datasource/influxdb/mocks/datasource.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
],
|
||||
"public/app/plugins/datasource/influxdb/query_part.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
@@ -3653,8 +3453,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not re-export imported variable (\`./trace\`)", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/jaeger/datasource.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/loki/LanguageProvider.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@@ -3694,13 +3493,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/plugins/datasource/loki/mocks/datasource.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
],
|
||||
"public/app/plugins/datasource/loki/mocks/metadataRequest.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilder.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
@@ -3836,9 +3628,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
|
||||
],
|
||||
"public/app/plugins/datasource/tempo/webpack.config.ts:5381": [
|
||||
[0, 0, 0, "Do not re-export imported variable (\`config\`)", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/zipkin/QueryField.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
@@ -3849,9 +3638,6 @@ exports[`better eslint`] = {
|
||||
"public/app/plugins/datasource/zipkin/utils/transforms.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/zipkin/webpack.config.ts:5381": [
|
||||
[0, 0, 0, "Do not re-export imported variable (\`config\`)", "0"]
|
||||
],
|
||||
"public/app/plugins/panel/annolist/AnnoListPanel.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
@@ -3970,9 +3756,6 @@ exports[`better eslint`] = {
|
||||
"public/app/plugins/panel/geomap/types.ts:5381": [
|
||||
[0, 0, 0, "Do not re-export imported variable (\`./panelcfg.gen\`)", "0"]
|
||||
],
|
||||
"public/app/plugins/panel/geomap/utils/layers.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/plugins/panel/geomap/utils/tooltip.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
@@ -4195,9 +3978,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/types/acl.ts:5381": [
|
||||
[0, 0, 0, "Do not re-export imported variable (\`OrgRole\`)", "0"]
|
||||
],
|
||||
"public/app/types/alerting.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
@@ -4219,29 +3999,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"]
|
||||
],
|
||||
"public/app/types/index.ts:5381": [
|
||||
[0, 0, 0, "Do not re-export imported variable (\`CoreEvents\`)", "0"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "1"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "2"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "3"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "4"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "5"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "6"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "7"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "8"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "9"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "10"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "11"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "12"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "13"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "14"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "15"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "16"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "17"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "18"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "19"],
|
||||
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "20"]
|
||||
],
|
||||
"public/app/types/jquery/jquery.d.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
@@ -4311,6 +4068,15 @@ exports[`no undocumented stories`] = {
|
||||
"packages/grafana-ui/src/components/ButtonCascader/ButtonCascader.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/CallToActionCard/CallToActionCard.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/ColorPicker/ColorPickerInput.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/ColorPicker/SeriesColorPicker.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/DateTimePickers/RelativeTimeRangePicker/RelativeTimeRangePicker.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
@@ -4326,12 +4092,27 @@ exports[`no undocumented stories`] = {
|
||||
"packages/grafana-ui/src/components/DateTimePickers/WeekStartPicker.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Dropdown/ButtonSelect.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/FormField/FormField.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/InfoTooltip/InfoTooltip.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/List/List.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/PageLayout/PageToolbar.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/QueryField/QueryField.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/SecretFormField/SecretFormField.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/SecretTextArea/SecretTextArea.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
@@ -4344,6 +4125,9 @@ exports[`no undocumented stories`] = {
|
||||
"packages/grafana-ui/src/components/Segment/SegmentInput.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Select/SelectPerf.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/Slider/RangeSlider.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
@@ -4353,9 +4137,21 @@ exports[`no undocumented stories`] = {
|
||||
"packages/grafana-ui/src/components/StatsPicker/StatsPicker.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/ThemeDemos/BorderRadius.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/ThemeDemos/EmotionPerfTest.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/ThemeDemos/Typography.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/UnitPicker/UnitPicker.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
@@ -4367,6 +4163,9 @@ exports[`no undocumented stories`] = {
|
||||
],
|
||||
"packages/grafana-ui/src/components/VizTooltip/SeriesTable.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
],
|
||||
"packages/grafana-ui/src/utils/useDelayedSwitch.story.tsx:5381": [
|
||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||
]
|
||||
}`
|
||||
};
|
||||
|
||||
@@ -289,7 +289,7 @@ steps:
|
||||
- commands:
|
||||
- npx wait-on@7.0.1 http://$HOST:$PORT
|
||||
- yarn playwright install --with-deps chromium
|
||||
- yarn e2e:playwright
|
||||
- yarn e2e:playwright --grep @plugins
|
||||
depends_on:
|
||||
- grafana-server
|
||||
- build-test-plugins
|
||||
@@ -761,7 +761,7 @@ steps:
|
||||
- commands:
|
||||
- npx wait-on@7.0.1 http://$HOST:$PORT
|
||||
- yarn playwright install --with-deps chromium
|
||||
- yarn e2e:playwright
|
||||
- yarn e2e:playwright --grep @plugins
|
||||
depends_on:
|
||||
- grafana-server
|
||||
- build-test-plugins
|
||||
@@ -2986,6 +2986,6 @@ kind: secret
|
||||
name: gcr_credentials
|
||||
---
|
||||
kind: signature
|
||||
hmac: 1198b1489e48a9ced211633a0325d112814553246847fc7320fb5ac2bcb32b7d
|
||||
hmac: d20f1d6e2e8347701f82114ad352f53db57dc95b5b3831941fa93d063a92b9d8
|
||||
|
||||
...
|
||||
|
||||
22
.github/CODEOWNERS
vendored
22
.github/CODEOWNERS
vendored
@@ -80,6 +80,7 @@
|
||||
/apps/dashboard/ @grafana/grafana-app-platform-squad @grafana/dashboards-squad
|
||||
/apps/folder/ @grafana/grafana-app-platform-squad
|
||||
/apps/playlist/ @grafana/grafana-app-platform-squad
|
||||
/apps/secret/ @grafana/grafana-operator-experience-squad
|
||||
/apps/investigations/ @fcjack @matryer @svennergr
|
||||
/apps/advisor/ @grafana/plugins-platform-backend
|
||||
/apps/iam/ @grafana/access-squad
|
||||
@@ -87,8 +88,8 @@
|
||||
/pkg/apis/ @grafana/grafana-app-platform-squad
|
||||
/pkg/apis/query @grafana/grafana-datasources-core-services
|
||||
/pkg/apis/userstorage @grafana/grafana-app-platform-squad @grafana/plugins-platform-backend
|
||||
/pkg/apis/secret @grafana/grafana-operator-experience-squad
|
||||
/pkg/bus/ @grafana/grafana-search-and-storage
|
||||
/pkg/clientauth/ @grafana/grafana-app-platform-squad
|
||||
/pkg/cmd/ @grafana/grafana-backend-group
|
||||
/pkg/cmd/grafana-cli/commands/install_command.go @grafana/plugins-platform-backend
|
||||
/pkg/cmd/grafana-cli/commands/install_command_test.go @grafana/plugins-platform-backend
|
||||
@@ -149,6 +150,7 @@
|
||||
/pkg/services/hooks/ @grafana/grafana-backend-group
|
||||
/pkg/services/kmsproviders/ @grafana/grafana-operator-experience-squad
|
||||
/pkg/services/licensing/ @grafana/grafana-operator-experience-squad
|
||||
/pkg/services/mtdsclient/ @grafana/grafana-datasources-core-services
|
||||
/pkg/services/navtree/ @grafana/grafana-backend-group
|
||||
/pkg/services/notifications/ @grafana/grafana-backend-group
|
||||
/pkg/services/org/ @grafana/grafana-backend-group
|
||||
@@ -177,7 +179,6 @@
|
||||
/pkg/setting/ @grafana/grafana-backend-services-squad
|
||||
/pkg/tests/ @grafana/grafana-backend-services-squad
|
||||
/pkg/tests/apis/ @grafana/grafana-app-platform-squad
|
||||
/pkg/tests/apis/query @grafana/grafana-datasources-core-services
|
||||
/pkg/tests/apis/alerting @grafana/grafana-app-platform-squad @grafana/alerting-backend
|
||||
/pkg/tests/api/correlations/ @grafana/datapro
|
||||
/pkg/tsdb/grafanads/ @grafana/grafana-backend-group
|
||||
@@ -305,6 +306,7 @@
|
||||
/devenv/jsonnet/ @grafana/dataviz-squad
|
||||
/devenv/local_cdn/ @grafana/frontend-ops
|
||||
/devenv/local-npm/ @grafana/frontend-ops
|
||||
/devenv/frontend-service/ @grafana/grafana-frontend-platform
|
||||
/devenv/setup.sh @grafana/grafana-backend-services-squad
|
||||
/devenv/plugins.yaml @grafana/plugins-platform-frontend
|
||||
|
||||
@@ -400,8 +402,10 @@
|
||||
/public/app/core/internationalization/ @grafana/grafana-frontend-platform
|
||||
/e2e/ @grafana/grafana-frontend-platform
|
||||
/e2e/cloud-plugins-suite/ @grafana/partner-datasources
|
||||
/e2e/plugin-e2e/plugin-e2e-api-tests/ @grafana/plugins-platform-frontend
|
||||
/e2e/test-plugins/grafana-extensionstest-app/ @grafana/plugins-platform-frontend
|
||||
/e2e-playwright/ @grafana/grafana-frontend-platform
|
||||
/e2e-playwright/plugin-e2e/ @grafana/oss-big-tent @grafana/partner-datasources
|
||||
/e2e-playwright/plugin-e2e/plugin-e2e-api-tests/ @grafana/plugins-platform-frontend
|
||||
/e2e-playwright/test-plugins/grafana-extensionstest-app/ @grafana/plugins-platform-frontend
|
||||
|
||||
# Packages
|
||||
/packages/ @grafana/grafana-frontend-platform @grafana/plugins-platform-frontend
|
||||
@@ -477,6 +481,7 @@
|
||||
/cypress.config.js @grafana/grafana-frontend-platform
|
||||
/.levignore.js @grafana/plugins-platform-frontend
|
||||
playwright.config.ts @grafana/plugins-platform-frontend
|
||||
playwright.storybook.config.ts @grafana/grafana-frontend-platform
|
||||
|
||||
# public folder
|
||||
/public/app/api/ @grafana/grafana-frontend-platform
|
||||
@@ -623,6 +628,7 @@ playwright.config.ts @grafana/plugins-platform-frontend
|
||||
/scripts/cli/ @grafana/grafana-frontend-platform
|
||||
/scripts/clean-git-or-error.sh @grafana/grafana-as-code
|
||||
/scripts/grafana-server/ @grafana/grafana-frontend-platform
|
||||
/scripts/check-frontend-dev.sh @grafana/grafana-frontend-platform
|
||||
/scripts/helpers/ @grafana/grafana-developer-enablement-squad
|
||||
/scripts/import_many_dashboards.sh @torkelo
|
||||
/scripts/mixin-check.sh @bergquist
|
||||
@@ -747,6 +753,7 @@ embed.go @grafana/grafana-as-code
|
||||
/pkg/kinds/ @grafana/grafana-as-code
|
||||
/pkg/registry/ @grafana/grafana-as-code
|
||||
/pkg/registry/apis/ @grafana/grafana-app-platform-squad
|
||||
/pkg/registry/apis/folders @grafana/grafana-search-and-storage
|
||||
/pkg/registry/apis/query @grafana/grafana-datasources-core-services
|
||||
/pkg/registry/apis/secret @grafana/grafana-operator-experience-squad
|
||||
/pkg/registry/apis/userstorage @grafana/grafana-app-platform-squad @grafana/plugins-platform-backend
|
||||
@@ -770,6 +777,7 @@ embed.go @grafana/grafana-as-code
|
||||
/.github/pr-checks.json @tolzhabayev
|
||||
/.github/pr-commands.json @tolzhabayev
|
||||
/.github/renovate.json5 @grafana/frontend-ops
|
||||
/.github/actions/check-jobs/action.yml @grafana/grafana-frontend-platform
|
||||
/.github/actions/setup-enterprise/action.yml @grafana/grafana-backend-group
|
||||
/.github/actions/setup-grafana-bench/ @Proximyst
|
||||
/.github/actions/build-package @grafana/grafana-developer-enablement-squad
|
||||
@@ -796,6 +804,7 @@ embed.go @grafana/grafana-as-code
|
||||
/.github/workflows/commands.yml @torkelo
|
||||
/.github/workflows/community-release.yml @grafana/grafana-developer-enablement-squad
|
||||
/.github/workflows/detect-breaking-changes-* @grafana/plugins-platform-frontend
|
||||
/.github/workflows/detect-plugin-extension-changes.yml @grafana/plugins-platform-frontend
|
||||
/.github/workflows/documentation-ci.yml @grafana/docs-tooling
|
||||
/.github/workflows/deploy-pr-preview.yml @grafana/docs-tooling
|
||||
/.github/workflows/feature-toggles-ci.yml @grafana/docs-tooling
|
||||
@@ -817,6 +826,7 @@ embed.go @grafana/grafana-as-code
|
||||
/.github/workflows/scripts/json-file-to-job-output.js @grafana/plugins-platform-frontend
|
||||
/.github/workflows/stale.yml @grafana/grafana-developer-enablement-squad
|
||||
/.github/workflows/storybook-verification.yml @grafana/grafana-frontend-platform
|
||||
/.github/workflows/storybook-verification-playwright.yml @grafana/grafana-frontend-platform
|
||||
/.github/workflows/update-make-docs.yml @grafana/docs-tooling
|
||||
/.github/workflows/scripts/kinds/verify-kinds.go @grafana/platform-monitoring
|
||||
/.github/workflows/scripts/create-security-branch/create-security-branch.sh @grafana/grafana-developer-enablement-squad
|
||||
@@ -876,3 +886,7 @@ embed.go @grafana/grafana-as-code
|
||||
/conf/provisioning/datasources/ @grafana/plugins-platform-backend
|
||||
/conf/provisioning/plugins/ @grafana/plugins-platform-backend
|
||||
/conf/provisioning/sample/ @grafana/grafana-git-ui-sync-team
|
||||
|
||||
# Security
|
||||
/relyance.yaml @grafana/security-team
|
||||
/.github/workflows/relyance-scan.yml @grafana/security-team
|
||||
|
||||
48
.github/actions/check-jobs/action.yml
vendored
Normal file
48
.github/actions/check-jobs/action.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
name: Check jobs results
|
||||
description: Checks if any jobs have failed and exits with error if failures are found. Use to check the results of matrix test runs.
|
||||
inputs:
|
||||
needs:
|
||||
description: JSON string containing the needs context from the workflow
|
||||
required: true
|
||||
failure-message:
|
||||
description: Custom message to display when failures are found
|
||||
required: false
|
||||
default: "One or more jobs have failed"
|
||||
success-message:
|
||||
description: Custom message to display when all jobs pass
|
||||
required: false
|
||||
default: "All jobs passed successfully"
|
||||
outputs:
|
||||
any-failed:
|
||||
description: Whether any jobs failed
|
||||
value: ${{ steps.check-jobs.outputs.any-failed }}
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Check test suites
|
||||
id: check-jobs
|
||||
shell: bash
|
||||
env:
|
||||
NEEDS: ${{ inputs.needs }}
|
||||
FAILURE_MSG: ${{ inputs.failure-message }}
|
||||
SUCCESS_MSG: ${{ inputs.success-message }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
# Print the needs context, debugging
|
||||
echo "$NEEDS" | jq
|
||||
|
||||
# Extract failures
|
||||
FAILURES="$(echo "$NEEDS" | jq 'with_entries(select(.value.result == "failure")) | map_values(.result)')"
|
||||
|
||||
# Check if there are any failures
|
||||
if [ "$(echo "$FAILURES" | jq '. | length')" != "0" ]; then
|
||||
echo "❌ $FAILURE_MSG"
|
||||
echo "Failed suites:"
|
||||
echo "$FAILURES" | jq -r 'to_entries[] | "- \(.key): \(.value)"'
|
||||
echo "any-failed=true" >> "$GITHUB_OUTPUT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ $SUCCESS_MSG"
|
||||
2
.github/dependabot.yml
vendored
2
.github/dependabot.yml
vendored
@@ -8,11 +8,11 @@ updates:
|
||||
directories:
|
||||
- "/"
|
||||
- "/apps/playlist"
|
||||
- "/apps/secret"
|
||||
- "/apps/investigations"
|
||||
- "/pkg/aggregator"
|
||||
- "/pkg/apimachinery"
|
||||
- "/pkg/apis/folder"
|
||||
- "/pkg/apis/secret"
|
||||
- "/pkg/apiserver"
|
||||
- "/pkg/build"
|
||||
- "/pkg/build/wire"
|
||||
|
||||
2
.github/license_finder.yaml
vendored
2
.github/license_finder.yaml
vendored
@@ -99,7 +99,7 @@
|
||||
:versions: []
|
||||
:when: 2025-05-03 13:10:00.000000000 Z
|
||||
- - :license
|
||||
- github.com/grafana/grafana/pkg/apis/secret
|
||||
- github.com/grafana/grafana/apps/secret
|
||||
- unknown
|
||||
- :who: Carl Bergquist
|
||||
:why: repository is owned by Grafana Labs
|
||||
|
||||
2
.github/workflows/add-to-whats-new.yml
vendored
2
.github/workflows/add-to-whats-new.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.1
|
||||
- uses: marocchino/sticky-pull-request-comment@d2ad0de260ae8b0235ce059e63f2949ba9e05943 # v2.9.3
|
||||
with:
|
||||
message: |
|
||||
Since you've added the `Add to what's new` label, consider drafting a [What's new note](https://admin.grafana.com/content-admin/#/collections/whats-new/new) for this feature.
|
||||
|
||||
@@ -62,7 +62,7 @@ jobs:
|
||||
with:
|
||||
credentials_json: '${{ env.PLUGINS_GOOGLE_CREDENTIALS }}'
|
||||
- name: 'Set up Cloud SDK'
|
||||
uses: 'google-github-actions/setup-gcloud@6189d56e4096ee891640bb02ac264be376592d6a'
|
||||
uses: 'google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a'
|
||||
- name: Setup nodejs environment
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
|
||||
@@ -158,13 +158,15 @@ jobs:
|
||||
|
||||
- id: 'auth'
|
||||
uses: 'google-github-actions/auth@6fc4af4b145ae7821d527454aa9bd537d1f2dc5f'
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
with:
|
||||
workload_identity_provider: projects/304398677251/locations/global/workloadIdentityPools/github/providers/github-provider
|
||||
service_account: github-plugins-data-levitate@grafanalabs-workload-identity.iam.gserviceaccount.com
|
||||
project_id: 'grafanalabs-global'
|
||||
|
||||
- name: 'Set up Cloud SDK'
|
||||
uses: 'google-github-actions/setup-gcloud@6189d56e4096ee891640bb02ac264be376592d6a'
|
||||
uses: 'google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a'
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
with:
|
||||
version: '>= 363.0.0'
|
||||
project_id: 'grafanalabs-global'
|
||||
@@ -175,6 +177,7 @@ jobs:
|
||||
run: ./scripts/check-breaking-changes.sh
|
||||
env:
|
||||
FORCE_COLOR: 3
|
||||
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }} # used in check-breaking-changes.sh and levitate-parse-json-report.js
|
||||
|
||||
- name: Persisting the check output
|
||||
run: |
|
||||
@@ -199,6 +202,7 @@ jobs:
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
|
||||
steps:
|
||||
- id: get-secrets
|
||||
@@ -267,7 +271,7 @@ jobs:
|
||||
# Comment on the PR
|
||||
- name: Comment on PR
|
||||
if: steps.levitate-run.outputs.exit_code == 1
|
||||
uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728
|
||||
uses: marocchino/sticky-pull-request-comment@d2ad0de260ae8b0235ce059e63f2949ba9e05943
|
||||
with:
|
||||
header: levitate-breaking-change-comment
|
||||
number: ${{ github.event.pull_request.number }}
|
||||
@@ -284,7 +288,7 @@ jobs:
|
||||
# Remove comment from the PR (no more breaking changes)
|
||||
- name: Remove comment from PR
|
||||
if: steps.levitate-run.outputs.exit_code == 0
|
||||
uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728
|
||||
uses: marocchino/sticky-pull-request-comment@d2ad0de260ae8b0235ce059e63f2949ba9e05943
|
||||
with:
|
||||
header: levitate-breaking-change-comment
|
||||
number: ${{ github.event.pull_request.number }}
|
||||
|
||||
156
.github/workflows/detect-plugin-extension-changes.yml
vendored
Normal file
156
.github/workflows/detect-plugin-extension-changes.yml
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
---
|
||||
name: Detect Plugin Extension Changes
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- 'main'
|
||||
paths:
|
||||
- 'packages/**'
|
||||
- 'public/**'
|
||||
|
||||
env:
|
||||
# Space-separated list of keywords referring to plugin extensions
|
||||
PLUGIN_EXTENSION_KEYWORDS: "usePluginLinks, usePluginComponent, usePluginComponents, usePluginFunctions, PluginExtensionPoints"
|
||||
|
||||
jobs:
|
||||
detect-plugin-extension-changes:
|
||||
name: Detect Plugin Extension Changes
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Check for plugin extension changes
|
||||
id: check-changes
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
|
||||
// Plugin extension keywords from environment
|
||||
const keywords = process.env.PLUGIN_EXTENSION_KEYWORDS.split(',');
|
||||
const baseSha = '${{ github.event.pull_request.base.sha }}';
|
||||
const headSha = '${{ github.event.pull_request.head.sha }}';
|
||||
|
||||
console.log('Checking for plugin extension changes...');
|
||||
console.log('Keywords:', keywords);
|
||||
|
||||
// Get changed files in packages/ and public/ directories
|
||||
let changedFiles = [];
|
||||
const diffOutput = execSync(
|
||||
`git diff --name-only ${baseSha}...${headSha} -- packages/ public/`,
|
||||
{ encoding: 'utf8' }
|
||||
).trim();
|
||||
|
||||
if (diffOutput) {
|
||||
changedFiles = diffOutput.split('\n').filter(file => {
|
||||
// Validate file path and ensure it's in target directories
|
||||
return file.match(/^(packages\/|public\/)/) &&
|
||||
file.match(/^[a-zA-Z0-9._/-]+$/) &&
|
||||
fs.existsSync(file);
|
||||
});
|
||||
}
|
||||
|
||||
console.log('Changed files to check:', changedFiles);
|
||||
|
||||
// Check each file for plugin extension keywords
|
||||
const filesWithChanges = new Set();
|
||||
let hasPluginExtensionChanges = false;
|
||||
|
||||
for (const file of changedFiles) {
|
||||
try {
|
||||
// Get the diff for this specific file
|
||||
const fileDiff = execSync(
|
||||
`git diff ${baseSha}...${headSha} -- "${file}"`,
|
||||
{ encoding: 'utf8' }
|
||||
);
|
||||
|
||||
// Check if any keywords are in the diff
|
||||
for (const keyword of keywords) {
|
||||
if (fileDiff.includes(keyword)) {
|
||||
console.log(`Found ${keyword} in ${file}`);
|
||||
filesWithChanges.add(file);
|
||||
hasPluginExtensionChanges = true;
|
||||
break; // Found at least one keyword, move to next file
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(`Error checking file ${file}:`, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Set outputs
|
||||
const filesArray = Array.from(filesWithChanges);
|
||||
const formattedFiles = filesArray.length > 0
|
||||
? '`' + filesArray.join('`\\n- `') + '`'
|
||||
: '';
|
||||
|
||||
core.setOutput('plugin_extension_changes', hasPluginExtensionChanges.toString());
|
||||
core.setOutput('formatted_changed_files', formattedFiles);
|
||||
|
||||
if (hasPluginExtensionChanges) {
|
||||
console.log('The following files have changes that may affect plugin extensions:');
|
||||
console.log(filesArray);
|
||||
} else {
|
||||
console.log('No changes detected in core Grafana extensions or extension points.');
|
||||
}
|
||||
|
||||
- name: Send Slack Message via Payload
|
||||
id: slack
|
||||
if: steps.check-changes.outputs.plugin_extension_changes == 'true'
|
||||
uses: grafana/shared-workflows/actions/send-slack-message@0941e3408fa4789fec9062c44a2a9e1832146ba6 #v2.0.1
|
||||
with:
|
||||
method: chat.postMessage
|
||||
payload-templated: true
|
||||
payload: |
|
||||
{
|
||||
"channel": "C031SLFH6G0",
|
||||
"text": "Plugin Extension changes in core Grafana *PR:* <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }} :information_source:",
|
||||
"icon_emoji": ":grot:",
|
||||
"username": "Plugin Extension Bot",
|
||||
"blocks": [
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": "*Plugin Extensions:* possible changes to extension points in core Grafana."
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": "*PR:* <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }}>\n*Job:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Job>"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": "*File(s) with changes:*\n- ${{ steps.check-changes.outputs.formatted_changed_files }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": "*What to do?*\nMake sure that:\n- All extension point ids start with `grafana/`\n- All extension point ids are exposed via <https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/types/pluginExtensions.ts#L183|the `PluginExtensionPoints` enum in grafana-data>\n- Core Grafana is not registering extensions to extension points offered by plugins"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
5
.github/workflows/frontend-lint.yml
vendored
5
.github/workflows/frontend-lint.yml
vendored
@@ -16,6 +16,7 @@ jobs:
|
||||
contents: read
|
||||
outputs:
|
||||
changed: ${{ steps.detect-changes.outputs.frontend }}
|
||||
prettier: ${{ steps.detect-changes.outputs.frontend == 'true' || steps.detect-changes.outputs.docs == 'true' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -34,7 +35,7 @@ jobs:
|
||||
id-token: write
|
||||
# Run this workflow only for PRs from forks; if it gets merged into `main` or `release-*`,
|
||||
# the `lint-frontend-prettier-enterprise` workflow will run instead
|
||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true && needs.detect-changes.outputs.changed == 'true'
|
||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true && needs.detect-changes.outputs.prettier == 'true'
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -55,7 +56,7 @@ jobs:
|
||||
contents: read
|
||||
id-token: write
|
||||
# Run this workflow for non-PR events (like pushes to `main` or `release-*`) OR for internal PRs (PRs not from forks)
|
||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false && needs.detect-changes.outputs.changed == 'true'
|
||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false && needs.detect-changes.outputs.prettier == 'true'
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
1
.github/workflows/i18n-crowdin-download.yml
vendored
1
.github/workflows/i18n-crowdin-download.yml
vendored
@@ -7,6 +7,7 @@ on:
|
||||
|
||||
jobs:
|
||||
download-sources-from-crowdin:
|
||||
if: github.repository == 'grafana/grafana'
|
||||
uses: grafana/grafana-github-actions/.github/workflows/crowdin-download.yml@main
|
||||
with:
|
||||
crowdin_project_id: 5
|
||||
|
||||
1
.github/workflows/i18n-crowdin-upload.yml
vendored
1
.github/workflows/i18n-crowdin-upload.yml
vendored
@@ -14,6 +14,7 @@ on:
|
||||
|
||||
jobs:
|
||||
upload-sources-to-crowdin:
|
||||
if: github.repository == 'grafana/grafana'
|
||||
uses: grafana/grafana-github-actions/.github/workflows/crowdin-upload.yml@main
|
||||
with:
|
||||
crowdin_project_id: 5
|
||||
|
||||
191
.github/workflows/pr-e2e-tests.yml
vendored
191
.github/workflows/pr-e2e-tests.yml
vendored
@@ -7,12 +7,17 @@ on:
|
||||
- main
|
||||
- release-*.*.*
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
|
||||
# TODO: re-enable this before merging
|
||||
# concurrency:
|
||||
# group: ${{ github.workflow }}-${{ github.ref }}
|
||||
# cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
|
||||
|
||||
permissions: {}
|
||||
|
||||
env:
|
||||
ACTIONS_STEP_DEBUG: true
|
||||
RUNNER_DEBUG: 1
|
||||
|
||||
jobs:
|
||||
detect-changes:
|
||||
name: Detect whether code changed
|
||||
@@ -44,22 +49,56 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
path: ./grafana
|
||||
persist-credentials: false
|
||||
- uses: dagger/dagger-for-github@e47aba410ef9bb9ed81a4d2a97df31061e5e842e
|
||||
|
||||
# TODO: add a cleanup workflow to remove the cache when the PR is closed
|
||||
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy
|
||||
# TODO: maybe we could just use the cache to store the build, instead of uploading as an artifact?
|
||||
- uses: actions/cache@v4
|
||||
id: cache
|
||||
with:
|
||||
key: "build-grafana-${{ runner.os }}-${{ hashFiles('yarn.lock', 'public/*', 'packages/*', 'pkg/**/*.go', '**/go.mod', '**/go.sum', '!**_test.go', '!**.test.ts', '!**.test.tsx') }}"
|
||||
path: |
|
||||
build-dir
|
||||
|
||||
# If no cache hit, build Grafana
|
||||
- name: Build Grafana
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
uses: dagger/dagger-for-github@e47aba410ef9bb9ed81a4d2a97df31061e5e842e
|
||||
with:
|
||||
verb: run
|
||||
args: go -C grafana run ./pkg/build/cmd artifacts -a targz:grafana:linux/amd64 --grafana-dir="${PWD}/grafana" > out.txt
|
||||
- run: mv "$(cat out.txt)" grafana.tar.gz
|
||||
- run: echo "artifact=grafana-e2e-${{github.run_number}}" >> "$GITHUB_OUTPUT"
|
||||
args: go run ./pkg/build/cmd artifacts -a targz:grafana:linux/amd64 --grafana-dir="${PWD}" > out.txt
|
||||
- name: Cat built artifact
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: cat out.txt
|
||||
- name: Move built artifact
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
mkdir -p build-dir
|
||||
mv "$(cat out.txt)" build-dir/grafana.tar.gz
|
||||
|
||||
# If cache hit, validate the artifact is present
|
||||
- name: Validate artifact
|
||||
if: steps.cache.outputs.cache-hit == 'true'
|
||||
run: |
|
||||
if [ ! -f build-dir/grafana.tar.gz ]; then
|
||||
echo "Error: build-dir/grafana.tar.gz not found in cache"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Set artifact name
|
||||
run: echo "artifact=grafana-server-${{github.run_number}}" >> "$GITHUB_OUTPUT"
|
||||
id: artifact
|
||||
- uses: actions/upload-artifact@v4
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
id: upload
|
||||
with:
|
||||
retention-days: 1
|
||||
name: ${{ steps.artifact.outputs.artifact }}
|
||||
path: grafana.tar.gz
|
||||
path: build-dir/grafana.tar.gz
|
||||
|
||||
# TODO: we won't need this when we only have playwright
|
||||
build-e2e-runner:
|
||||
needs: detect-changes
|
||||
if: needs.detect-changes.outputs.changed == 'true'
|
||||
@@ -159,6 +198,119 @@ jobs:
|
||||
path: videos
|
||||
retention-days: 1
|
||||
|
||||
run-playwright-tests:
|
||||
needs:
|
||||
- build-grafana
|
||||
name: Playwright E2E tests (${{ matrix.shard }}/${{ matrix.shardTotal }})
|
||||
runs-on: ubuntu-latest-8-cores
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shard: [1, 2, 3, 4, 5, 6, 7, 8]
|
||||
shardTotal: [8]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ${{ needs.build-grafana.outputs.artifact }}
|
||||
- name: Run E2E tests
|
||||
uses: dagger/dagger-for-github@e47aba410ef9bb9ed81a4d2a97df31061e5e842e
|
||||
with:
|
||||
verb: run
|
||||
args: go run ./pkg/build/e2e-playwright --package=grafana.tar.gz --shard=${{ matrix.shard }}/${{ matrix.shardTotal }} --blob-dir=./blob-report
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: success() || failure()
|
||||
with:
|
||||
name: playwright-blob-${{ github.run_number }}-${{ matrix.shard }}
|
||||
path: ./blob-report
|
||||
retention-days: 1
|
||||
|
||||
required-playwright-tests:
|
||||
needs:
|
||||
- run-playwright-tests
|
||||
- build-grafana
|
||||
if: ${{ !cancelled() }}
|
||||
name: All Playwright tests complete
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
|
||||
- name: Download blob reports from GitHub Actions Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: blobs
|
||||
pattern: playwright-blob-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Check blob reports
|
||||
run: |
|
||||
if [ ! "$(ls -A ./blobs)" ]; then
|
||||
echo "Error: No blob reports found in ./blobs directory"
|
||||
echo "Did the Playwright tests run at all?"
|
||||
exit 1
|
||||
fi
|
||||
echo "Found blob reports in ./blobs:"
|
||||
ls -lah ./blobs
|
||||
|
||||
- name: Merge into HTML Report
|
||||
run: npx playwright merge-reports --reporter html ./blobs
|
||||
|
||||
- name: Merge into JSON Report
|
||||
env:
|
||||
PLAYWRIGHT_JSON_OUTPUT_NAME: /tmp/playwright-results.json
|
||||
run: npx playwright merge-reports --reporter=json ./blobs
|
||||
|
||||
- name: Bench report
|
||||
run: |
|
||||
docker run --rm \
|
||||
--volume="/tmp/playwright-results.json:/home/bench/tests/playwright-results.json" \
|
||||
us-docker.pkg.dev/grafanalabs-global/docker-grafana-bench-prod/grafana-bench:v0.5.1 report \
|
||||
--grafana-url "http://localhost:3000" \
|
||||
--grafana-version "CI- ${{ github.sha }}" \
|
||||
--test-suite-name "FrontendCore" \
|
||||
--report-input playwright \
|
||||
--report-output log \
|
||||
--log-level DEBUG \
|
||||
/home/bench/tests/playwright-results.json
|
||||
|
||||
- name: Upload HTML report
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: playwright-html-${{ github.run_number }}
|
||||
path: playwright-report
|
||||
retention-days: 7
|
||||
|
||||
- name: Check test suites
|
||||
id: check-jobs
|
||||
uses: ./.github/actions/check-jobs
|
||||
continue-on-error: true # Failure will be reported on Show test results step
|
||||
with:
|
||||
needs: ${{ toJson(needs) }}
|
||||
failure-message: "One or more E2E test suites have failed"
|
||||
success-message: "All E2E test suites completed successfully"
|
||||
|
||||
- name: Show test results
|
||||
env:
|
||||
FAILED: ${{ steps.check-jobs.outputs.any-failed }}
|
||||
# sed removes the leading `../../src/` from the paths
|
||||
run: |
|
||||
npx playwright merge-reports --reporter list ./all-blob-reports | sed 's|\(\.\./\)\{1,\}src/|/|g'
|
||||
if [ "$FAILED" = "true" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run-a11y-test:
|
||||
needs:
|
||||
- build-grafana
|
||||
@@ -193,6 +345,7 @@ jobs:
|
||||
required-e2e-tests:
|
||||
needs:
|
||||
- run-e2e-tests
|
||||
- build-grafana
|
||||
# a11y test is not listed on purpose: it is not an important E2E test.
|
||||
# It is also totally fine to fail right now.
|
||||
# always() is the best function here.
|
||||
@@ -203,13 +356,13 @@ jobs:
|
||||
name: All E2E tests complete
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Check test suites
|
||||
env:
|
||||
NEEDS: ${{ toJson(needs) }}
|
||||
run: |
|
||||
FAILURES="$(echo "$NEEDS" | jq 'with_entries(select(.value.result == "failure")) | map_values(.result)')"
|
||||
echo "$FAILURES"
|
||||
if [ "$(echo "$FAILURES" | jq '. | length')" != "0" ]; then
|
||||
exit 1
|
||||
fi
|
||||
echo "All OK!"
|
||||
uses: ./.github/actions/check-jobs
|
||||
with:
|
||||
needs: ${{ toJson(needs) }}
|
||||
failure-message: "One or more E2E test suites have failed"
|
||||
success-message: "All E2E test suites completed successfully"
|
||||
|
||||
18
.github/workflows/pr-frontend-unit-tests.yml
vendored
18
.github/workflows/pr-frontend-unit-tests.yml
vendored
@@ -90,6 +90,23 @@ jobs:
|
||||
TEST_SHARD: ${{ matrix.chunk }}
|
||||
TEST_SHARD_TOTAL: 8
|
||||
|
||||
frontend-decoupled-plugin-tests:
|
||||
needs: detect-changes
|
||||
if: needs.detect-changes.outputs.changed == 'true'
|
||||
runs-on: ubuntu-latest-8-cores
|
||||
name: "Decoupled plugin tests"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: 'yarn.lock'
|
||||
- run: yarn install --immutable --check-cache
|
||||
- run: yarn run plugin:test:ci
|
||||
|
||||
# This is the job that is actually required by rulesets.
|
||||
# We need to require EITHER the OSS or the Enterprise job to pass.
|
||||
# However, if one is skipped, GitHub won't flat-map the shards,
|
||||
@@ -98,6 +115,7 @@ jobs:
|
||||
needs:
|
||||
- frontend-unit-tests
|
||||
- frontend-unit-tests-enterprise
|
||||
- frontend-decoupled-plugin-tests
|
||||
# always() is the best function here.
|
||||
# success() || failure() will skip this function if any need is also skipped.
|
||||
# That means conditional test suites will fail the entire requirement check.
|
||||
|
||||
69
.github/workflows/pr-go-workspace-check.yml
vendored
69
.github/workflows/pr-go-workspace-check.yml
vendored
@@ -45,3 +45,72 @@ jobs:
|
||||
fi
|
||||
- name: Ensure Dockerfile contains submodule COPY commands
|
||||
run: ./scripts/go-workspace/validate-dockerfile.sh
|
||||
|
||||
check-wire:
|
||||
name: Check Wire Changes
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Set go version
|
||||
uses: actions/setup-go@19bb51245e9c80abacb2e91cc42b33fa478b8639
|
||||
with:
|
||||
cache: false
|
||||
go-version-file: go.mod
|
||||
|
||||
- name: Setup Enterprise
|
||||
if: github.event.pull_request.head.repo.fork == false
|
||||
uses: ./.github/actions/setup-enterprise
|
||||
|
||||
- name: Calculate generated wire checksums
|
||||
id: pre_gen_oss
|
||||
run: |
|
||||
OSS_WIRE_CHECKSUM="$(sha256sum pkg/server/wire_gen.go | cut -d' ' -f1)"
|
||||
echo "wire_checksum=$OSS_WIRE_CHECKSUM" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Calculate generated enterprise wire checksums
|
||||
id: pre_gen_enterprise
|
||||
if: github.event.pull_request.head.repo.fork == false
|
||||
run: |
|
||||
ENTERPRISE_WIRE_CHECKSUM="$(sha256sum pkg/server/enterprise_wire_gen.go | cut -d' ' -f1)"
|
||||
echo "wire_checksum=$ENTERPRISE_WIRE_CHECKSUM" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Generate Go files
|
||||
run: make gen-go
|
||||
|
||||
- name: Check for generated file changes
|
||||
run: |
|
||||
OSS_WIRE_CHANGED=false
|
||||
CURRENT_OSS_WIRE_CHECKSUM=$(sha256sum pkg/server/wire_gen.go | cut -d' ' -f1)
|
||||
if [ "$CURRENT_OSS_WIRE_CHECKSUM" != "${{ steps.pre_gen_oss.outputs.wire_checksum }}" ]; then
|
||||
OSS_WIRE_CHANGED=true
|
||||
echo "Uncomitted changes detected in pkg/server/wire_gen.go"
|
||||
fi
|
||||
|
||||
ENTERPRISE_WIRE_CHANGED=false
|
||||
if [ -f "pkg/server/enterprise_wire_gen.go" ]; then
|
||||
CURRENT_ENTERPRISE_WIRE_CHECKSUM=$(sha256sum pkg/server/enterprise_wire_gen.go | cut -d' ' -f1)
|
||||
if [ "$CURRENT_ENTERPRISE_WIRE_CHECKSUM" != "${{ steps.pre_gen_enterprise.outputs.wire_checksum }}" ]; then
|
||||
ENTERPRISE_WIRE_CHANGED=true
|
||||
echo "Uncomitted changes detected in pkg/server/enterprise_wire_gen.go"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$OSS_WIRE_CHANGED" = "false" ] && [ "$ENTERPRISE_WIRE_CHANGED" = "false" ]; then
|
||||
echo "No changes in generated Go files"
|
||||
else
|
||||
if [[ "${{ github.event.pull_request.head.repo.fork }}" == "false" ]]; then
|
||||
echo "> !!! Please link Enterprise and run 'make gen-go', then commit the changes to both repositories."
|
||||
else
|
||||
echo "> !!! Please run 'make gen-go' and commit the changes."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
5
.github/workflows/publish-artifact.yml
vendored
5
.github/workflows/publish-artifact.yml
vendored
@@ -48,7 +48,7 @@ jobs:
|
||||
path: ./artifact
|
||||
- name: Log in to GCS
|
||||
id: login-to-gcs
|
||||
uses: grafana/shared-workflows/actions/login-to-gcs@login-to-gcs/v0.2.1
|
||||
uses: grafana/shared-workflows/actions/login-to-gcs@main
|
||||
with:
|
||||
environment: ${{ inputs.environment }}
|
||||
service_account: ${{ inputs.service-account }}
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
find ./artifact -mindepth 2 -maxdepth 2 -exec cp -r {} out/ \;
|
||||
ls -al out
|
||||
- name: Upload artifacts
|
||||
uses: grafana/shared-workflows/actions/push-to-gcs@push-to-gcs-v0.2.0
|
||||
uses: grafana/shared-workflows/actions/push-to-gcs@main
|
||||
with:
|
||||
bucket: ${{ inputs.bucket }}
|
||||
environment: ${{ inputs.environment }}
|
||||
@@ -66,3 +66,4 @@ jobs:
|
||||
path: out
|
||||
bucket_path: ${{ inputs.bucket-path }}
|
||||
service_account: ${{ inputs.service-account }}
|
||||
gzip: false
|
||||
|
||||
2
.github/workflows/release-build.yml
vendored
2
.github/workflows/release-build.yml
vendored
@@ -186,5 +186,5 @@ jobs:
|
||||
bucket: grafana-prerelease
|
||||
pattern: artifacts-*
|
||||
run-id: ${{ github.run_id }}
|
||||
bucket-path: ${{ needs.setup.outputs.version }}
|
||||
bucket-path: ${{ needs.setup.outputs.version }}_${{ github.run_id }}
|
||||
environment: prod
|
||||
|
||||
2
.github/workflows/release-pr.yml
vendored
2
.github/workflows/release-pr.yml
vendored
@@ -208,7 +208,7 @@ jobs:
|
||||
if: ${{ inputs.bump == true || inputs.bump == 'true' }}
|
||||
run: |
|
||||
git add package.json lerna.json yarn.lock packages public
|
||||
test -e e2e/test-plugins && git add e2e/test-plugins
|
||||
test -e e2e-playwright/test-plugins && git add e2e-playwright/test-plugins
|
||||
git commit -m "Update version to $VERSION"
|
||||
|
||||
- name: Git push
|
||||
|
||||
33
.github/workflows/relyance-scan.yml
vendored
Normal file
33
.github/workflows/relyance-scan.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
name: Relyance Compliance Inspection
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *' # Run daily at 00:00 UTC
|
||||
workflow_dispatch: # Allow for manual trigger
|
||||
|
||||
jobs:
|
||||
relyance-compliance-inspector:
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write # Needed for Vault access
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Get API key
|
||||
id: vault-secrets
|
||||
uses: grafana/shared-workflows/actions/get-vault-secrets@5d7e361bc7e0a183cde8afe9899fb7b596d2659b # get-vault-secrets-v1.2.0
|
||||
with:
|
||||
repo_secrets: |
|
||||
API_KEY=relyance:API_KEY
|
||||
|
||||
- name: Run Relyance scan
|
||||
env:
|
||||
API_KEY: "${{ fromJSON(steps.vault-secrets.outputs.secrets).API_KEY }}"
|
||||
run: |
|
||||
docker pull gcr.io/relyance-ext/compliance_inspector:release && \
|
||||
docker run --rm -v ${{ github.workspace }}:/repo --env "API_KEY=${{ env.API_KEY }}" gcr.io/relyance-ext/compliance_inspector:release
|
||||
@@ -64,7 +64,7 @@ jobs:
|
||||
tools/
|
||||
public/
|
||||
conf/
|
||||
e2e/test-plugins/
|
||||
e2e-playwright/test-plugins/
|
||||
devenv/
|
||||
key: ${{ runner.os }}-grafana-${{ hashFiles('go.mod', 'package-lock.json', 'Makefile', 'pkg/storage/**/*.go', 'public/app/features/search/**/*.ts', 'public/app/features/search/**/*.tsx') }}
|
||||
# only rebuild grafana if search files have changed ( or dependencies )
|
||||
@@ -116,7 +116,7 @@ jobs:
|
||||
tools/
|
||||
public/
|
||||
conf/
|
||||
e2e/test-plugins/
|
||||
e2e-playwright/test-plugins/
|
||||
devenv/
|
||||
key: ${{ runner.os }}-grafana-${{ hashFiles('go.mod', 'package-lock.json', 'Makefile', 'pkg/storage/**/*.go', 'public/app/features/search/**/*.ts', 'public/app/features/search/**/*.tsx') }}
|
||||
- name: Set the step name
|
||||
|
||||
47
.github/workflows/storybook-verification-playwright.yml
vendored
Normal file
47
.github/workflows/storybook-verification-playwright.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
name: Verify Storybook (Playwright)
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'packages/grafana-ui/**'
|
||||
- 'e2e-playwright/storybook/**'
|
||||
- '!docs/**'
|
||||
- '!*.md'
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'packages/grafana-ui/**'
|
||||
- 'e2e-playwright/storybook/**'
|
||||
- '!docs/**'
|
||||
- '!*.md'
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
verify-storybook:
|
||||
name: Verify Storybook (Playwright)
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
cache: 'yarn'
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn install --immutable
|
||||
|
||||
- name: Install Playwright browsers
|
||||
run: npx playwright install --with-deps
|
||||
|
||||
- name: Run Storybook and E2E tests
|
||||
run: yarn e2e:playwright:storybook
|
||||
12
.github/workflows/trufflehog.yml
vendored
12
.github/workflows/trufflehog.yml
vendored
@@ -21,15 +21,17 @@ jobs:
|
||||
contents: read # clone the repo
|
||||
|
||||
steps:
|
||||
- name: Calculate fetch depth
|
||||
id: fetch_depth
|
||||
shell: bash
|
||||
run: echo "fetch_depth=$(( ${{ github.event.pull_request.commits }} + 2 ))" >> "$GITHUB_OUTPUT"
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.head_ref }}
|
||||
fetch-depth: ${{ steps.fetch_depth.outputs.fetch_depth }}
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
- name: Trufflehog
|
||||
uses: trufflesecurity/trufflehog@90190deac64289cb10bb694894be8db9ead8790b # v3.88.29
|
||||
uses: trufflesecurity/trufflehog@eafb8c5f6a06175141c27f17bcc17941853d0047 # v3.90.0
|
||||
with:
|
||||
base: ${{ github.event.pull_request.base.sha }}
|
||||
head: ${{ github.event.pull_request.head.sha }}
|
||||
extra_args: --results=verified
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -237,4 +237,4 @@ public/app/plugins/**/dist/
|
||||
# Mock service worker used for fake API responses in frontend development
|
||||
public/mockServiceWorker.js
|
||||
|
||||
/e2e/test-plugins/*/dist
|
||||
/e2e-playwright/test-plugins/*/dist
|
||||
|
||||
@@ -83,6 +83,14 @@ linters:
|
||||
deny:
|
||||
- pkg: github.com/grafana/grafana/pkg
|
||||
desc: apps/playlist is not allowed to import grafana core
|
||||
apps-secret:
|
||||
list-mode: lax
|
||||
files:
|
||||
- ./apps/secret/*
|
||||
- ./apps/secret/**/*
|
||||
deny:
|
||||
- pkg: github.com/grafana/grafana/pkg
|
||||
desc: apps/secret is not allowed to import grafana core
|
||||
coreplugins:
|
||||
files:
|
||||
- '**/pkg/tsdb/grafana-pyroscope-datasource/*'
|
||||
|
||||
60
CHANGELOG.md
60
CHANGELOG.md
@@ -1,3 +1,63 @@
|
||||
<!-- 12.0.2+security-01 START -->
|
||||
|
||||
# 12.0.2+security-01 (2025-07-17)
|
||||
|
||||
### Features and enhancements
|
||||
|
||||
- **Profiles:** Stop passing response headers for Grafana-Pyroscope and parca datasources [#106730](https://github.com/grafana/grafana/pull/106730), [@simonswine](https://github.com/simonswine)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- **FlameGraph:** Fix bug for function names that conflict with JavaScript object prototype properties [#106625](https://github.com/grafana/grafana/pull/106625), [@simonswine](https://github.com/simonswine)
|
||||
- **Security:** Fixed CVE-2025-6023
|
||||
- **Security:** Fixed CVE-2025-6197
|
||||
|
||||
<!-- 12.0.2+security-01 END -->
|
||||
<!-- 11.6.3+security-01 START -->
|
||||
|
||||
# 11.6.3+security-01 (2025-07-17)
|
||||
|
||||
### Features and enhancements
|
||||
|
||||
- **Profiles:** Stop passing response headers for Grafana-Pyroscope and parca datasources [#106729](https://github.com/grafana/grafana/pull/106729), [@simonswine](https://github.com/simonswine)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- **FlameGraph:** Fix bug for function names that conflict with JavaScript object prototype properties [#106624](https://github.com/grafana/grafana/pull/106624), [@simonswine](https://github.com/simonswine)
|
||||
- **Security:** Fixed CVE-2025-6023
|
||||
- **Security:** Fixed CVE-2025-6197
|
||||
|
||||
<!-- 11.6.3+security-01 END -->
|
||||
<!-- 11.5.6+security-01 START -->
|
||||
|
||||
# 11.5.6+security-01 (2025-07-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- **Security:** Fixed CVE-2025-6023
|
||||
- **Security:** Fixed CVE-2025-6197
|
||||
|
||||
<!-- 11.5.6+security-01 END -->
|
||||
<!-- 11.4.6+security-01 START -->
|
||||
|
||||
# 11.4.6+security-01 (2025-07-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- **Security:** Fixed CVE-2025-6023
|
||||
- **Security:** Fixed CVE-2025-6197
|
||||
|
||||
<!-- 11.4.6+security-01 END -->
|
||||
<!-- 11.3.8+security-01 START -->
|
||||
|
||||
# 11.3.8+security-01 (2025-07-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- **Security:** Fixed CVE-2025-6023
|
||||
- **Security:** Fixed CVE-2025-6197
|
||||
|
||||
<!-- 11.3.8+security-01 END -->
|
||||
<!-- 12.0.2 START -->
|
||||
|
||||
# 12.0.2 (2025-06-17)
|
||||
|
||||
@@ -1,29 +1,56 @@
|
||||
# Contributing to Grafana
|
||||
# Contribute to Grafana
|
||||
|
||||
Thank you for your interest in contributing to Grafana! We welcome all people who want to contribute in a healthy and constructive manner within our community. To help us create a safe and positive community experience for all, we require all participants to adhere to the [Code of Conduct](CODE_OF_CONDUCT.md).
|
||||
|
||||
This document is a guide to help you through the process of contributing to Grafana.
|
||||
This document is a guide to help you through the process of making technical contributions to Grafana.
|
||||
|
||||
## Become a contributor
|
||||
Whether you're a new contributer or a seasoned veteran we hope these resources help you connect with the community:
|
||||
|
||||
You can contribute to Grafana in several ways. Here are some examples:
|
||||
Interact and be heard:
|
||||
|
||||
- Contribute to the Grafana codebase.
|
||||
- Report and triage bugs.
|
||||
- Develop community plugins and dashboards.
|
||||
- Write technical documentation and blog posts, for users and contributors.
|
||||
- Organize meetups and user groups in your local area.
|
||||
- Help others by answering questions about Grafana.
|
||||
- Forums: Do you have a problem, question, or curiosity? Visit our [forums](https://gra.fan/fromgithubtoforums) for a reservoir of knowledge- submit your own questions and answers!
|
||||
- Meetups: Craving in-person connections without the long journeys? [Join your local Grafana & Friends meetup group](https://gra.fan/githubtomeetup)!
|
||||
- Community Slack: Eager for real-time connections with fellow users? Begin a conversation on [Slack](https://gra.fan/githubtoslack).
|
||||
Learn:
|
||||
- YouTube: From getting started to exploring newer projects like Pyroscope and Beyla, the [Grafana YouTube channel](https://gra.fan/githubtoyoutube) has what you need to get started!
|
||||
- Meetups: Join a [group near you](https://gra.fan/githubtomeetup) to learn from local experts and ask questions in real time.
|
||||
Share your story:
|
||||
- Meetups and blogs: We’d love to feature your OSS Grafana Labs use case or story at an upcoming Grafana & Friends meetup or on the Grafana blog! Submit your idea [here](https://gra.fan/githubtocca) and we’ll connect with you on next steps if accepted.
|
||||
|
||||
## Make technical contributions
|
||||
|
||||
We welcome your technical contributions! Here are some examples:
|
||||
|
||||
- Contribute to the Grafana codebase- check out these [help-wanted issues](<(https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)>)
|
||||
- Develop community [plugins](https://grafana.com/developers/plugin-tools)
|
||||
- Report [bugs](https://github.com/grafana/grafana/issues/new?template=0-bug-report.yaml)
|
||||
- [Triage issues](https://github.com/grafana/grafana/blob/4414b92e93440cc9ed0f281989ee71dc16216a15/contribute/triage-issues.md)
|
||||
- Report [security vulnerabilities](https://github.com/grafana/grafana/security/policy)
|
||||
- Submit a [feature request](https://github.com/grafana/grafana/issues/new?template=1-feature_requests.md)
|
||||
- Write [technical documentation](https://github.com/grafana/grafana/blob/4414b92e93440cc9ed0f281989ee71dc16216a15/contribute/documentation/README.md)
|
||||
|
||||
**Please note:** We do not currently accept contributions for translations. Please do not submit pull requests translating grafana.json files - they will be rejected. We do accept contributions to mark up phrases for translation. See [Internationalization](contribute/internationalization.md).
|
||||
|
||||
For more ways to contribute, check out the [Open Source Guides](https://opensource.guide/how-to-contribute/).
|
||||
### Your first contribution
|
||||
|
||||
Unsure where to begin contributing to Grafana? Start by browsing issues labeled `beginner friendly` or `help wanted`.
|
||||
|
||||
- [Beginner-friendly](https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22beginner+friendly%22) issues are generally straightforward to complete.
|
||||
- [Help wanted](https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) issues are problems we would like the community to help us with regardless of complexity.
|
||||
|
||||
If you're looking to make a code change, see how to set up your environment for [local development](contribute/developer-guide.md).
|
||||
|
||||
When you're ready to contribute, it's time to [create a pull request](/contribute/create-pull-request.md).
|
||||
|
||||
### Develop a plugin
|
||||
|
||||
Developing a Grafana plugin is a fantastic way to share your unique ideas with the community, extend the platform’s capabilities, and make a real impact on how people visualize and understand their data. Check out our guide to creating [plugins](https://grafana.com/developers/plugin-tools)
|
||||
|
||||
### Report bugs
|
||||
|
||||
Before submitting a new issue, try to make sure someone hasn't already reported the problem. Look through the [existing issues](https://github.com/grafana/grafana/issues) for similar issues.
|
||||
|
||||
Report a bug by submitting a [bug report](https://github.com/grafana/grafana/issues/new?labels=type%3A+bug&template=1-bug_report.md). Make sure that you provide as much information as possible on how to reproduce the bug.
|
||||
Report a bug by submitting a [bug report](https://github.com/grafana/grafana/issues/new?template=0-bug-report.yaml). Make sure that you provide as much information as possible on how to reproduce the bug.
|
||||
|
||||
Follow the issue template and add additional information that will help us replicate the problem.
|
||||
|
||||
@@ -38,42 +65,25 @@ For a dashboard related issues:
|
||||
|
||||
For authentication and alerting Grafana server logs are useful.
|
||||
|
||||
#### Security issues
|
||||
|
||||
If you believe you've found a security vulnerability, please read our [security policy](https://github.com/grafana/grafana/security/policy) for more details.
|
||||
|
||||
### Suggest enhancements
|
||||
|
||||
If you have an idea of how to improve Grafana, submit a [feature request](https://github.com/grafana/grafana/issues/new?assignees=&labels=type%2Ffeature-request&projects=&template=1-feature_requests.md).
|
||||
|
||||
We want to make Grafana accessible to even more people. Submit an [accessibility issue](https://github.com/grafana/grafana/issues/new?labels=type%3A+accessibility&template=3-accessibility.md) to help us understand what we can improve.
|
||||
|
||||
### Write documentation
|
||||
|
||||
To edit or write technical content, refer to [Contribute to our documentation](/contribute/documentation/README.md). We welcome your expertise and input as our body of technical content grows.
|
||||
|
||||
### Triage issues
|
||||
|
||||
If you don't have the knowledge or time to code, consider helping with _issue triage_. The community will thank you for saving them time by spending some of yours.
|
||||
|
||||
Read more about the ways you can [Triage issues](/contribute/triage-issues.md).
|
||||
|
||||
### Answering questions
|
||||
#### Security issues
|
||||
|
||||
If you have a question and you can't find the answer in the [documentation](https://grafana.com/docs/), the next step is to ask it on the [community site](https://community.grafana.com/).
|
||||
If you believe you've found a security vulnerability, please read our [security policy](https://github.com/grafana/grafana/security/policy) for more details on reporting.
|
||||
|
||||
It's important to us to help these users, and we'd love your help. Sign up to our [community site](https://community.grafana.com/), and start helping other Grafana users by answering their questions.
|
||||
### Suggest enhancements
|
||||
|
||||
### Your first contribution
|
||||
If you have an idea of how to improve Grafana, submit a [feature request](https://github.com/grafana/grafana/issues/new?template=1-feature_requests.md).
|
||||
|
||||
Unsure where to begin contributing to Grafana? Start by browsing issues labeled `beginner friendly` or `help wanted`.
|
||||
We want to make Grafana accessible to even more people. Submit an [accessibility issue](https://github.com/grafana/grafana/issues/new?template=2-accessibility.md) to help us understand what we can improve.
|
||||
|
||||
- [Beginner-friendly](https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22beginner+friendly%22) issues are generally straightforward to complete.
|
||||
- [Help wanted](https://github.com/grafana/grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) issues are problems we would like the community to help us with regardless of complexity.
|
||||
### Write documentation
|
||||
|
||||
If you're looking to make a code change, see how to set up your environment for [local development](contribute/developer-guide.md).
|
||||
|
||||
When you're ready to contribute, it's time to [create a pull request](/contribute/create-pull-request.md).
|
||||
To edit or write technical content, refer to [Contribute to our documentation](/contribute/documentation/README.md). We welcome your expertise and input as our body of technical content grows.
|
||||
|
||||
#### Contributor License Agreement (CLA)
|
||||
|
||||
|
||||
@@ -69,9 +69,9 @@ COPY go.* ./
|
||||
COPY .bingo .bingo
|
||||
COPY .citools .citools
|
||||
|
||||
# Include vendored dependencies
|
||||
# Copy go dependencies first
|
||||
# If updating this, please also update devenv/frontend-service/backend.dockerfile
|
||||
COPY pkg/util/xorm pkg/util/xorm
|
||||
COPY pkg/apis/secret pkg/apis/secret
|
||||
COPY pkg/apiserver pkg/apiserver
|
||||
COPY pkg/apimachinery pkg/apimachinery
|
||||
COPY pkg/build pkg/build
|
||||
@@ -83,6 +83,7 @@ COPY pkg/storage/unified/apistore pkg/storage/unified/apistore
|
||||
COPY pkg/semconv pkg/semconv
|
||||
COPY pkg/aggregator pkg/aggregator
|
||||
COPY apps/playlist apps/playlist
|
||||
COPY apps/secret apps/secret
|
||||
COPY apps/investigations apps/investigations
|
||||
COPY apps/advisor apps/advisor
|
||||
COPY apps/dashboard apps/dashboard
|
||||
|
||||
14
Makefile
14
Makefile
@@ -279,6 +279,18 @@ run-frontend: deps-js ## Fetch js dependencies and watch frontend for rebuild
|
||||
run-air: ## [Experimental] Build and run backend, and watch for changes. See .air.toml for configuration. Check https://github.com/air-verse/air for installation instructions.
|
||||
air -c .air.toml
|
||||
|
||||
.PHONY: frontend-service-check
|
||||
frontend-service-check:
|
||||
./devenv/frontend-service/local-init.sh
|
||||
|
||||
.PHONY: frontend-service-up
|
||||
frontend-service-up: frontend-service-check
|
||||
tilt up -f devenv/frontend-service/Tiltfile
|
||||
|
||||
.PHONY: frontend-service-down
|
||||
frontend-service-down: frontend-service-check
|
||||
tilt down -f devenv/frontend-service/Tiltfile
|
||||
|
||||
##@ Testing
|
||||
|
||||
.PHONY: test-go
|
||||
@@ -471,7 +483,7 @@ protobuf: ## Compile protobuf definitions
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.5
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.4.0
|
||||
buf generate pkg/plugins/backendplugin/pluginextensionv2 --template pkg/plugins/backendplugin/pluginextensionv2/buf.gen.yaml
|
||||
buf generate pkg/apis/secret/v0alpha1/decrypt --template pkg/apis/secret/v0alpha1/decrypt/buf.gen.yaml
|
||||
buf generate apps/secret/decrypt/v1beta1 --template apps/secret/decrypt/v1beta1/buf.gen.yaml
|
||||
buf generate pkg/storage/unified/proto --template pkg/storage/unified/proto/buf.gen.yaml
|
||||
buf generate pkg/services/authz/proto/v1 --template pkg/services/authz/proto/v1/buf.gen.yaml
|
||||
buf generate pkg/services/ngalert/store/proto/v1 --template pkg/services/ngalert/store/proto/v1/buf.gen.yaml
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
APP_SDK_VERSION := v0.39.2
|
||||
APP_SDK_DIR := $(shell go env GOPATH)/bin/app-sdk-$(APP_SDK_VERSION)
|
||||
APP_SDK_BIN := $(APP_SDK_DIR)/grafana-app-sdk
|
||||
|
||||
.PHONY: install-app-sdk
|
||||
install-app-sdk: $(APP_SDK_BIN) ## Install the Grafana App SDK
|
||||
|
||||
$(APP_SDK_BIN):
|
||||
@echo "Installing Grafana App SDK version $(APP_SDK_VERSION)"
|
||||
@mkdir -p $(APP_SDK_DIR)
|
||||
# The only way to install specific versions of binaries using `go install`
|
||||
# is by setting GOBIN to the directory you want to install the binary to.
|
||||
GOBIN=$(APP_SDK_DIR) go install github.com/grafana/grafana-app-sdk/cmd/grafana-app-sdk@$(APP_SDK_VERSION)
|
||||
@touch $@
|
||||
|
||||
.PHONY: update-app-sdk
|
||||
update-app-sdk: ## Update the Grafana App SDK dependency in go.mod
|
||||
go get github.com/grafana/grafana-app-sdk@$(APP_SDK_VERSION)
|
||||
|
||||
.PHONY: generate
|
||||
generate:
|
||||
@grafana-app-sdk generate -g ./pkg/apis --grouping=group --postprocess --defencoding=none
|
||||
generate: ## Run Grafana App SDK code generation
|
||||
@$(APP_SDK_BIN) generate -g ./pkg/apis --grouping=group --postprocess --defencoding=none
|
||||
|
||||
@@ -3,8 +3,8 @@ module github.com/grafana/grafana/apps/advisor
|
||||
go 1.24.4
|
||||
|
||||
require (
|
||||
github.com/grafana/grafana-app-sdk v0.39.0
|
||||
k8s.io/apimachinery v0.33.1
|
||||
github.com/grafana/grafana-app-sdk v0.39.2
|
||||
k8s.io/apimachinery v0.33.2
|
||||
k8s.io/klog/v2 v2.130.1
|
||||
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff
|
||||
)
|
||||
@@ -33,7 +33,7 @@ require (
|
||||
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/grafana/authlib v0.0.0-20250515162837-2f4a8263eabb // indirect
|
||||
github.com/grafana/grafana-app-sdk/logging v0.38.2 // indirect
|
||||
github.com/grafana/grafana-app-sdk/logging v0.39.1 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
@@ -79,9 +79,9 @@ require (
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/api v0.33.1 // indirect
|
||||
k8s.io/apiextensions-apiserver v0.33.1 // indirect
|
||||
k8s.io/client-go v0.33.1 // indirect
|
||||
k8s.io/api v0.33.2 // indirect
|
||||
k8s.io/apiextensions-apiserver v0.33.2 // indirect
|
||||
k8s.io/client-go v0.33.2 // indirect
|
||||
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
|
||||
|
||||
@@ -63,11 +63,14 @@ github.com/grafana/grafana-app-sdk v0.30.0/go.mod h1:jhfqNIovb+Mes2vdMf9iMCWQkp1
|
||||
github.com/grafana/grafana-app-sdk v0.31.0/go.mod h1:Xw00NL7qpRLo5r3Gn48Bl1Xn2n4eUDI5pYf/wMufKWs=
|
||||
github.com/grafana/grafana-app-sdk v0.35.1/go.mod h1:Zx5MkVppYK+ElSDUAR6+fjzOVo6I/cIgk+ty+LmNOxI=
|
||||
github.com/grafana/grafana-app-sdk v0.39.0/go.mod h1:xRyBQOttgWTc3tGe9pI0upnpEPVhzALf7Mh/61O4zyY=
|
||||
github.com/grafana/grafana-app-sdk v0.39.2 h1:ymfr+1318t+JC9U2OYrzVpGmNG/aJONUmFFu/G98Xh8=
|
||||
github.com/grafana/grafana-app-sdk v0.39.2/go.mod h1:t0m6q561lpoHQCixS9LUHFUhUzDClzNtm7BH60gHVSY=
|
||||
github.com/grafana/grafana-app-sdk/logging v0.29.0 h1:mgbXaAf33aFwqwGVeaX30l8rkeAJH0iACgX5Rn6YkN4=
|
||||
github.com/grafana/grafana-app-sdk/logging v0.29.0/go.mod h1:xy6ZyVXl50Z3DBDLybvBPphbykPhuVNed/VNmen9DQM=
|
||||
github.com/grafana/grafana-app-sdk/logging v0.30.0/go.mod h1:xy6ZyVXl50Z3DBDLybvBPphbykPhuVNed/VNmen9DQM=
|
||||
github.com/grafana/grafana-app-sdk/logging v0.35.0/go.mod h1:Y/bvbDhBiV/tkIle9RW49pgfSPIPSON8Q4qjx3pyqDk=
|
||||
github.com/grafana/grafana-app-sdk/logging v0.38.2/go.mod h1:Y/bvbDhBiV/tkIle9RW49pgfSPIPSON8Q4qjx3pyqDk=
|
||||
github.com/grafana/grafana-app-sdk/logging v0.39.1/go.mod h1:WhDENSnaGHtyVVwZGVnAR7YLvh2xlLDYR3D7E6h7XVk=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 h1:VNqngBF40hVlDloBruUehVYC3ArSgIyScOAyMRqBxRg=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1/go.mod h1:RBRO7fro65R6tjKzYgLAFo0t1QEXY1Dp+i/bvpRiqiQ=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1/go.mod h1:tIxuGz/9mpox++sgp9fJjHO0+q1X9/UOWd798aAm22M=
|
||||
@@ -302,21 +305,25 @@ k8s.io/api v0.32.0/go.mod h1:4LEwHZEf6Q/cG96F3dqR965sYOfmPM7rq81BLgsE0p0=
|
||||
k8s.io/api v0.32.1/go.mod h1:/Yi/BqkuueW1BgpoePYBRdDYfjPF5sgTr5+YqDZra5k=
|
||||
k8s.io/api v0.32.3/go.mod h1:2wEDTXADtm/HA7CCMD8D8bK4yuBUptzaRhYcYEEYA3k=
|
||||
k8s.io/api v0.33.1/go.mod h1:87esjTn9DRSRTD4fWMXamiXxJhpOIREjWOSjsW1kEHw=
|
||||
k8s.io/api v0.33.2/go.mod h1:fhrbphQJSM2cXzCWgqU29xLDuks4mu7ti9vveEnpSXs=
|
||||
k8s.io/apiextensions-apiserver v0.32.0 h1:S0Xlqt51qzzqjKPxfgX1xh4HBZE+p8KKBq+k2SWNOE0=
|
||||
k8s.io/apiextensions-apiserver v0.32.0/go.mod h1:86hblMvN5yxMvZrZFX2OhIHAuFIMJIZ19bTvzkP+Fmw=
|
||||
k8s.io/apiextensions-apiserver v0.32.1/go.mod h1:sxWIGuGiYov7Io1fAS2X06NjMIk5CbRHc2StSmbaQto=
|
||||
k8s.io/apiextensions-apiserver v0.32.3/go.mod h1:8YwcvVRMVzw0r1Stc7XfGAzB/SIVLunqApySV5V7Dss=
|
||||
k8s.io/apiextensions-apiserver v0.33.1/go.mod h1:uNQ52z1A1Gu75QSa+pFK5bcXc4hq7lpOXbweZgi4dqA=
|
||||
k8s.io/apiextensions-apiserver v0.33.2/go.mod h1:IvVanieYsEHJImTKXGP6XCOjTwv2LUMos0YWc9O+QP8=
|
||||
k8s.io/apimachinery v0.32.0 h1:cFSE7N3rmEEtv4ei5X6DaJPHHX0C+upp+v5lVPiEwpg=
|
||||
k8s.io/apimachinery v0.32.0/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
|
||||
k8s.io/apimachinery v0.32.1/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
|
||||
k8s.io/apimachinery v0.32.3/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
|
||||
k8s.io/apimachinery v0.33.1/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
|
||||
k8s.io/apimachinery v0.33.2/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
|
||||
k8s.io/client-go v0.32.0 h1:DimtMcnN/JIKZcrSrstiwvvZvLjG0aSxy8PxN8IChp8=
|
||||
k8s.io/client-go v0.32.0/go.mod h1:boDWvdM1Drk4NJj/VddSLnx59X3OPgwrOo0vGbtq9+8=
|
||||
k8s.io/client-go v0.32.1/go.mod h1:aTTKZY7MdxUaJ/KiUs8D+GssR9zJZi77ZqtzcGXIiDg=
|
||||
k8s.io/client-go v0.32.3/go.mod h1:3v0+3k4IcT9bXTc4V2rt+d2ZPPG700Xy6Oi0Gdl2PaY=
|
||||
k8s.io/client-go v0.33.1/go.mod h1:JAsUrl1ArO7uRVFWfcj6kOomSlCv+JpvIsp6usAGefA=
|
||||
k8s.io/client-go v0.33.2/go.mod h1:9mCgT4wROvL948w6f6ArJNb7yQd7QsvqavDeZHvNmHo=
|
||||
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
|
||||
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
|
||||
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y=
|
||||
|
||||
@@ -24,5 +24,8 @@ type CheckMetadata struct {
|
||||
|
||||
// NewCheckMetadata creates a new CheckMetadata object.
|
||||
func NewCheckMetadata() *CheckMetadata {
|
||||
return &CheckMetadata{}
|
||||
return &CheckMetadata{
|
||||
Finalizers: []string{},
|
||||
Labels: map[string]string{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,11 @@ import (
|
||||
type Check struct {
|
||||
metav1.TypeMeta `json:",inline" yaml:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
|
||||
Spec CheckSpec `json:"spec" yaml:"spec"`
|
||||
CheckStatus CheckStatus `json:"status" yaml:"status"`
|
||||
|
||||
// Spec is the spec of the Check
|
||||
Spec CheckSpec `json:"spec" yaml:"spec"`
|
||||
|
||||
Status CheckStatus `json:"status" yaml:"status"`
|
||||
}
|
||||
|
||||
func (o *Check) GetSpec() any {
|
||||
@@ -37,14 +40,14 @@ func (o *Check) SetSpec(spec any) error {
|
||||
|
||||
func (o *Check) GetSubresources() map[string]any {
|
||||
return map[string]any{
|
||||
"status": o.CheckStatus,
|
||||
"status": o.Status,
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Check) GetSubresource(name string) (any, bool) {
|
||||
switch name {
|
||||
case "status":
|
||||
return o.CheckStatus, true
|
||||
return o.Status, true
|
||||
default:
|
||||
return nil, false
|
||||
}
|
||||
@@ -57,7 +60,7 @@ func (o *Check) SetSubresource(name string, value any) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot set status type %#v, not of type CheckStatus", value)
|
||||
}
|
||||
o.CheckStatus = cast
|
||||
o.Status = cast
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("subresource '%s' does not exist", name)
|
||||
@@ -219,6 +222,20 @@ func (o *Check) DeepCopyObject() runtime.Object {
|
||||
return o.Copy()
|
||||
}
|
||||
|
||||
func (o *Check) DeepCopy() *Check {
|
||||
cpy := &Check{}
|
||||
o.DeepCopyInto(cpy)
|
||||
return cpy
|
||||
}
|
||||
|
||||
func (o *Check) DeepCopyInto(dst *Check) {
|
||||
dst.TypeMeta.APIVersion = o.TypeMeta.APIVersion
|
||||
dst.TypeMeta.Kind = o.TypeMeta.Kind
|
||||
o.ObjectMeta.DeepCopyInto(&dst.ObjectMeta)
|
||||
o.Spec.DeepCopyInto(&dst.Spec)
|
||||
o.Status.DeepCopyInto(&dst.Status)
|
||||
}
|
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.Object = &Check{}
|
||||
|
||||
@@ -262,5 +279,41 @@ func (o *CheckList) SetItems(items []resource.Object) {
|
||||
}
|
||||
}
|
||||
|
||||
func (o *CheckList) DeepCopy() *CheckList {
|
||||
cpy := &CheckList{}
|
||||
o.DeepCopyInto(cpy)
|
||||
return cpy
|
||||
}
|
||||
|
||||
func (o *CheckList) DeepCopyInto(dst *CheckList) {
|
||||
resource.CopyObjectInto(dst, o)
|
||||
}
|
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.ListObject = &CheckList{}
|
||||
|
||||
// Copy methods for all subresource types
|
||||
|
||||
// DeepCopy creates a full deep copy of Spec
|
||||
func (s *CheckSpec) DeepCopy() *CheckSpec {
|
||||
cpy := &CheckSpec{}
|
||||
s.DeepCopyInto(cpy)
|
||||
return cpy
|
||||
}
|
||||
|
||||
// DeepCopyInto deep copies Spec into another Spec object
|
||||
func (s *CheckSpec) DeepCopyInto(dst *CheckSpec) {
|
||||
resource.CopyObjectInto(dst, s)
|
||||
}
|
||||
|
||||
// DeepCopy creates a full deep copy of CheckStatus
|
||||
func (s *CheckStatus) DeepCopy() *CheckStatus {
|
||||
cpy := &CheckStatus{}
|
||||
s.DeepCopyInto(cpy)
|
||||
return cpy
|
||||
}
|
||||
|
||||
// DeepCopyInto deep copies CheckStatus into another CheckStatus object
|
||||
func (s *CheckStatus) DeepCopyInto(dst *CheckStatus) {
|
||||
resource.CopyObjectInto(dst, s)
|
||||
}
|
||||
|
||||
@@ -3,16 +3,18 @@
|
||||
package v0alpha1
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CheckErrorLink struct {
|
||||
// URL to a page with more information about the error
|
||||
Url string `json:"url"`
|
||||
// Human readable error message
|
||||
Message string `json:"message"`
|
||||
type CheckReport struct {
|
||||
// Number of elements analyzed
|
||||
Count int64 `json:"count"`
|
||||
// List of failures
|
||||
Failures []CheckReportFailure `json:"failures"`
|
||||
}
|
||||
|
||||
// NewCheckErrorLink creates a new CheckErrorLink object.
|
||||
func NewCheckErrorLink() *CheckErrorLink {
|
||||
return &CheckErrorLink{}
|
||||
// NewCheckReport creates a new CheckReport object.
|
||||
func NewCheckReport() *CheckReport {
|
||||
return &CheckReport{
|
||||
Failures: []CheckReportFailure{},
|
||||
}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
@@ -33,7 +35,22 @@ type CheckReportFailure struct {
|
||||
|
||||
// NewCheckReportFailure creates a new CheckReportFailure object.
|
||||
func NewCheckReportFailure() *CheckReportFailure {
|
||||
return &CheckReportFailure{}
|
||||
return &CheckReportFailure{
|
||||
Links: []CheckErrorLink{},
|
||||
}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CheckErrorLink struct {
|
||||
// URL to a page with more information about the error
|
||||
Url string `json:"url"`
|
||||
// Human readable error message
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
// NewCheckErrorLink creates a new CheckErrorLink object.
|
||||
func NewCheckErrorLink() *CheckErrorLink {
|
||||
return &CheckErrorLink{}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
@@ -56,7 +73,7 @@ func NewCheckstatusOperatorState() *CheckstatusOperatorState {
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CheckStatus struct {
|
||||
Report CheckV0alpha1StatusReport `json:"report"`
|
||||
Report CheckReport `json:"report"`
|
||||
// operatorStates is a map of operator ID to operator state evaluations.
|
||||
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
|
||||
OperatorStates map[string]CheckstatusOperatorState `json:"operatorStates,omitempty"`
|
||||
@@ -67,7 +84,7 @@ type CheckStatus struct {
|
||||
// NewCheckStatus creates a new CheckStatus object.
|
||||
func NewCheckStatus() *CheckStatus {
|
||||
return &CheckStatus{
|
||||
Report: *NewCheckV0alpha1StatusReport(),
|
||||
Report: *NewCheckReport(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,16 +104,3 @@ const (
|
||||
CheckStatusOperatorStateStateInProgress CheckStatusOperatorStateState = "in_progress"
|
||||
CheckStatusOperatorStateStateFailed CheckStatusOperatorStateState = "failed"
|
||||
)
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CheckV0alpha1StatusReport struct {
|
||||
// Number of elements analyzed
|
||||
Count int64 `json:"count"`
|
||||
// List of failures
|
||||
Failures []CheckReportFailure `json:"failures"`
|
||||
}
|
||||
|
||||
// NewCheckV0alpha1StatusReport creates a new CheckV0alpha1StatusReport object.
|
||||
func NewCheckV0alpha1StatusReport() *CheckV0alpha1StatusReport {
|
||||
return &CheckV0alpha1StatusReport{}
|
||||
}
|
||||
|
||||
@@ -24,5 +24,8 @@ type CheckTypeMetadata struct {
|
||||
|
||||
// NewCheckTypeMetadata creates a new CheckTypeMetadata object.
|
||||
func NewCheckTypeMetadata() *CheckTypeMetadata {
|
||||
return &CheckTypeMetadata{}
|
||||
return &CheckTypeMetadata{
|
||||
Finalizers: []string{},
|
||||
Labels: map[string]string{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,11 @@ import (
|
||||
type CheckType struct {
|
||||
metav1.TypeMeta `json:",inline" yaml:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
|
||||
Spec CheckTypeSpec `json:"spec" yaml:"spec"`
|
||||
CheckTypeStatus CheckTypeStatus `json:"status" yaml:"status"`
|
||||
|
||||
// Spec is the spec of the CheckType
|
||||
Spec CheckTypeSpec `json:"spec" yaml:"spec"`
|
||||
|
||||
Status CheckTypeStatus `json:"status" yaml:"status"`
|
||||
}
|
||||
|
||||
func (o *CheckType) GetSpec() any {
|
||||
@@ -37,14 +40,14 @@ func (o *CheckType) SetSpec(spec any) error {
|
||||
|
||||
func (o *CheckType) GetSubresources() map[string]any {
|
||||
return map[string]any{
|
||||
"status": o.CheckTypeStatus,
|
||||
"status": o.Status,
|
||||
}
|
||||
}
|
||||
|
||||
func (o *CheckType) GetSubresource(name string) (any, bool) {
|
||||
switch name {
|
||||
case "status":
|
||||
return o.CheckTypeStatus, true
|
||||
return o.Status, true
|
||||
default:
|
||||
return nil, false
|
||||
}
|
||||
@@ -57,7 +60,7 @@ func (o *CheckType) SetSubresource(name string, value any) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot set status type %#v, not of type CheckTypeStatus", value)
|
||||
}
|
||||
o.CheckTypeStatus = cast
|
||||
o.Status = cast
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("subresource '%s' does not exist", name)
|
||||
@@ -219,6 +222,20 @@ func (o *CheckType) DeepCopyObject() runtime.Object {
|
||||
return o.Copy()
|
||||
}
|
||||
|
||||
func (o *CheckType) DeepCopy() *CheckType {
|
||||
cpy := &CheckType{}
|
||||
o.DeepCopyInto(cpy)
|
||||
return cpy
|
||||
}
|
||||
|
||||
func (o *CheckType) DeepCopyInto(dst *CheckType) {
|
||||
dst.TypeMeta.APIVersion = o.TypeMeta.APIVersion
|
||||
dst.TypeMeta.Kind = o.TypeMeta.Kind
|
||||
o.ObjectMeta.DeepCopyInto(&dst.ObjectMeta)
|
||||
o.Spec.DeepCopyInto(&dst.Spec)
|
||||
o.Status.DeepCopyInto(&dst.Status)
|
||||
}
|
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.Object = &CheckType{}
|
||||
|
||||
@@ -262,5 +279,41 @@ func (o *CheckTypeList) SetItems(items []resource.Object) {
|
||||
}
|
||||
}
|
||||
|
||||
func (o *CheckTypeList) DeepCopy() *CheckTypeList {
|
||||
cpy := &CheckTypeList{}
|
||||
o.DeepCopyInto(cpy)
|
||||
return cpy
|
||||
}
|
||||
|
||||
func (o *CheckTypeList) DeepCopyInto(dst *CheckTypeList) {
|
||||
resource.CopyObjectInto(dst, o)
|
||||
}
|
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.ListObject = &CheckTypeList{}
|
||||
|
||||
// Copy methods for all subresource types
|
||||
|
||||
// DeepCopy creates a full deep copy of Spec
|
||||
func (s *CheckTypeSpec) DeepCopy() *CheckTypeSpec {
|
||||
cpy := &CheckTypeSpec{}
|
||||
s.DeepCopyInto(cpy)
|
||||
return cpy
|
||||
}
|
||||
|
||||
// DeepCopyInto deep copies Spec into another Spec object
|
||||
func (s *CheckTypeSpec) DeepCopyInto(dst *CheckTypeSpec) {
|
||||
resource.CopyObjectInto(dst, s)
|
||||
}
|
||||
|
||||
// DeepCopy creates a full deep copy of CheckTypeStatus
|
||||
func (s *CheckTypeStatus) DeepCopy() *CheckTypeStatus {
|
||||
cpy := &CheckTypeStatus{}
|
||||
s.DeepCopyInto(cpy)
|
||||
return cpy
|
||||
}
|
||||
|
||||
// DeepCopyInto deep copies CheckTypeStatus into another CheckTypeStatus object
|
||||
func (s *CheckTypeStatus) DeepCopyInto(dst *CheckTypeStatus) {
|
||||
resource.CopyObjectInto(dst, s)
|
||||
}
|
||||
|
||||
@@ -23,5 +23,7 @@ type CheckTypeSpec struct {
|
||||
|
||||
// NewCheckTypeSpec creates a new CheckTypeSpec object.
|
||||
func NewCheckTypeSpec() *CheckTypeSpec {
|
||||
return &CheckTypeSpec{}
|
||||
return &CheckTypeSpec{
|
||||
Steps: []CheckTypeStep{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,16 +3,16 @@ package v0alpha1
|
||||
import "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
const (
|
||||
// Group is the API group used by all kinds in this package
|
||||
Group = "advisor.grafana.app"
|
||||
// Version is the API version used by all kinds in this package
|
||||
Version = "v0alpha1"
|
||||
// APIGroup is the API group used by all kinds in this package
|
||||
APIGroup = "advisor.grafana.app"
|
||||
// APIVersion is the API version used by all kinds in this package
|
||||
APIVersion = "v0alpha1"
|
||||
)
|
||||
|
||||
var (
|
||||
// GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package
|
||||
GroupVersion = schema.GroupVersion{
|
||||
Group: Group,
|
||||
Version: Version,
|
||||
Group: APIGroup,
|
||||
Version: APIVersion,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -15,6 +15,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.Check": schema_pkg_apis_advisor_v0alpha1_Check(ref),
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckErrorLink": schema_pkg_apis_advisor_v0alpha1_CheckErrorLink(ref),
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckList": schema_pkg_apis_advisor_v0alpha1_CheckList(ref),
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReport": schema_pkg_apis_advisor_v0alpha1_CheckReport(ref),
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReportFailure": schema_pkg_apis_advisor_v0alpha1_CheckReportFailure(ref),
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckSpec": schema_pkg_apis_advisor_v0alpha1_CheckSpec(ref),
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckStatus": schema_pkg_apis_advisor_v0alpha1_CheckStatus(ref),
|
||||
@@ -24,7 +25,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypeStatus": schema_pkg_apis_advisor_v0alpha1_CheckTypeStatus(ref),
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypeStep": schema_pkg_apis_advisor_v0alpha1_CheckTypeStep(ref),
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypestatusOperatorState": schema_pkg_apis_advisor_v0alpha1_CheckTypestatusOperatorState(ref),
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckV0alpha1StatusReport": schema_pkg_apis_advisor_v0alpha1_CheckV0alpha1StatusReport(ref),
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckstatusOperatorState": schema_pkg_apis_advisor_v0alpha1_CheckstatusOperatorState(ref),
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,9 @@ func schema_pkg_apis_advisor_v0alpha1_Check(ref common.ReferenceCallback) common
|
||||
},
|
||||
"spec": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckSpec"),
|
||||
Description: "Spec is the spec of the Check",
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckSpec"),
|
||||
},
|
||||
},
|
||||
"status": {
|
||||
@@ -153,6 +154,43 @@ func schema_pkg_apis_advisor_v0alpha1_CheckList(ref common.ReferenceCallback) co
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_advisor_v0alpha1_CheckReport(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"count": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Number of elements analyzed",
|
||||
Default: 0,
|
||||
Type: []string{"integer"},
|
||||
Format: "int64",
|
||||
},
|
||||
},
|
||||
"failures": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "List of failures",
|
||||
Type: []string{"array"},
|
||||
Items: &spec.SchemaOrArray{
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReportFailure"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"count", "failures"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReportFailure"},
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_advisor_v0alpha1_CheckReportFailure(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
@@ -258,7 +296,7 @@ func schema_pkg_apis_advisor_v0alpha1_CheckStatus(ref common.ReferenceCallback)
|
||||
"report": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckV0alpha1StatusReport"),
|
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReport"),
|
||||
},
|
||||
},
|
||||
"operatorStates": {
|
||||
@@ -296,7 +334,7 @@ func schema_pkg_apis_advisor_v0alpha1_CheckStatus(ref common.ReferenceCallback)
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckV0alpha1StatusReport", "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckstatusOperatorState"},
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReport", "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckstatusOperatorState"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,8 +366,9 @@ func schema_pkg_apis_advisor_v0alpha1_CheckType(ref common.ReferenceCallback) co
|
||||
},
|
||||
"spec": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypeSpec"),
|
||||
Description: "Spec is the spec of the CheckType",
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckTypeSpec"),
|
||||
},
|
||||
},
|
||||
"status": {
|
||||
@@ -566,43 +605,6 @@ func schema_pkg_apis_advisor_v0alpha1_CheckTypestatusOperatorState(ref common.Re
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_advisor_v0alpha1_CheckV0alpha1StatusReport(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"count": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Number of elements analyzed",
|
||||
Default: 0,
|
||||
Type: []string{"integer"},
|
||||
Format: "int64",
|
||||
},
|
||||
},
|
||||
"failures": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "List of failures",
|
||||
Type: []string{"array"},
|
||||
Items: &spec.SchemaOrArray{
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReportFailure"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"count", "failures"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckReportFailure"},
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_advisor_v0alpha1_CheckstatusOperatorState(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
|
||||
@@ -7,15 +7,19 @@ package apis
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/grafana/grafana-app-sdk/app"
|
||||
"github.com/grafana/grafana-app-sdk/resource"
|
||||
|
||||
v0alpha1 "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1"
|
||||
)
|
||||
|
||||
var (
|
||||
rawSchemaCheckv0alpha1 = []byte(`{"spec":{"properties":{"data":{"additionalProperties":{"type":"string"},"description":"Generic data input that a check can receive","type":"object"}},"type":"object"},"status":{"properties":{"additionalFields":{"description":"additionalFields is reserved for future use","type":"object","x-kubernetes-preserve-unknown-fields":true},"operatorStates":{"additionalProperties":{"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"description":"details contains any extra information that is operator-specific","type":"object","x-kubernetes-preserve-unknown-fields":true},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"},"report":{"properties":{"count":{"description":"Number of elements analyzed","type":"integer"},"failures":{"description":"List of failures","items":{"properties":{"item":{"description":"Human readable identifier of the item that failed","type":"string"},"itemID":{"description":"ID of the item that failed","type":"string"},"links":{"description":"Links to actions that can be taken to resolve the failure","items":{"properties":{"message":{"description":"Human readable error message","type":"string"},"url":{"description":"URL to a page with more information about the error","type":"string"}},"required":["url","message"],"type":"object"},"type":"array"},"moreInfo":{"description":"More information about the failure, not meant to be displayed to the user. Used for LLM suggestions.","type":"string"},"severity":{"description":"Severity of the failure","enum":["high","low"],"type":"string"},"stepID":{"description":"Step ID that the failure is associated with","type":"string"}},"required":["severity","stepID","item","itemID","links"],"type":"object"},"type":"array"}},"required":["count","failures"],"type":"object"}},"required":["report"],"type":"object","x-kubernetes-preserve-unknown-fields":true}}`)
|
||||
rawSchemaCheckv0alpha1 = []byte(`{"spec":{"properties":{"data":{"additionalProperties":{"type":"string"},"description":"Generic data input that a check can receive","type":"object"}},"type":"object"},"status":{"properties":{"additionalFields":{"description":"additionalFields is reserved for future use","type":"object","x-kubernetes-preserve-unknown-fields":true},"operatorStates":{"additionalProperties":{"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"description":"details contains any extra information that is operator-specific","type":"object","x-kubernetes-preserve-unknown-fields":true},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"},"report":{"properties":{"count":{"description":"Number of elements analyzed","type":"integer"},"failures":{"description":"List of failures","items":{"properties":{"item":{"description":"Human readable identifier of the item that failed","type":"string"},"itemID":{"description":"ID of the item that failed","type":"string"},"links":{"description":"Links to actions that can be taken to resolve the failure","items":{"properties":{"message":{"description":"Human readable error message","type":"string"},"url":{"description":"URL to a page with more information about the error","type":"string"}},"required":["url","message"],"type":"object"},"type":"array"},"moreInfo":{"description":"More information about the failure, not meant to be displayed to the user. Used for LLM suggestions.","type":"string"},"severity":{"description":"Severity of the failure","enum":["high","low"],"type":"string"},"stepID":{"description":"Step ID that the failure is associated with","type":"string"}},"required":["severity","stepID","item","itemID","links"],"type":"object"},"type":"array"}},"required":["count","failures"],"type":"object"}},"required":["report"],"type":"object"}}`)
|
||||
versionSchemaCheckv0alpha1 app.VersionSchema
|
||||
_ = json.Unmarshal(rawSchemaCheckv0alpha1, &versionSchemaCheckv0alpha1)
|
||||
rawSchemaCheckTypev0alpha1 = []byte(`{"spec":{"properties":{"name":{"type":"string"},"steps":{"items":{"properties":{"description":{"type":"string"},"resolution":{"type":"string"},"stepID":{"type":"string"},"title":{"type":"string"}},"required":["title","description","stepID","resolution"],"type":"object"},"type":"array"}},"required":["name","steps"],"type":"object"},"status":{"properties":{"additionalFields":{"description":"additionalFields is reserved for future use","type":"object","x-kubernetes-preserve-unknown-fields":true},"operatorStates":{"additionalProperties":{"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"description":"details contains any extra information that is operator-specific","type":"object","x-kubernetes-preserve-unknown-fields":true},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"}},"type":"object","x-kubernetes-preserve-unknown-fields":true}}`)
|
||||
rawSchemaCheckTypev0alpha1 = []byte(`{"spec":{"properties":{"name":{"type":"string"},"steps":{"items":{"properties":{"description":{"type":"string"},"resolution":{"type":"string"},"stepID":{"type":"string"},"title":{"type":"string"}},"required":["title","description","stepID","resolution"],"type":"object"},"type":"array"}},"required":["name","steps"],"type":"object"},"status":{"properties":{"additionalFields":{"description":"additionalFields is reserved for future use","type":"object","x-kubernetes-preserve-unknown-fields":true},"operatorStates":{"additionalProperties":{"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"description":"details contains any extra information that is operator-specific","type":"object","x-kubernetes-preserve-unknown-fields":true},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"}},"type":"object"}}`)
|
||||
versionSchemaCheckTypev0alpha1 app.VersionSchema
|
||||
_ = json.Unmarshal(rawSchemaCheckTypev0alpha1, &versionSchemaCheckTypev0alpha1)
|
||||
)
|
||||
@@ -58,12 +62,6 @@ var appManifestData = app.ManifestData{
|
||||
},
|
||||
}
|
||||
|
||||
func jsonToMap(j string) map[string]any {
|
||||
m := make(map[string]any)
|
||||
json.Unmarshal([]byte(j), &j)
|
||||
return m
|
||||
}
|
||||
|
||||
func LocalManifest() app.Manifest {
|
||||
return app.NewEmbeddedManifest(appManifestData)
|
||||
}
|
||||
@@ -71,3 +69,15 @@ func LocalManifest() app.Manifest {
|
||||
func RemoteManifest() app.Manifest {
|
||||
return app.NewAPIServerManifest("advisor")
|
||||
}
|
||||
|
||||
var kindVersionToGoType = map[string]resource.Kind{
|
||||
"Check/v0alpha1": v0alpha1.CheckKind(),
|
||||
"CheckType/v0alpha1": v0alpha1.CheckTypeKind(),
|
||||
}
|
||||
|
||||
// ManifestGoTypeAssociator returns the associated resource.Kind instance for a given Kind and Version, if one exists.
|
||||
// If there is no association for the provided Kind and Version, exists will return false.
|
||||
func ManifestGoTypeAssociator(kind, version string) (goType resource.Kind, exists bool) {
|
||||
goType, exists = kindVersionToGoType[fmt.Sprintf("%s/%s", kind, version)]
|
||||
return goType, exists
|
||||
}
|
||||
|
||||
@@ -106,3 +106,25 @@ func SetStatusAnnotation(ctx context.Context, client resource.Client, obj resour
|
||||
}},
|
||||
}, resource.PatchOptions{}, obj)
|
||||
}
|
||||
|
||||
func SetAnnotations(ctx context.Context, client resource.Client, obj resource.Object, annotations map[string]string) error {
|
||||
return client.PatchInto(ctx, obj.GetStaticMetadata().Identifier(), resource.PatchRequest{
|
||||
Operations: []resource.PatchOperation{{
|
||||
Operation: resource.PatchOpAdd,
|
||||
Path: "/metadata/annotations",
|
||||
Value: annotations,
|
||||
}},
|
||||
}, resource.PatchOptions{}, obj)
|
||||
}
|
||||
|
||||
func SetStatus(ctx context.Context, client resource.Client, obj resource.Object, status any) error {
|
||||
return client.PatchInto(ctx, obj.GetStaticMetadata().Identifier(), resource.PatchRequest{
|
||||
Operations: []resource.PatchOperation{{
|
||||
Operation: resource.PatchOpAdd,
|
||||
Path: "/status",
|
||||
Value: status,
|
||||
}},
|
||||
}, resource.PatchOptions{
|
||||
Subresource: "status",
|
||||
}, obj)
|
||||
}
|
||||
|
||||
@@ -78,28 +78,21 @@ func processCheck(ctx context.Context, log logging.Logger, client resource.Clien
|
||||
return fmt.Errorf("error running steps: %w", err)
|
||||
}
|
||||
|
||||
report := &advisorv0alpha1.CheckV0alpha1StatusReport{
|
||||
report := &advisorv0alpha1.CheckReport{
|
||||
Failures: failures,
|
||||
Count: int64(len(items)),
|
||||
}
|
||||
c.Status.Report = *report
|
||||
err = checks.SetStatus(ctx, client, obj, c.Status)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Set the status annotation to processed and annotate the steps ignored
|
||||
annotations := checks.AddAnnotations(ctx, obj, map[string]string{
|
||||
checks.StatusAnnotation: checks.StatusAnnotationProcessed,
|
||||
checks.IgnoreStepsAnnotationList: checkType.GetAnnotations()[checks.IgnoreStepsAnnotationList],
|
||||
})
|
||||
return client.PatchInto(ctx, obj.GetStaticMetadata().Identifier(), resource.PatchRequest{
|
||||
Operations: []resource.PatchOperation{
|
||||
{
|
||||
Operation: resource.PatchOpAdd,
|
||||
Path: "/status/report",
|
||||
Value: *report,
|
||||
}, {
|
||||
Operation: resource.PatchOpAdd,
|
||||
Path: "/metadata/annotations",
|
||||
Value: annotations,
|
||||
},
|
||||
},
|
||||
}, resource.PatchOptions{}, obj)
|
||||
return checks.SetAnnotations(ctx, client, obj, annotations)
|
||||
}
|
||||
|
||||
func processCheckRetry(ctx context.Context, log logging.Logger, client resource.Client, typesClient resource.Client, obj resource.Object, check checks.Check) error {
|
||||
@@ -157,7 +150,7 @@ func processCheckRetry(ctx context.Context, log logging.Logger, client resource.
|
||||
}
|
||||
}
|
||||
// Pull failures from the report for the items to retry
|
||||
c.CheckStatus.Report.Failures = slices.DeleteFunc(c.CheckStatus.Report.Failures, func(f advisorv0alpha1.CheckReportFailure) bool {
|
||||
c.Status.Report.Failures = slices.DeleteFunc(c.Status.Report.Failures, func(f advisorv0alpha1.CheckReportFailure) bool {
|
||||
if f.ItemID == itemToRetry {
|
||||
for _, newFailure := range failures {
|
||||
if newFailure.StepID == f.StepID {
|
||||
@@ -171,19 +164,13 @@ func processCheckRetry(ctx context.Context, log logging.Logger, client resource.
|
||||
// Failure not in the list of items to retry, keep it
|
||||
return false
|
||||
})
|
||||
err = checks.SetStatus(ctx, client, obj, c.Status)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Delete the retry annotation to mark the check as processed
|
||||
annotations := checks.DeleteAnnotations(ctx, obj, []string{checks.RetryAnnotation})
|
||||
return client.PatchInto(ctx, obj.GetStaticMetadata().Identifier(), resource.PatchRequest{
|
||||
Operations: []resource.PatchOperation{{
|
||||
Operation: resource.PatchOpAdd,
|
||||
Path: "/status/report",
|
||||
Value: c.CheckStatus.Report,
|
||||
}, {
|
||||
Operation: resource.PatchOpAdd,
|
||||
Path: "/metadata/annotations",
|
||||
Value: annotations,
|
||||
}},
|
||||
}, resource.PatchOptions{}, obj)
|
||||
return checks.SetAnnotations(ctx, client, obj, annotations)
|
||||
}
|
||||
|
||||
func runStepsInParallel(ctx context.Context, log logging.Logger, spec *advisorv0alpha1.CheckSpec, steps []checks.Step, items []any) ([]advisorv0alpha1.CheckReportFailure, error) {
|
||||
|
||||
@@ -95,9 +95,9 @@ func TestProcessMultipleCheckItems(t *testing.T) {
|
||||
err = processCheck(ctx, logging.DefaultLogger, client, typesClient, obj, check)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, checks.StatusAnnotationProcessed, obj.GetAnnotations()[checks.StatusAnnotation])
|
||||
r := client.lastValue.(advisorv0alpha1.CheckV0alpha1StatusReport)
|
||||
assert.Equal(t, r.Count, int64(100))
|
||||
assert.Len(t, r.Failures, 50)
|
||||
r := client.values[0].(advisorv0alpha1.CheckStatus)
|
||||
assert.Equal(t, r.Report.Count, int64(100))
|
||||
assert.Len(t, r.Report.Failures, 50)
|
||||
}
|
||||
|
||||
func TestProcessCheck_AlreadyProcessed(t *testing.T) {
|
||||
@@ -231,7 +231,7 @@ func TestProcessCheckRetry_SkipMissingItem(t *testing.T) {
|
||||
checks.RetryAnnotation: "item",
|
||||
checks.StatusAnnotation: checks.StatusAnnotationProcessed,
|
||||
})
|
||||
obj.CheckStatus.Report.Failures = []advisorv0alpha1.CheckReportFailure{
|
||||
obj.Status.Report.Failures = []advisorv0alpha1.CheckReportFailure{
|
||||
{
|
||||
ItemID: "item",
|
||||
StepID: "step",
|
||||
@@ -254,7 +254,7 @@ func TestProcessCheckRetry_SkipMissingItem(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, checks.StatusAnnotationProcessed, obj.GetAnnotations()[checks.StatusAnnotation])
|
||||
assert.Empty(t, obj.GetAnnotations()[checks.RetryAnnotation])
|
||||
assert.Empty(t, obj.CheckStatus.Report.Failures)
|
||||
assert.Empty(t, obj.Status.Report.Failures)
|
||||
}
|
||||
|
||||
func TestProcessCheckRetry_Success(t *testing.T) {
|
||||
@@ -263,7 +263,7 @@ func TestProcessCheckRetry_Success(t *testing.T) {
|
||||
checks.RetryAnnotation: "item",
|
||||
checks.StatusAnnotation: checks.StatusAnnotationProcessed,
|
||||
})
|
||||
obj.CheckStatus.Report.Failures = []advisorv0alpha1.CheckReportFailure{
|
||||
obj.Status.Report.Failures = []advisorv0alpha1.CheckReportFailure{
|
||||
{
|
||||
ItemID: "item",
|
||||
StepID: "step",
|
||||
@@ -286,16 +286,16 @@ func TestProcessCheckRetry_Success(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, checks.StatusAnnotationProcessed, obj.GetAnnotations()[checks.StatusAnnotation])
|
||||
assert.Empty(t, obj.GetAnnotations()[checks.RetryAnnotation])
|
||||
assert.Empty(t, obj.CheckStatus.Report.Failures)
|
||||
assert.Empty(t, obj.Status.Report.Failures)
|
||||
}
|
||||
|
||||
type mockClient struct {
|
||||
resource.Client
|
||||
lastValue any
|
||||
values []any
|
||||
}
|
||||
|
||||
func (m *mockClient) PatchInto(ctx context.Context, id resource.Identifier, req resource.PatchRequest, opts resource.PatchOptions, obj resource.Object) error {
|
||||
m.lastValue = req.Operations[0].Value
|
||||
m.values = append(m.values, req.Operations[0].Value)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ update-app-sdk: ## Update the Grafana App SDK dependency in go.mod
|
||||
go mod tidy
|
||||
|
||||
.PHONY: generate
|
||||
generate: install-app-sdk update-app-sdk
|
||||
generate: do-generate ## Run Grafana App SDK code generation
|
||||
|
||||
.PHONY: do-generate
|
||||
do-generate: install-app-sdk update-app-sdk
|
||||
## --defencoding=none and noschemasinmanifest are needed to avoid infinite loop while generating recursive models (see routingtree.cue)
|
||||
@$(APP_SDK_BIN) generate --grouping=group --gogenpath=./pkg/apis --defencoding=none --postprocess --noschemasinmanifest
|
||||
|
||||
@@ -89,9 +89,9 @@ require (
|
||||
golang.org/x/text v0.26.0 // indirect
|
||||
golang.org/x/time v0.11.0 // indirect
|
||||
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20250303144028-a0af3efb3deb // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 // indirect
|
||||
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
|
||||
google.golang.org/grpc v1.73.0 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
|
||||
|
||||
@@ -317,12 +317,12 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20250303144028-a0af3efb3deb h1:ITgPrl429bc6+2ZraNSzMDk3I95nmQln2fuPstKwFDE=
|
||||
google.golang.org/genproto v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:sAo5UzpjUwgFBCzupwhcLcxHVDK7vG5IqI30YnwX2eE=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 h1:Kog3KlB4xevJlAcbbbzPfRG0+X9fdoGM+UBRKVz6Wr0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237/go.mod h1:ezi0AVyMKDWy5xAncvjLWH7UcLBB5n7y2fQ8MzjJcto=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 h1:cJfm9zPbe1e873mHJzmQ1nwVEeRDU/T1wXDK2kUSU34=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 h1:rHWScKit0gvAPuOnu87KpaYtjK5zBMLcULh7gxkCXu4=
|
||||
google.golang.org/genproto v0.0.0-20250603155806-513f23925822/go.mod h1:HubltRL7rMh0LfnQPkMH4NPDFEWp0jw3vixw7jEM53s=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 h1:oWVWY3NzT7KJppx2UKhKmzPq4SRe0LdCijVRwvGeikY=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822/go.mod h1:h3c4v36UTKzUiuaOKQ6gr3S+0hovBtUrXzTG/i3+XEc=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 h1:fc6jSaCT0vBduLYZHYrBBNY4dsWuvgyff9noRNDdBeE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||
google.golang.org/grpc v1.18.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
// schema is unexported to prevent accidental overwrites
|
||||
var (
|
||||
schemaReceiver = resource.NewSimpleSchema("notifications.alerting.grafana.app", "v0alpha1", &Receiver{}, &ReceiverList{}, resource.WithKind("Receiver"),
|
||||
resource.WithPlural("receivers"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{resource.SelectableField{
|
||||
resource.WithPlural("receivers"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{{
|
||||
FieldSelector: "spec.title",
|
||||
FieldValueFunc: func(o resource.Object) (string, error) {
|
||||
cast, ok := o.(*Receiver)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
// schema is unexported to prevent accidental overwrites
|
||||
var (
|
||||
schemaTemplateGroup = resource.NewSimpleSchema("notifications.alerting.grafana.app", "v0alpha1", &TemplateGroup{}, &TemplateGroupList{}, resource.WithKind("TemplateGroup"),
|
||||
resource.WithPlural("templategroups"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{resource.SelectableField{
|
||||
resource.WithPlural("templategroups"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{{
|
||||
FieldSelector: "spec.title",
|
||||
FieldValueFunc: func(o resource.Object) (string, error) {
|
||||
cast, ok := o.(*TemplateGroup)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
// schema is unexported to prevent accidental overwrites
|
||||
var (
|
||||
schemaTimeInterval = resource.NewSimpleSchema("notifications.alerting.grafana.app", "v0alpha1", &TimeInterval{}, &TimeIntervalList{}, resource.WithKind("TimeInterval"),
|
||||
resource.WithPlural("timeintervals"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{resource.SelectableField{
|
||||
resource.WithPlural("timeintervals"), resource.WithScope(resource.NamespacedScope), resource.WithSelectableFields([]resource.SelectableField{{
|
||||
FieldSelector: "spec.name",
|
||||
FieldValueFunc: func(o resource.Object) (string, error) {
|
||||
cast, ok := o.(*TimeInterval)
|
||||
|
||||
@@ -14,8 +14,6 @@ import (
|
||||
v0alpha1 "github.com/grafana/grafana/apps/alerting/notifications/pkg/apis/alerting/v0alpha1"
|
||||
)
|
||||
|
||||
var ()
|
||||
|
||||
var appManifestData = app.ManifestData{
|
||||
AppName: "alerting",
|
||||
Group: "notifications.alerting.grafana.app",
|
||||
|
||||
@@ -60,3 +60,10 @@ post-generate-cleanup: ## Clean up the generated code
|
||||
@echo "// To sync changes, run: make generate in apps/dashboard" >> ./pkg/apis/dashboard/v2alpha1/dashboard_spec.cue
|
||||
@echo "" >> ./pkg/apis/dashboard/v2alpha1/dashboard_spec.cue
|
||||
@cat ./kinds/v2alpha1/dashboard_spec.cue >> ./pkg/apis/dashboard/v2alpha1/dashboard_spec.cue
|
||||
|
||||
# Copy dashboard/v2alpha2 spec so we can use it for schema validation
|
||||
@echo "// This file is managed by grafana-app-sdk - DO NOT EDIT MANUALLY" > ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue
|
||||
@echo "// Source: apps/dashboard/kinds/v2alpha2/dashboard_spec.cue" >> ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue
|
||||
@echo "// To sync changes, run: make generate in apps/dashboard" >> ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue
|
||||
@echo "" >> ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue
|
||||
@cat ./kinds/v2alpha2/dashboard_spec.cue >> ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue
|
||||
|
||||
@@ -116,8 +116,8 @@ require (
|
||||
golang.org/x/time v0.11.0 // indirect
|
||||
golang.org/x/tools v0.34.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
|
||||
google.golang.org/grpc v1.73.0 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect
|
||||
|
||||
@@ -357,10 +357,10 @@ golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhS
|
||||
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
|
||||
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 h1:Kog3KlB4xevJlAcbbbzPfRG0+X9fdoGM+UBRKVz6Wr0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237/go.mod h1:ezi0AVyMKDWy5xAncvjLWH7UcLBB5n7y2fQ8MzjJcto=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 h1:cJfm9zPbe1e873mHJzmQ1nwVEeRDU/T1wXDK2kUSU34=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 h1:oWVWY3NzT7KJppx2UKhKmzPq4SRe0LdCijVRwvGeikY=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822/go.mod h1:h3c4v36UTKzUiuaOKQ6gr3S+0hovBtUrXzTG/i3+XEc=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 h1:fc6jSaCT0vBduLYZHYrBBNY4dsWuvgyff9noRNDdBeE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||
google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok=
|
||||
google.golang.org/grpc v1.73.0/go.mod h1:50sbHOUqWoCQGI8V2HQLJM0B+LMlIUjNSZmow7EVBQc=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
|
||||
@@ -3,7 +3,8 @@ package kinds
|
||||
import (
|
||||
v0 "github.com/grafana/grafana/sdkkinds/dashboard/v0alpha1"
|
||||
v1 "github.com/grafana/grafana/sdkkinds/dashboard/v1beta1"
|
||||
v2 "github.com/grafana/grafana/sdkkinds/dashboard/v2alpha1"
|
||||
v2alpha1 "github.com/grafana/grafana/sdkkinds/dashboard/v2alpha1"
|
||||
v2alpha2 "github.com/grafana/grafana/sdkkinds/dashboard/v2alpha2"
|
||||
)
|
||||
|
||||
// Status is the shared status of all dashboard versions.
|
||||
@@ -63,7 +64,13 @@ dashboard: {
|
||||
}
|
||||
"v2alpha1": {
|
||||
schema: {
|
||||
spec: v2.DashboardSpec
|
||||
spec: v2alpha1.DashboardSpec
|
||||
status: DashboardStatus
|
||||
}
|
||||
}
|
||||
"v2alpha2": {
|
||||
schema: {
|
||||
spec: v2alpha2.DashboardSpec
|
||||
status: DashboardStatus
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,8 +111,6 @@ DashboardLink: {
|
||||
keepTime: bool | *false
|
||||
}
|
||||
|
||||
// Keeping this for backwards compatibility for GroupByVariableSpec and AdhocVariableSpec
|
||||
// This type is widely used in the codebase and changing it will have a big impact
|
||||
DataSourceRef: {
|
||||
// The plugin type-id
|
||||
type?: string
|
||||
@@ -387,7 +385,8 @@ VizConfigKind: {
|
||||
}
|
||||
|
||||
AnnotationQuerySpec: {
|
||||
query: DataQueryKind
|
||||
datasource?: DataSourceRef
|
||||
query?: DataQueryKind
|
||||
enable: bool
|
||||
hide: bool
|
||||
iconColor: string
|
||||
@@ -413,19 +412,15 @@ QueryOptionsSpec: {
|
||||
}
|
||||
|
||||
DataQueryKind: {
|
||||
kind: "DataQuery"
|
||||
group: string
|
||||
version: string | *"v0"
|
||||
// New type for datasource reference
|
||||
// Not creating a new type until we figure out how to handle DS refs for group by, adhoc, and every place that uses DataSourceRef in TS.
|
||||
datasource?: {
|
||||
name?: string
|
||||
}
|
||||
// The kind of a DataQueryKind is the datasource type
|
||||
kind: string
|
||||
spec: [string]: _
|
||||
}
|
||||
|
||||
PanelQuerySpec: {
|
||||
query: DataQueryKind
|
||||
datasource?: DataSourceRef
|
||||
|
||||
refId: string
|
||||
hidden: bool
|
||||
}
|
||||
@@ -728,6 +723,7 @@ QueryVariableSpec: {
|
||||
refresh: VariableRefresh
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
datasource?: DataSourceRef
|
||||
query: DataQueryKind
|
||||
regex: string | *""
|
||||
sort: VariableSort
|
||||
@@ -738,6 +734,8 @@ QueryVariableSpec: {
|
||||
allValue?: string
|
||||
placeholder?: string
|
||||
allowCustomValue: bool | *true
|
||||
staticOptions?: [...VariableOption]
|
||||
staticOptionsOrder?: "before" | "after" | "sorted"
|
||||
}
|
||||
|
||||
// Query variable kind
|
||||
|
||||
964
apps/dashboard/kinds/v2alpha2/dashboard_spec.cue
Normal file
964
apps/dashboard/kinds/v2alpha2/dashboard_spec.cue
Normal file
@@ -0,0 +1,964 @@
|
||||
package v2alpha2
|
||||
|
||||
DashboardSpec: {
|
||||
annotations: [...AnnotationQueryKind] | *[]
|
||||
|
||||
// Configuration of dashboard cursor sync behavior.
|
||||
// "Off" for no shared crosshair or tooltip (default).
|
||||
// "Crosshair" for shared crosshair.
|
||||
// "Tooltip" for shared crosshair AND shared tooltip.
|
||||
cursorSync: DashboardCursorSync
|
||||
|
||||
// Description of dashboard.
|
||||
description?: string
|
||||
|
||||
// Whether a dashboard is editable or not.
|
||||
editable?: bool | *true
|
||||
|
||||
elements: [ElementReference.name]: Element | *{}
|
||||
|
||||
layout: GridLayoutKind | RowsLayoutKind | AutoGridLayoutKind | TabsLayoutKind
|
||||
|
||||
// Links with references to other dashboards or external websites.
|
||||
links: [...DashboardLink] | *[]
|
||||
|
||||
// When set to true, the dashboard will redraw panels at an interval matching the pixel width.
|
||||
// This will keep data "moving left" regardless of the query refresh rate. This setting helps
|
||||
// avoid dashboards presenting stale live data.
|
||||
liveNow?: bool
|
||||
|
||||
// When set to true, the dashboard will load all panels in the dashboard when it's loaded.
|
||||
preload: bool | *false
|
||||
|
||||
// Plugins only. The version of the dashboard installed together with the plugin.
|
||||
// This is used to determine if the dashboard should be updated when the plugin is updated.
|
||||
revision?: uint16
|
||||
|
||||
// Tags associated with dashboard.
|
||||
tags: [...string] | *[]
|
||||
|
||||
timeSettings: TimeSettingsSpec
|
||||
|
||||
// Title of dashboard.
|
||||
title: string
|
||||
|
||||
// Configured template variables.
|
||||
variables: [...VariableKind] | *[]
|
||||
}
|
||||
|
||||
// Supported dashboard elements
|
||||
Element: PanelKind | LibraryPanelKind // |* more element types in the future
|
||||
|
||||
LibraryPanelKind: {
|
||||
kind: "LibraryPanel"
|
||||
spec: LibraryPanelKindSpec
|
||||
}
|
||||
|
||||
LibraryPanelKindSpec: {
|
||||
// Panel ID for the library panel in the dashboard
|
||||
id: number
|
||||
// Title for the library panel in the dashboard
|
||||
title: string
|
||||
|
||||
libraryPanel: LibraryPanelRef
|
||||
}
|
||||
|
||||
// A library panel is a reusable panel that you can use in any dashboard.
|
||||
// When you make a change to a library panel, that change propagates to all instances of where the panel is used.
|
||||
// Library panels streamline reuse of panels across multiple dashboards.
|
||||
LibraryPanelRef: {
|
||||
// Library panel name
|
||||
name: string
|
||||
// Library panel uid
|
||||
uid: string
|
||||
}
|
||||
|
||||
AnnotationPanelFilter: {
|
||||
// Should the specified panels be included or excluded
|
||||
exclude?: bool | *false
|
||||
|
||||
// Panel IDs that should be included or excluded
|
||||
ids: [...uint32]
|
||||
}
|
||||
|
||||
// "Off" for no shared crosshair or tooltip (default).
|
||||
// "Crosshair" for shared crosshair.
|
||||
// "Tooltip" for shared crosshair AND shared tooltip.
|
||||
DashboardCursorSync: "Crosshair" | "Tooltip" | *"Off"
|
||||
|
||||
// Links with references to other dashboards or external resources
|
||||
DashboardLink: {
|
||||
// Title to display with the link
|
||||
title: string
|
||||
// Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource)
|
||||
// FIXME: The type is generated as `type: DashboardLinkType | dashboardLinkType.Link;` but it should be `type: DashboardLinkType`
|
||||
type: DashboardLinkType
|
||||
// Icon name to be displayed with the link
|
||||
icon: string
|
||||
// Tooltip to display when the user hovers their mouse over it
|
||||
tooltip: string
|
||||
// Link URL. Only required/valid if the type is link
|
||||
url?: string
|
||||
// List of tags to limit the linked dashboards. If empty, all dashboards will be displayed. Only valid if the type is dashboards
|
||||
tags: [...string] | *[]
|
||||
// If true, all dashboards links will be displayed in a dropdown. If false, all dashboards links will be displayed side by side. Only valid if the type is dashboards
|
||||
asDropdown: bool | *false
|
||||
// If true, the link will be opened in a new tab
|
||||
targetBlank: bool | *false
|
||||
// If true, includes current template variables values in the link as query params
|
||||
includeVars: bool | *false
|
||||
// If true, includes current time range in the link as query params
|
||||
keepTime: bool | *false
|
||||
}
|
||||
|
||||
DataSourceRef: {
|
||||
// The plugin type-id
|
||||
type?: string
|
||||
|
||||
// Specific datasource instance
|
||||
uid?: string
|
||||
}
|
||||
|
||||
// A topic is attached to DataFrame metadata in query results.
|
||||
// This specifies where the data should be used.
|
||||
DataTopic: "series" | "annotations" | "alertStates" @cog(kind="enum",memberNames="Series|Annotations|AlertStates")
|
||||
|
||||
// Transformations allow to manipulate data returned by a query before the system applies a visualization.
|
||||
// Using transformations you can: rename fields, join time series data, perform mathematical operations across queries,
|
||||
// use the output of one transformation as the input to another transformation, etc.
|
||||
DataTransformerConfig: {
|
||||
// Unique identifier of transformer
|
||||
id: string
|
||||
// Disabled transformations are skipped
|
||||
disabled?: bool
|
||||
// Optional frame matcher. When missing it will be applied to all results
|
||||
filter?: MatcherConfig
|
||||
// Where to pull DataFrames from as input to transformation
|
||||
topic?: DataTopic
|
||||
// Options to be passed to the transformer
|
||||
// Valid options depend on the transformer id
|
||||
options: _
|
||||
}
|
||||
|
||||
DataLink: {
|
||||
title: string
|
||||
url: string
|
||||
targetBlank?: bool
|
||||
}
|
||||
|
||||
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
|
||||
// Each column within this structure is called a field. A field can represent a single time series or table column.
|
||||
// Field options allow you to change how the data is displayed in your visualizations.
|
||||
FieldConfigSource: {
|
||||
// Defaults are the options applied to all fields.
|
||||
defaults: FieldConfig
|
||||
// Overrides are the options applied to specific fields overriding the defaults.
|
||||
overrides: [...{
|
||||
matcher: MatcherConfig
|
||||
properties: [...DynamicConfigValue]
|
||||
}]
|
||||
}
|
||||
|
||||
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
|
||||
// Each column within this structure is called a field. A field can represent a single time series or table column.
|
||||
// Field options allow you to change how the data is displayed in your visualizations.
|
||||
FieldConfig: {
|
||||
// The display value for this field. This supports template variables blank is auto
|
||||
displayName?: string
|
||||
|
||||
// This can be used by data sources that return and explicit naming structure for values and labels
|
||||
// When this property is configured, this value is used rather than the default naming strategy.
|
||||
displayNameFromDS?: string
|
||||
|
||||
// Human readable field metadata
|
||||
description?: string
|
||||
|
||||
// An explicit path to the field in the datasource. When the frame meta includes a path,
|
||||
// This will default to `${frame.meta.path}/${field.name}
|
||||
//
|
||||
// When defined, this value can be used as an identifier within the datasource scope, and
|
||||
// may be used to update the results
|
||||
path?: string
|
||||
|
||||
// True if data source can write a value to the path. Auth/authz are supported separately
|
||||
writeable?: bool
|
||||
|
||||
// True if data source field supports ad-hoc filters
|
||||
filterable?: bool
|
||||
|
||||
// Unit a field should use. The unit you select is applied to all fields except time.
|
||||
// You can use the units ID availables in Grafana or a custom unit.
|
||||
// Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts
|
||||
// As custom unit, you can use the following formats:
|
||||
// `suffix:<suffix>` for custom unit that should go after value.
|
||||
// `prefix:<prefix>` for custom unit that should go before value.
|
||||
// `time:<format>` For custom date time formats type for example `time:YYYY-MM-DD`.
|
||||
// `si:<base scale><unit characters>` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character.
|
||||
// `count:<unit>` for a custom count unit.
|
||||
// `currency:<unit>` for custom a currency unit.
|
||||
unit?: string
|
||||
|
||||
// Specify the number of decimals Grafana includes in the rendered value.
|
||||
// If you leave this field blank, Grafana automatically truncates the number of decimals based on the value.
|
||||
// For example 1.1234 will display as 1.12 and 100.456 will display as 100.
|
||||
// To display all decimals, set the unit to `String`.
|
||||
decimals?: number
|
||||
|
||||
// The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
|
||||
min?: number
|
||||
// The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
|
||||
max?: number
|
||||
|
||||
// Convert input values into a display string
|
||||
mappings?: [...ValueMapping]
|
||||
|
||||
// Map numeric values to states
|
||||
thresholds?: ThresholdsConfig
|
||||
|
||||
// Panel color configuration
|
||||
color?: FieldColor
|
||||
|
||||
// The behavior when clicking on a result
|
||||
links?: [...]
|
||||
|
||||
// Alternative to empty string
|
||||
noValue?: string
|
||||
|
||||
// custom is specified by the FieldConfig field
|
||||
// in panel plugin schemas.
|
||||
custom?: {...}
|
||||
}
|
||||
|
||||
DynamicConfigValue: {
|
||||
id: string | *""
|
||||
value?: _
|
||||
}
|
||||
|
||||
// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
|
||||
// It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type.
|
||||
MatcherConfig: {
|
||||
// The matcher id. This is used to find the matcher implementation from registry.
|
||||
id: string | *""
|
||||
// The matcher options. This is specific to the matcher implementation.
|
||||
options?: _
|
||||
}
|
||||
|
||||
Threshold: {
|
||||
value: number
|
||||
color: string
|
||||
}
|
||||
|
||||
ThresholdsMode: "absolute" | "percentage"
|
||||
|
||||
ThresholdsConfig: {
|
||||
mode: ThresholdsMode
|
||||
steps: [...Threshold]
|
||||
}
|
||||
|
||||
ValueMapping: ValueMap | RangeMap | RegexMap | SpecialValueMap
|
||||
|
||||
// Supported value mapping types
|
||||
// `value`: Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
|
||||
// `range`: Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
|
||||
// `regex`: Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
|
||||
// `special`: Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A.
|
||||
MappingType: "value" | "range" | "regex" | "special"
|
||||
|
||||
// Maps text values to a color or different display text and color.
|
||||
// For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
|
||||
ValueMap: {
|
||||
type: MappingType & "value"
|
||||
// Map with <value_to_match>: ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } }
|
||||
options: [string]: ValueMappingResult
|
||||
}
|
||||
|
||||
// Maps numerical ranges to a display text and color.
|
||||
// For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
|
||||
RangeMap: {
|
||||
type: MappingType & "range"
|
||||
// Range to match against and the result to apply when the value is within the range
|
||||
options: {
|
||||
// Min value of the range. It can be null which means -Infinity
|
||||
from: float64 | null
|
||||
// Max value of the range. It can be null which means +Infinity
|
||||
to: float64 | null
|
||||
// Config to apply when the value is within the range
|
||||
result: ValueMappingResult
|
||||
}
|
||||
}
|
||||
|
||||
// Maps regular expressions to replacement text and a color.
|
||||
// For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
|
||||
RegexMap: {
|
||||
type: MappingType & "regex"
|
||||
// Regular expression to match against and the result to apply when the value matches the regex
|
||||
options: {
|
||||
// Regular expression to match against
|
||||
pattern: string
|
||||
// Config to apply when the value matches the regex
|
||||
result: ValueMappingResult
|
||||
}
|
||||
}
|
||||
|
||||
// Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color.
|
||||
// See SpecialValueMatch to see the list of special values.
|
||||
// For example, you can configure a special value mapping so that null values appear as N/A.
|
||||
SpecialValueMap: {
|
||||
type: MappingType & "special"
|
||||
options: {
|
||||
// Special value to match against
|
||||
match: SpecialValueMatch
|
||||
// Config to apply when the value matches the special value
|
||||
result: ValueMappingResult
|
||||
}
|
||||
}
|
||||
|
||||
// Special value types supported by the `SpecialValueMap`
|
||||
SpecialValueMatch: "true" | "false" | "null" | "nan" | "null+nan" | "empty" @cog(kind="enum",memberNames="True|False|Null|NaN|NullAndNaN|Empty")
|
||||
|
||||
// Result used as replacement with text and color when the value matches
|
||||
ValueMappingResult: {
|
||||
// Text to display when the value matches
|
||||
text?: string
|
||||
// Text to use when the value matches
|
||||
color?: string
|
||||
// Icon to display when the value matches. Only specific visualizations.
|
||||
icon?: string
|
||||
// Position in the mapping array. Only used internally.
|
||||
index?: int32
|
||||
}
|
||||
|
||||
// Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value.
|
||||
// Continuous color interpolates a color using the percentage of a value relative to min and max.
|
||||
// Accepted values are:
|
||||
// `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold
|
||||
// `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations
|
||||
// `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations
|
||||
// `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode
|
||||
// `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode
|
||||
// `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode
|
||||
// `continuous-YlRd`: Continuous Yellow-Red palette mode
|
||||
// `continuous-BlPu`: Continuous Blue-Purple palette mode
|
||||
// `continuous-YlBl`: Continuous Yellow-Blue palette mode
|
||||
// `continuous-blues`: Continuous Blue palette mode
|
||||
// `continuous-reds`: Continuous Red palette mode
|
||||
// `continuous-greens`: Continuous Green palette mode
|
||||
// `continuous-purples`: Continuous Purple palette mode
|
||||
// `shades`: Shades of a single color. Specify a single color, useful in an override rule.
|
||||
// `fixed`: Fixed color mode. Specify a single color, useful in an override rule.
|
||||
FieldColorModeId: "thresholds" | "palette-classic" | "palette-classic-by-name" | "continuous-GrYlRd" | "continuous-RdYlGr" | "continuous-BlYlRd" | "continuous-YlRd" | "continuous-BlPu" | "continuous-YlBl" | "continuous-blues" | "continuous-reds" | "continuous-greens" | "continuous-purples" | "fixed" | "shades"
|
||||
|
||||
// Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value.
|
||||
FieldColorSeriesByMode: "min" | "max" | "last"
|
||||
|
||||
// Map a field to a color.
|
||||
FieldColor: {
|
||||
// The main color scheme mode.
|
||||
mode: FieldColorModeId
|
||||
// The fixed color value for fixed or shades color modes.
|
||||
fixedColor?: string
|
||||
// Some visualizations need to know how to assign a series color from by value color schemes.
|
||||
seriesBy?: FieldColorSeriesByMode
|
||||
}
|
||||
|
||||
// Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource)
|
||||
DashboardLinkType: "link" | "dashboards"
|
||||
|
||||
// --- Common types ---
|
||||
Kind: {
|
||||
kind: string
|
||||
spec: _
|
||||
metadata?: _
|
||||
}
|
||||
|
||||
// --- Kinds ---
|
||||
VizConfigSpec: {
|
||||
pluginVersion: string
|
||||
options: [string]: _
|
||||
fieldConfig: FieldConfigSource
|
||||
}
|
||||
|
||||
VizConfigKind: {
|
||||
// The kind of a VizConfigKind is the plugin ID
|
||||
kind: string
|
||||
spec: VizConfigSpec
|
||||
}
|
||||
|
||||
AnnotationQuerySpec: {
|
||||
datasource?: DataSourceRef
|
||||
query?: DataQueryKind
|
||||
enable: bool
|
||||
hide: bool
|
||||
iconColor: string
|
||||
name: string
|
||||
builtIn?: bool | *false
|
||||
filter?: AnnotationPanelFilter
|
||||
legacyOptions?: [string]: _ //Catch-all field for datasource-specific properties
|
||||
}
|
||||
|
||||
AnnotationQueryKind: {
|
||||
kind: "AnnotationQuery"
|
||||
spec: AnnotationQuerySpec
|
||||
}
|
||||
|
||||
QueryOptionsSpec: {
|
||||
timeFrom?: string
|
||||
maxDataPoints?: int
|
||||
timeShift?: string
|
||||
queryCachingTTL?: int
|
||||
interval?: string
|
||||
cacheTimeout?: string
|
||||
hideTimeOverride?: bool
|
||||
}
|
||||
|
||||
DataQueryKind: {
|
||||
// The kind of a DataQueryKind is the datasource type
|
||||
kind: string
|
||||
spec: [string]: _
|
||||
}
|
||||
|
||||
PanelQuerySpec: {
|
||||
query: DataQueryKind
|
||||
datasource?: DataSourceRef
|
||||
|
||||
refId: string
|
||||
hidden: bool
|
||||
}
|
||||
|
||||
PanelQueryKind: {
|
||||
kind: "PanelQuery"
|
||||
spec: PanelQuerySpec
|
||||
}
|
||||
|
||||
TransformationKind: {
|
||||
// The kind of a TransformationKind is the transformation ID
|
||||
kind: string
|
||||
spec: DataTransformerConfig
|
||||
}
|
||||
|
||||
QueryGroupSpec: {
|
||||
queries: [...PanelQueryKind]
|
||||
transformations: [...TransformationKind]
|
||||
queryOptions: QueryOptionsSpec
|
||||
}
|
||||
|
||||
QueryGroupKind: {
|
||||
kind: "QueryGroup"
|
||||
spec: QueryGroupSpec
|
||||
}
|
||||
|
||||
TimeRangeOption: {
|
||||
display: string | *"Last 6 hours"
|
||||
from: string | *"now-6h"
|
||||
to: string | *"now"
|
||||
}
|
||||
|
||||
// Time configuration
|
||||
// It defines the default time config for the time picker, the refresh picker for the specific dashboard.
|
||||
TimeSettingsSpec: {
|
||||
// Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc".
|
||||
timezone?: string | *"browser"
|
||||
// Start time range for dashboard.
|
||||
// Accepted values are relative time strings like "now-6h" or absolute time strings like "2020-07-10T08:00:00.000Z".
|
||||
from: string | *"now-6h"
|
||||
// End time range for dashboard.
|
||||
// Accepted values are relative time strings like "now-6h" or absolute time strings like "2020-07-10T08:00:00.000Z".
|
||||
to: string | *"now"
|
||||
// Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
|
||||
autoRefresh: string | *"" // v1: refresh
|
||||
// Interval options available in the refresh picker dropdown.
|
||||
autoRefreshIntervals: [...string] | *["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"] // v1: timepicker.refresh_intervals
|
||||
// Selectable options available in the time picker dropdown. Has no effect on provisioned dashboard.
|
||||
quickRanges?: [...TimeRangeOption] // v1: timepicker.quick_ranges , not exposed in the UI
|
||||
// Whether timepicker is visible or not.
|
||||
hideTimepicker: bool | *false // v1: timepicker.hidden
|
||||
// Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday".
|
||||
weekStart?: "saturday" | "monday" | "sunday"
|
||||
// The month that the fiscal year starts on. 0 = January, 11 = December
|
||||
fiscalYearStartMonth: int | *0
|
||||
// Override the now time by entering a time delay. Use this option to accommodate known delays in data aggregation to avoid null values.
|
||||
nowDelay?: string // v1: timepicker.nowDelay
|
||||
}
|
||||
|
||||
RepeatMode: "variable" // other repeat modes will be added in the future: label, frame
|
||||
|
||||
RepeatOptions: {
|
||||
mode: RepeatMode
|
||||
value: string
|
||||
direction?: "h" | "v"
|
||||
maxPerRow?: int
|
||||
}
|
||||
|
||||
RowRepeatOptions: {
|
||||
mode: RepeatMode
|
||||
value: string
|
||||
}
|
||||
|
||||
TabRepeatOptions: {
|
||||
mode: RepeatMode
|
||||
value: string
|
||||
}
|
||||
|
||||
AutoGridRepeatOptions: {
|
||||
mode: RepeatMode
|
||||
value: string
|
||||
}
|
||||
|
||||
GridLayoutItemSpec: {
|
||||
x: int
|
||||
y: int
|
||||
width: int
|
||||
height: int
|
||||
element: ElementReference // reference to a PanelKind from dashboard.spec.elements Expressed as JSON Schema reference
|
||||
repeat?: RepeatOptions
|
||||
}
|
||||
|
||||
GridLayoutItemKind: {
|
||||
kind: "GridLayoutItem"
|
||||
spec: GridLayoutItemSpec
|
||||
}
|
||||
|
||||
GridLayoutSpec: {
|
||||
items: [...GridLayoutItemKind]
|
||||
}
|
||||
|
||||
GridLayoutKind: {
|
||||
kind: "GridLayout"
|
||||
spec: GridLayoutSpec
|
||||
}
|
||||
|
||||
RowsLayoutKind: {
|
||||
kind: "RowsLayout"
|
||||
spec: RowsLayoutSpec
|
||||
}
|
||||
|
||||
RowsLayoutSpec: {
|
||||
rows: [...RowsLayoutRowKind]
|
||||
}
|
||||
|
||||
RowsLayoutRowKind: {
|
||||
kind: "RowsLayoutRow"
|
||||
spec: RowsLayoutRowSpec
|
||||
}
|
||||
|
||||
RowsLayoutRowSpec: {
|
||||
title?: string
|
||||
collapse?: bool
|
||||
hideHeader?: bool
|
||||
fillScreen?: bool
|
||||
conditionalRendering?: ConditionalRenderingGroupKind
|
||||
repeat?: RowRepeatOptions
|
||||
layout: GridLayoutKind | AutoGridLayoutKind | TabsLayoutKind | RowsLayoutKind
|
||||
}
|
||||
|
||||
AutoGridLayoutKind: {
|
||||
kind: "AutoGridLayout"
|
||||
spec: AutoGridLayoutSpec
|
||||
}
|
||||
|
||||
AutoGridLayoutSpec: {
|
||||
maxColumnCount?: number | *3
|
||||
columnWidthMode: "narrow" | *"standard" | "wide" | "custom"
|
||||
columnWidth?: number
|
||||
rowHeightMode: "short" | *"standard" | "tall" | "custom"
|
||||
rowHeight?: number
|
||||
fillScreen?: bool | *false
|
||||
items: [...AutoGridLayoutItemKind]
|
||||
}
|
||||
|
||||
AutoGridLayoutItemKind: {
|
||||
kind: "AutoGridLayoutItem"
|
||||
spec: AutoGridLayoutItemSpec
|
||||
}
|
||||
|
||||
AutoGridLayoutItemSpec: {
|
||||
element: ElementReference
|
||||
repeat?: AutoGridRepeatOptions
|
||||
conditionalRendering?: ConditionalRenderingGroupKind
|
||||
}
|
||||
|
||||
TabsLayoutKind: {
|
||||
kind: "TabsLayout"
|
||||
spec: TabsLayoutSpec
|
||||
}
|
||||
|
||||
TabsLayoutSpec: {
|
||||
tabs: [...TabsLayoutTabKind]
|
||||
}
|
||||
|
||||
TabsLayoutTabKind: {
|
||||
kind: "TabsLayoutTab"
|
||||
spec: TabsLayoutTabSpec
|
||||
}
|
||||
|
||||
TabsLayoutTabSpec: {
|
||||
title?: string
|
||||
layout: GridLayoutKind | RowsLayoutKind | AutoGridLayoutKind | TabsLayoutKind
|
||||
conditionalRendering?: ConditionalRenderingGroupKind
|
||||
repeat?: TabRepeatOptions
|
||||
}
|
||||
|
||||
PanelSpec: {
|
||||
id: number
|
||||
title: string
|
||||
description: string
|
||||
links: [...DataLink]
|
||||
data: QueryGroupKind
|
||||
vizConfig: VizConfigKind
|
||||
transparent?: bool
|
||||
}
|
||||
|
||||
PanelKind: {
|
||||
kind: "Panel"
|
||||
spec: PanelSpec
|
||||
}
|
||||
|
||||
ElementReference: {
|
||||
kind: "ElementReference"
|
||||
name: string
|
||||
}
|
||||
|
||||
// Start FIXME: variables - in CUE PR - this are things that should be added into the cue schema
|
||||
// TODO: properties such as `hide`, `skipUrlSync`, `multi` are type boolean, and in the old schema they are conditional,
|
||||
// should we make them conditional in the new schema as well? or should we make them required but default to false?
|
||||
|
||||
// Variable types
|
||||
VariableValue: VariableValueSingle | [...VariableValueSingle]
|
||||
|
||||
VariableValueSingle: string | bool | number | CustomVariableValue
|
||||
|
||||
// Custom formatter variable
|
||||
CustomFormatterVariable: {
|
||||
name: string
|
||||
type: VariableType
|
||||
multi: bool
|
||||
includeAll: bool
|
||||
}
|
||||
|
||||
// Custom variable value
|
||||
CustomVariableValue: {
|
||||
// The format name or function used in the expression
|
||||
formatter: *null | string | VariableCustomFormatterFn
|
||||
}
|
||||
|
||||
// Custom formatter function
|
||||
VariableCustomFormatterFn: {
|
||||
value: _
|
||||
legacyVariableModel: {
|
||||
name: string
|
||||
type: VariableType
|
||||
multi: bool
|
||||
includeAll: bool
|
||||
}
|
||||
legacyDefaultFormatter?: VariableCustomFormatterFn
|
||||
}
|
||||
|
||||
// Dashboard variable type
|
||||
// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
|
||||
// `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
|
||||
// `constant`: Define a hidden constant.
|
||||
// `datasource`: Quickly change the data source for an entire dashboard.
|
||||
// `interval`: Interval variables represent time spans.
|
||||
// `textbox`: Display a free text input field with an optional default value.
|
||||
// `custom`: Define the variable options manually using a comma-separated list.
|
||||
// `system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables
|
||||
VariableType: "query" | "adhoc" | "groupby" | "constant" | "datasource" | "interval" | "textbox" | "custom" |
|
||||
"system" | "snapshot"
|
||||
|
||||
VariableKind: QueryVariableKind | TextVariableKind | ConstantVariableKind | DatasourceVariableKind | IntervalVariableKind | CustomVariableKind | GroupByVariableKind | AdhocVariableKind
|
||||
|
||||
// Sort variable options
|
||||
// Accepted values are:
|
||||
// `disabled`: No sorting
|
||||
// `alphabeticalAsc`: Alphabetical ASC
|
||||
// `alphabeticalDesc`: Alphabetical DESC
|
||||
// `numericalAsc`: Numerical ASC
|
||||
// `numericalDesc`: Numerical DESC
|
||||
// `alphabeticalCaseInsensitiveAsc`: Alphabetical Case Insensitive ASC
|
||||
// `alphabeticalCaseInsensitiveDesc`: Alphabetical Case Insensitive DESC
|
||||
// `naturalAsc`: Natural ASC
|
||||
// `naturalDesc`: Natural DESC
|
||||
// VariableSort enum with default value
|
||||
VariableSort: "disabled" | "alphabeticalAsc" | "alphabeticalDesc" | "numericalAsc" | "numericalDesc" | "alphabeticalCaseInsensitiveAsc" | "alphabeticalCaseInsensitiveDesc" | "naturalAsc" | "naturalDesc"
|
||||
|
||||
// Options to config when to refresh a variable
|
||||
// `never`: Never refresh the variable
|
||||
// `onDashboardLoad`: Queries the data source every time the dashboard loads.
|
||||
// `onTimeRangeChanged`: Queries the data source when the dashboard time range changes.
|
||||
VariableRefresh: *"never" | "onDashboardLoad" | "onTimeRangeChanged"
|
||||
|
||||
// Determine if the variable shows on dashboard
|
||||
// Accepted values are `dontHide` (show label and value), `hideLabel` (show value only), `hideVariable` (show nothing).
|
||||
VariableHide: *"dontHide" | "hideLabel" | "hideVariable"
|
||||
|
||||
// Determine the origin of the adhoc variable filter
|
||||
FilterOrigin: "dashboard"
|
||||
|
||||
// FIXME: should we introduce this? --- Variable value option
|
||||
VariableValueOption: {
|
||||
label: string
|
||||
value: VariableValueSingle
|
||||
group?: string
|
||||
}
|
||||
|
||||
// Variable option specification
|
||||
VariableOption: {
|
||||
// Whether the option is selected or not
|
||||
selected?: bool
|
||||
// Text to be displayed for the option
|
||||
text: string | [...string]
|
||||
// Value of the option
|
||||
value: string | [...string]
|
||||
}
|
||||
|
||||
// Query variable specification
|
||||
QueryVariableSpec: {
|
||||
name: string | *""
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
value: ""
|
||||
}
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
refresh: VariableRefresh
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
datasource?: DataSourceRef
|
||||
query: DataQueryKind
|
||||
regex: string | *""
|
||||
sort: VariableSort
|
||||
definition?: string
|
||||
options: [...VariableOption] | *[]
|
||||
multi: bool | *false
|
||||
includeAll: bool | *false
|
||||
allValue?: string
|
||||
placeholder?: string
|
||||
allowCustomValue: bool | *true
|
||||
staticOptions?: [...VariableOption]
|
||||
staticOptionsOrder?: "before" | "after" | "sorted"
|
||||
}
|
||||
|
||||
// Query variable kind
|
||||
QueryVariableKind: {
|
||||
kind: "QueryVariable"
|
||||
spec: QueryVariableSpec
|
||||
}
|
||||
|
||||
// Text variable specification
|
||||
TextVariableSpec: {
|
||||
name: string | *""
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
value: ""
|
||||
}
|
||||
query: string | *""
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
}
|
||||
|
||||
// Text variable kind
|
||||
TextVariableKind: {
|
||||
kind: "TextVariable"
|
||||
spec: TextVariableSpec
|
||||
}
|
||||
|
||||
// Constant variable specification
|
||||
ConstantVariableSpec: {
|
||||
name: string | *""
|
||||
query: string | *""
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
value: ""
|
||||
}
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
}
|
||||
|
||||
// Constant variable kind
|
||||
ConstantVariableKind: {
|
||||
kind: "ConstantVariable"
|
||||
spec: ConstantVariableSpec
|
||||
}
|
||||
|
||||
// Datasource variable specification
|
||||
DatasourceVariableSpec: {
|
||||
name: string | *""
|
||||
pluginId: string | *""
|
||||
refresh: VariableRefresh
|
||||
regex: string | *""
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
value: ""
|
||||
}
|
||||
options: [...VariableOption] | *[]
|
||||
multi: bool | *false
|
||||
includeAll: bool | *false
|
||||
allValue?: string
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
allowCustomValue: bool | *true
|
||||
}
|
||||
|
||||
// Datasource variable kind
|
||||
DatasourceVariableKind: {
|
||||
kind: "DatasourceVariable"
|
||||
spec: DatasourceVariableSpec
|
||||
}
|
||||
|
||||
// Interval variable specification
|
||||
IntervalVariableSpec: {
|
||||
name: string | *""
|
||||
query: string | *""
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
value: ""
|
||||
}
|
||||
options: [...VariableOption] | *[]
|
||||
auto: bool | *false
|
||||
auto_min: string | *""
|
||||
auto_count: int | *0
|
||||
refresh: VariableRefresh
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
}
|
||||
|
||||
// Interval variable kind
|
||||
IntervalVariableKind: {
|
||||
kind: "IntervalVariable"
|
||||
spec: IntervalVariableSpec
|
||||
}
|
||||
|
||||
// Custom variable specification
|
||||
CustomVariableSpec: {
|
||||
name: string | *""
|
||||
query: string | *""
|
||||
current: VariableOption
|
||||
options: [...VariableOption] | *[]
|
||||
multi: bool | *false
|
||||
includeAll: bool | *false
|
||||
allValue?: string
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
allowCustomValue: bool | *true
|
||||
}
|
||||
|
||||
// Custom variable kind
|
||||
CustomVariableKind: {
|
||||
kind: "CustomVariable"
|
||||
spec: CustomVariableSpec
|
||||
}
|
||||
|
||||
// GroupBy variable specification
|
||||
GroupByVariableSpec: {
|
||||
name: string | *""
|
||||
datasource?: DataSourceRef
|
||||
defaultValue?: VariableOption
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
value: ""
|
||||
}
|
||||
options: [...VariableOption] | *[]
|
||||
multi: bool | *false
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
}
|
||||
|
||||
// Group variable kind
|
||||
GroupByVariableKind: {
|
||||
kind: "GroupByVariable"
|
||||
spec: GroupByVariableSpec
|
||||
}
|
||||
|
||||
// Adhoc variable specification
|
||||
AdhocVariableSpec: {
|
||||
name: string | *""
|
||||
datasource?: DataSourceRef
|
||||
baseFilters: [...AdHocFilterWithLabels] | *[]
|
||||
filters: [...AdHocFilterWithLabels] | *[]
|
||||
defaultKeys: [...MetricFindValue] | *[]
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
allowCustomValue: bool | *true
|
||||
}
|
||||
|
||||
// Define the MetricFindValue type
|
||||
MetricFindValue: {
|
||||
text: string
|
||||
value?: string | number
|
||||
group?: string
|
||||
expandable?: bool
|
||||
}
|
||||
|
||||
// Define the AdHocFilterWithLabels type
|
||||
AdHocFilterWithLabels: {
|
||||
key: string
|
||||
operator: string
|
||||
value: string
|
||||
values?: [...string]
|
||||
keyLabel?: string
|
||||
valueLabels?: [...string]
|
||||
forceEdit?: bool
|
||||
origin?: FilterOrigin
|
||||
// @deprecated
|
||||
condition?: string
|
||||
}
|
||||
|
||||
// Adhoc variable kind
|
||||
AdhocVariableKind: {
|
||||
kind: "AdhocVariable"
|
||||
spec: AdhocVariableSpec
|
||||
}
|
||||
|
||||
ConditionalRenderingGroupKind: {
|
||||
kind: "ConditionalRenderingGroup"
|
||||
spec: ConditionalRenderingGroupSpec
|
||||
}
|
||||
|
||||
ConditionalRenderingGroupSpec: {
|
||||
visibility: "show" | "hide"
|
||||
condition: "and" | "or"
|
||||
items: [...ConditionalRenderingVariableKind | ConditionalRenderingDataKind | ConditionalRenderingTimeRangeSizeKind]
|
||||
}
|
||||
|
||||
ConditionalRenderingVariableKind: {
|
||||
kind: "ConditionalRenderingVariable"
|
||||
spec: ConditionalRenderingVariableSpec
|
||||
}
|
||||
|
||||
ConditionalRenderingVariableSpec: {
|
||||
variable: string
|
||||
operator: "equals" | "notEquals"
|
||||
value: string
|
||||
}
|
||||
|
||||
ConditionalRenderingDataKind: {
|
||||
kind: "ConditionalRenderingData"
|
||||
spec: ConditionalRenderingDataSpec
|
||||
}
|
||||
|
||||
ConditionalRenderingDataSpec: {
|
||||
value: bool
|
||||
}
|
||||
|
||||
ConditionalRenderingTimeRangeSizeKind: {
|
||||
kind: "ConditionalRenderingTimeRangeSize"
|
||||
spec: ConditionalRenderingTimeRangeSizeSpec
|
||||
}
|
||||
|
||||
ConditionalRenderingTimeRangeSizeSpec: {
|
||||
value: string
|
||||
}
|
||||
@@ -219,6 +219,10 @@ lineage: schemas: [{
|
||||
// Optional field, if you want to extract part of a series name or metric node segment.
|
||||
// Named capture groups can be used to separate the display text and value.
|
||||
regex?: string
|
||||
// Additional static options for query variable
|
||||
staticOptions?: [...#VariableOption]
|
||||
// Ordering of static options in relation to options returned from data source for query variable
|
||||
staticOptionsOrder?: "before" | "after" | "sorted"
|
||||
...
|
||||
} @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
|
||||
|
||||
|
||||
@@ -219,6 +219,10 @@ lineage: schemas: [{
|
||||
// Optional field, if you want to extract part of a series name or metric node segment.
|
||||
// Named capture groups can be used to separate the display text and value.
|
||||
regex?: string
|
||||
// Additional static options for query variable
|
||||
staticOptions?: [...#VariableOption]
|
||||
// Ordering of static options in relation to options returned from data source for query variable
|
||||
staticOptionsOrder?: "before" | "after" | "sorted"
|
||||
...
|
||||
} @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
|
||||
|
||||
|
||||
@@ -115,8 +115,6 @@ DashboardLink: {
|
||||
keepTime: bool | *false
|
||||
}
|
||||
|
||||
// Keeping this for backwards compatibility for GroupByVariableSpec and AdhocVariableSpec
|
||||
// This type is widely used in the codebase and changing it will have a big impact
|
||||
DataSourceRef: {
|
||||
// The plugin type-id
|
||||
type?: string
|
||||
@@ -391,7 +389,8 @@ VizConfigKind: {
|
||||
}
|
||||
|
||||
AnnotationQuerySpec: {
|
||||
query: DataQueryKind
|
||||
datasource?: DataSourceRef
|
||||
query?: DataQueryKind
|
||||
enable: bool
|
||||
hide: bool
|
||||
iconColor: string
|
||||
@@ -417,19 +416,15 @@ QueryOptionsSpec: {
|
||||
}
|
||||
|
||||
DataQueryKind: {
|
||||
kind: "DataQuery"
|
||||
group: string
|
||||
version: string | *"v0"
|
||||
// New type for datasource reference
|
||||
// Not creating a new type until we figure out how to handle DS refs for group by, adhoc, and every place that uses DataSourceRef in TS.
|
||||
datasource?: {
|
||||
name?: string
|
||||
}
|
||||
// The kind of a DataQueryKind is the datasource type
|
||||
kind: string
|
||||
spec: [string]: _
|
||||
}
|
||||
|
||||
PanelQuerySpec: {
|
||||
query: DataQueryKind
|
||||
datasource?: DataSourceRef
|
||||
|
||||
refId: string
|
||||
hidden: bool
|
||||
}
|
||||
@@ -732,6 +727,7 @@ QueryVariableSpec: {
|
||||
refresh: VariableRefresh
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
datasource?: DataSourceRef
|
||||
query: DataQueryKind
|
||||
regex: string | *""
|
||||
sort: VariableSort
|
||||
@@ -742,6 +738,8 @@ QueryVariableSpec: {
|
||||
allValue?: string
|
||||
placeholder?: string
|
||||
allowCustomValue: bool | *true
|
||||
staticOptions?: [...VariableOption]
|
||||
staticOptionsOrder?: "before" | "after" | "sorted"
|
||||
}
|
||||
|
||||
// Query variable kind
|
||||
|
||||
@@ -23,13 +23,14 @@ func NewDashboardAnnotationQueryKind() *DashboardAnnotationQueryKind {
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardAnnotationQuerySpec struct {
|
||||
Query DashboardDataQueryKind `json:"query"`
|
||||
Enable bool `json:"enable"`
|
||||
Hide bool `json:"hide"`
|
||||
IconColor string `json:"iconColor"`
|
||||
Name string `json:"name"`
|
||||
BuiltIn *bool `json:"builtIn,omitempty"`
|
||||
Filter *DashboardAnnotationPanelFilter `json:"filter,omitempty"`
|
||||
Datasource *DashboardDataSourceRef `json:"datasource,omitempty"`
|
||||
Query *DashboardDataQueryKind `json:"query,omitempty"`
|
||||
Enable bool `json:"enable"`
|
||||
Hide bool `json:"hide"`
|
||||
IconColor string `json:"iconColor"`
|
||||
Name string `json:"name"`
|
||||
BuiltIn *bool `json:"builtIn,omitempty"`
|
||||
Filter *DashboardAnnotationPanelFilter `json:"filter,omitempty"`
|
||||
// Catch-all field for datasource-specific properties
|
||||
LegacyOptions map[string]interface{} `json:"legacyOptions,omitempty"`
|
||||
}
|
||||
@@ -37,28 +38,34 @@ type DashboardAnnotationQuerySpec struct {
|
||||
// NewDashboardAnnotationQuerySpec creates a new DashboardAnnotationQuerySpec object.
|
||||
func NewDashboardAnnotationQuerySpec() *DashboardAnnotationQuerySpec {
|
||||
return &DashboardAnnotationQuerySpec{
|
||||
Query: *NewDashboardDataQueryKind(),
|
||||
BuiltIn: (func(input bool) *bool { return &input })(false),
|
||||
}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardDataSourceRef struct {
|
||||
// The plugin type-id
|
||||
Type *string `json:"type,omitempty"`
|
||||
// Specific datasource instance
|
||||
Uid *string `json:"uid,omitempty"`
|
||||
}
|
||||
|
||||
// NewDashboardDataSourceRef creates a new DashboardDataSourceRef object.
|
||||
func NewDashboardDataSourceRef() *DashboardDataSourceRef {
|
||||
return &DashboardDataSourceRef{}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardDataQueryKind struct {
|
||||
Kind string `json:"kind"`
|
||||
Group string `json:"group"`
|
||||
Version string `json:"version"`
|
||||
// New type for datasource reference
|
||||
// Not creating a new type until we figure out how to handle DS refs for group by, adhoc, and every place that uses DataSourceRef in TS.
|
||||
Datasource *DashboardV2alpha1DataQueryKindDatasource `json:"datasource,omitempty"`
|
||||
Spec map[string]interface{} `json:"spec"`
|
||||
// The kind of a DataQueryKind is the datasource type
|
||||
Kind string `json:"kind"`
|
||||
Spec map[string]interface{} `json:"spec"`
|
||||
}
|
||||
|
||||
// NewDashboardDataQueryKind creates a new DashboardDataQueryKind object.
|
||||
func NewDashboardDataQueryKind() *DashboardDataQueryKind {
|
||||
return &DashboardDataQueryKind{
|
||||
Kind: "DataQuery",
|
||||
Version: "v0",
|
||||
Spec: map[string]interface{}{},
|
||||
Spec: map[string]interface{}{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,9 +199,10 @@ func NewDashboardPanelQueryKind() *DashboardPanelQueryKind {
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardPanelQuerySpec struct {
|
||||
Query DashboardDataQueryKind `json:"query"`
|
||||
RefId string `json:"refId"`
|
||||
Hidden bool `json:"hidden"`
|
||||
Query DashboardDataQueryKind `json:"query"`
|
||||
Datasource *DashboardDataSourceRef `json:"datasource,omitempty"`
|
||||
RefId string `json:"refId"`
|
||||
Hidden bool `json:"hidden"`
|
||||
}
|
||||
|
||||
// NewDashboardPanelQuerySpec creates a new DashboardPanelQuerySpec object.
|
||||
@@ -1214,23 +1222,26 @@ func NewDashboardQueryVariableKind() *DashboardQueryVariableKind {
|
||||
// Query variable specification
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardQueryVariableSpec struct {
|
||||
Name string `json:"name"`
|
||||
Current DashboardVariableOption `json:"current"`
|
||||
Label *string `json:"label,omitempty"`
|
||||
Hide DashboardVariableHide `json:"hide"`
|
||||
Refresh DashboardVariableRefresh `json:"refresh"`
|
||||
SkipUrlSync bool `json:"skipUrlSync"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Query DashboardDataQueryKind `json:"query"`
|
||||
Regex string `json:"regex"`
|
||||
Sort DashboardVariableSort `json:"sort"`
|
||||
Definition *string `json:"definition,omitempty"`
|
||||
Options []DashboardVariableOption `json:"options"`
|
||||
Multi bool `json:"multi"`
|
||||
IncludeAll bool `json:"includeAll"`
|
||||
AllValue *string `json:"allValue,omitempty"`
|
||||
Placeholder *string `json:"placeholder,omitempty"`
|
||||
AllowCustomValue bool `json:"allowCustomValue"`
|
||||
Name string `json:"name"`
|
||||
Current DashboardVariableOption `json:"current"`
|
||||
Label *string `json:"label,omitempty"`
|
||||
Hide DashboardVariableHide `json:"hide"`
|
||||
Refresh DashboardVariableRefresh `json:"refresh"`
|
||||
SkipUrlSync bool `json:"skipUrlSync"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Datasource *DashboardDataSourceRef `json:"datasource,omitempty"`
|
||||
Query DashboardDataQueryKind `json:"query"`
|
||||
Regex string `json:"regex"`
|
||||
Sort DashboardVariableSort `json:"sort"`
|
||||
Definition *string `json:"definition,omitempty"`
|
||||
Options []DashboardVariableOption `json:"options"`
|
||||
Multi bool `json:"multi"`
|
||||
IncludeAll bool `json:"includeAll"`
|
||||
AllValue *string `json:"allValue,omitempty"`
|
||||
Placeholder *string `json:"placeholder,omitempty"`
|
||||
AllowCustomValue bool `json:"allowCustomValue"`
|
||||
StaticOptions []DashboardVariableOption `json:"staticOptions,omitempty"`
|
||||
StaticOptionsOrder *DashboardQueryVariableSpecStaticOptionsOrder `json:"staticOptionsOrder,omitempty"`
|
||||
}
|
||||
|
||||
// NewDashboardQueryVariableSpec creates a new DashboardQueryVariableSpec object.
|
||||
@@ -1626,21 +1637,6 @@ func NewDashboardGroupByVariableSpec() *DashboardGroupByVariableSpec {
|
||||
}
|
||||
}
|
||||
|
||||
// Keeping this for backwards compatibility for GroupByVariableSpec and AdhocVariableSpec
|
||||
// This type is widely used in the codebase and changing it will have a big impact
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardDataSourceRef struct {
|
||||
// The plugin type-id
|
||||
Type *string `json:"type,omitempty"`
|
||||
// Specific datasource instance
|
||||
Uid *string `json:"uid,omitempty"`
|
||||
}
|
||||
|
||||
// NewDashboardDataSourceRef creates a new DashboardDataSourceRef object.
|
||||
func NewDashboardDataSourceRef() *DashboardDataSourceRef {
|
||||
return &DashboardDataSourceRef{}
|
||||
}
|
||||
|
||||
// Adhoc variable kind
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardAdhocVariableKind struct {
|
||||
@@ -1774,16 +1770,6 @@ func NewDashboardSpec() *DashboardSpec {
|
||||
}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardV2alpha1DataQueryKindDatasource struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// NewDashboardV2alpha1DataQueryKindDatasource creates a new DashboardV2alpha1DataQueryKindDatasource object.
|
||||
func NewDashboardV2alpha1DataQueryKindDatasource() *DashboardV2alpha1DataQueryKindDatasource {
|
||||
return &DashboardV2alpha1DataQueryKindDatasource{}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardV2alpha1FieldConfigSourceOverrides struct {
|
||||
Matcher DashboardMatcherConfig `json:"matcher"`
|
||||
@@ -1906,6 +1892,15 @@ const (
|
||||
DashboardTimeSettingsSpecWeekStartSunday DashboardTimeSettingsSpecWeekStart = "sunday"
|
||||
)
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardQueryVariableSpecStaticOptionsOrder string
|
||||
|
||||
const (
|
||||
DashboardQueryVariableSpecStaticOptionsOrderBefore DashboardQueryVariableSpecStaticOptionsOrder = "before"
|
||||
DashboardQueryVariableSpecStaticOptionsOrderAfter DashboardQueryVariableSpecStaticOptionsOrder = "after"
|
||||
DashboardQueryVariableSpecStaticOptionsOrderSorted DashboardQueryVariableSpecStaticOptionsOrder = "sorted"
|
||||
)
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardPanelKindOrLibraryPanelKind struct {
|
||||
PanelKind *DashboardPanelKind `json:"PanelKind,omitempty"`
|
||||
|
||||
@@ -109,7 +109,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardTimeRangeOption": schema_pkg_apis_dashboard_v2alpha1_DashboardTimeRangeOption(ref),
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardTimeSettingsSpec": schema_pkg_apis_dashboard_v2alpha1_DashboardTimeSettingsSpec(ref),
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardTransformationKind": schema_pkg_apis_dashboard_v2alpha1_DashboardTransformationKind(ref),
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1DataQueryKindDatasource": schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1DataQueryKindDatasource(ref),
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1FieldConfigSourceOverrides": schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1FieldConfigSourceOverrides(ref),
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1RangeMapOptions": schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1RangeMapOptions(ref),
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1RegexMapOptions": schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1RegexMapOptions(ref),
|
||||
@@ -596,10 +595,14 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardAnnotationQuerySpec(ref common.
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"datasource": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef"),
|
||||
},
|
||||
},
|
||||
"query": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind"),
|
||||
Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind"),
|
||||
},
|
||||
},
|
||||
"enable": {
|
||||
@@ -657,11 +660,11 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardAnnotationQuerySpec(ref common.
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"query", "enable", "hide", "iconColor", "name"},
|
||||
Required: []string{"enable", "hide", "iconColor", "name"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardAnnotationPanelFilter", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind"},
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardAnnotationPanelFilter", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1502,29 +1505,10 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardDataQueryKind(ref common.Refere
|
||||
Properties: map[string]spec.Schema{
|
||||
"kind": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"group": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"version": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"datasource": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "New type for datasource reference Not creating a new type until we figure out how to handle DS refs for group by, adhoc, and every place that uses DataSourceRef in TS.",
|
||||
Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1DataQueryKindDatasource"),
|
||||
Description: "The kind of a DataQueryKind is the datasource type",
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"spec": {
|
||||
@@ -1542,11 +1526,9 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardDataQueryKind(ref common.Refere
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"kind", "group", "version", "spec"},
|
||||
Required: []string{"kind", "spec"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardV2alpha1DataQueryKindDatasource"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1554,8 +1536,7 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardDataSourceRef(ref common.Refere
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Keeping this for backwards compatibility for GroupByVariableSpec and AdhocVariableSpec This type is widely used in the codebase and changing it will have a big impact",
|
||||
Type: []string{"object"},
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"type": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
@@ -2909,6 +2890,11 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardPanelQuerySpec(ref common.Refer
|
||||
Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind"),
|
||||
},
|
||||
},
|
||||
"datasource": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef"),
|
||||
},
|
||||
},
|
||||
"refId": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: "",
|
||||
@@ -2928,7 +2914,7 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardPanelQuerySpec(ref common.Refer
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind"},
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3264,6 +3250,11 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardQueryVariableSpec(ref common.Re
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"datasource": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef"),
|
||||
},
|
||||
},
|
||||
"query": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
@@ -3336,12 +3327,31 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardQueryVariableSpec(ref common.Re
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"staticOptions": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"array"},
|
||||
Items: &spec.SchemaOrArray{
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardVariableOption"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"staticOptionsOrder": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"name", "current", "hide", "refresh", "skipUrlSync", "query", "regex", "sort", "options", "multi", "includeAll", "allowCustomValue"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardVariableOption"},
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataQueryKind", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardDataSourceRef", "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1.DashboardVariableOption"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4329,24 +4339,6 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardTransformationKind(ref common.R
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1DataQueryKindDatasource(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"name": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_dashboard_v2alpha1_DashboardV2alpha1FieldConfigSourceOverrides(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
|
||||
@@ -20,6 +20,7 @@ API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1,DashboardQueryGroupSpec,Queries
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1,DashboardQueryGroupSpec,Transformations
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1,DashboardQueryVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1,DashboardQueryVariableSpec,StaticOptions
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1,DashboardRowsLayoutSpec,Rows
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1,DashboardSpec,Annotations
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1,DashboardSpec,Links
|
||||
|
||||
18
apps/dashboard/pkg/apis/dashboard/v2alpha2/constants.go
Normal file
18
apps/dashboard/pkg/apis/dashboard/v2alpha2/constants.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package v2alpha2
|
||||
|
||||
import "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
const (
|
||||
// APIGroup is the API group used by all kinds in this package
|
||||
APIGroup = "dashboard.grafana.app"
|
||||
// APIVersion is the API version used by all kinds in this package
|
||||
APIVersion = "v2alpha2"
|
||||
)
|
||||
|
||||
var (
|
||||
// GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package
|
||||
GroupVersion = schema.GroupVersion{
|
||||
Group: APIGroup,
|
||||
Version: APIVersion,
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v2alpha2
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
||||
"github.com/grafana/grafana-app-sdk/resource"
|
||||
)
|
||||
|
||||
// DashboardJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
|
||||
type DashboardJSONCodec struct{}
|
||||
|
||||
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
|
||||
func (*DashboardJSONCodec) Read(reader io.Reader, into resource.Object) error {
|
||||
return json.NewDecoder(reader).Decode(into)
|
||||
}
|
||||
|
||||
// Write writes JSON-encoded bytes into `writer` marshaled from `from`
|
||||
func (*DashboardJSONCodec) Write(writer io.Writer, from resource.Object) error {
|
||||
return json.NewEncoder(writer).Encode(from)
|
||||
}
|
||||
|
||||
// Interface compliance checks
|
||||
var _ resource.Codec = &DashboardJSONCodec{}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v2alpha2
|
||||
|
||||
import (
|
||||
time "time"
|
||||
)
|
||||
|
||||
// metadata contains embedded CommonMetadata and can be extended with custom string fields
|
||||
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
|
||||
// without external reference as using the CommonMetadata reference breaks thema codegen.
|
||||
type DashboardMetadata struct {
|
||||
UpdateTimestamp time.Time `json:"updateTimestamp"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
Uid string `json:"uid"`
|
||||
CreationTimestamp time.Time `json:"creationTimestamp"`
|
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"`
|
||||
Finalizers []string `json:"finalizers"`
|
||||
ResourceVersion string `json:"resourceVersion"`
|
||||
Generation int64 `json:"generation"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
}
|
||||
|
||||
// NewDashboardMetadata creates a new DashboardMetadata object.
|
||||
func NewDashboardMetadata() *DashboardMetadata {
|
||||
return &DashboardMetadata{
|
||||
Finalizers: []string{},
|
||||
Labels: map[string]string{},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v2alpha2
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/grafana/grafana-app-sdk/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"time"
|
||||
)
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type Dashboard struct {
|
||||
metav1.TypeMeta `json:",inline" yaml:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata" yaml:"metadata"`
|
||||
|
||||
// Spec is the spec of the Dashboard
|
||||
Spec DashboardSpec `json:"spec" yaml:"spec"`
|
||||
|
||||
Status DashboardStatus `json:"status" yaml:"status"`
|
||||
}
|
||||
|
||||
func (o *Dashboard) GetSpec() any {
|
||||
return o.Spec
|
||||
}
|
||||
|
||||
func (o *Dashboard) SetSpec(spec any) error {
|
||||
cast, ok := spec.(DashboardSpec)
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec)
|
||||
}
|
||||
o.Spec = cast
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *Dashboard) GetSubresources() map[string]any {
|
||||
return map[string]any{
|
||||
"status": o.Status,
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Dashboard) GetSubresource(name string) (any, bool) {
|
||||
switch name {
|
||||
case "status":
|
||||
return o.Status, true
|
||||
default:
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Dashboard) SetSubresource(name string, value any) error {
|
||||
switch name {
|
||||
case "status":
|
||||
cast, ok := value.(DashboardStatus)
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot set status type %#v, not of type DashboardStatus", value)
|
||||
}
|
||||
o.Status = cast
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("subresource '%s' does not exist", name)
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Dashboard) GetStaticMetadata() resource.StaticMetadata {
|
||||
gvk := o.GroupVersionKind()
|
||||
return resource.StaticMetadata{
|
||||
Name: o.ObjectMeta.Name,
|
||||
Namespace: o.ObjectMeta.Namespace,
|
||||
Group: gvk.Group,
|
||||
Version: gvk.Version,
|
||||
Kind: gvk.Kind,
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Dashboard) SetStaticMetadata(metadata resource.StaticMetadata) {
|
||||
o.Name = metadata.Name
|
||||
o.Namespace = metadata.Namespace
|
||||
o.SetGroupVersionKind(schema.GroupVersionKind{
|
||||
Group: metadata.Group,
|
||||
Version: metadata.Version,
|
||||
Kind: metadata.Kind,
|
||||
})
|
||||
}
|
||||
|
||||
func (o *Dashboard) GetCommonMetadata() resource.CommonMetadata {
|
||||
dt := o.DeletionTimestamp
|
||||
var deletionTimestamp *time.Time
|
||||
if dt != nil {
|
||||
deletionTimestamp = &dt.Time
|
||||
}
|
||||
// Legacy ExtraFields support
|
||||
extraFields := make(map[string]any)
|
||||
if o.Annotations != nil {
|
||||
extraFields["annotations"] = o.Annotations
|
||||
}
|
||||
if o.ManagedFields != nil {
|
||||
extraFields["managedFields"] = o.ManagedFields
|
||||
}
|
||||
if o.OwnerReferences != nil {
|
||||
extraFields["ownerReferences"] = o.OwnerReferences
|
||||
}
|
||||
return resource.CommonMetadata{
|
||||
UID: string(o.UID),
|
||||
ResourceVersion: o.ResourceVersion,
|
||||
Generation: o.Generation,
|
||||
Labels: o.Labels,
|
||||
CreationTimestamp: o.CreationTimestamp.Time,
|
||||
DeletionTimestamp: deletionTimestamp,
|
||||
Finalizers: o.Finalizers,
|
||||
UpdateTimestamp: o.GetUpdateTimestamp(),
|
||||
CreatedBy: o.GetCreatedBy(),
|
||||
UpdatedBy: o.GetUpdatedBy(),
|
||||
ExtraFields: extraFields,
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Dashboard) SetCommonMetadata(metadata resource.CommonMetadata) {
|
||||
o.UID = types.UID(metadata.UID)
|
||||
o.ResourceVersion = metadata.ResourceVersion
|
||||
o.Generation = metadata.Generation
|
||||
o.Labels = metadata.Labels
|
||||
o.CreationTimestamp = metav1.NewTime(metadata.CreationTimestamp)
|
||||
if metadata.DeletionTimestamp != nil {
|
||||
dt := metav1.NewTime(*metadata.DeletionTimestamp)
|
||||
o.DeletionTimestamp = &dt
|
||||
} else {
|
||||
o.DeletionTimestamp = nil
|
||||
}
|
||||
o.Finalizers = metadata.Finalizers
|
||||
if o.Annotations == nil {
|
||||
o.Annotations = make(map[string]string)
|
||||
}
|
||||
if !metadata.UpdateTimestamp.IsZero() {
|
||||
o.SetUpdateTimestamp(metadata.UpdateTimestamp)
|
||||
}
|
||||
if metadata.CreatedBy != "" {
|
||||
o.SetCreatedBy(metadata.CreatedBy)
|
||||
}
|
||||
if metadata.UpdatedBy != "" {
|
||||
o.SetUpdatedBy(metadata.UpdatedBy)
|
||||
}
|
||||
// Legacy support for setting Annotations, ManagedFields, and OwnerReferences via ExtraFields
|
||||
if metadata.ExtraFields != nil {
|
||||
if annotations, ok := metadata.ExtraFields["annotations"]; ok {
|
||||
if cast, ok := annotations.(map[string]string); ok {
|
||||
o.Annotations = cast
|
||||
}
|
||||
}
|
||||
if managedFields, ok := metadata.ExtraFields["managedFields"]; ok {
|
||||
if cast, ok := managedFields.([]metav1.ManagedFieldsEntry); ok {
|
||||
o.ManagedFields = cast
|
||||
}
|
||||
}
|
||||
if ownerReferences, ok := metadata.ExtraFields["ownerReferences"]; ok {
|
||||
if cast, ok := ownerReferences.([]metav1.OwnerReference); ok {
|
||||
o.OwnerReferences = cast
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Dashboard) GetCreatedBy() string {
|
||||
if o.ObjectMeta.Annotations == nil {
|
||||
o.ObjectMeta.Annotations = make(map[string]string)
|
||||
}
|
||||
|
||||
return o.ObjectMeta.Annotations["grafana.com/createdBy"]
|
||||
}
|
||||
|
||||
func (o *Dashboard) SetCreatedBy(createdBy string) {
|
||||
if o.ObjectMeta.Annotations == nil {
|
||||
o.ObjectMeta.Annotations = make(map[string]string)
|
||||
}
|
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/createdBy"] = createdBy
|
||||
}
|
||||
|
||||
func (o *Dashboard) GetUpdateTimestamp() time.Time {
|
||||
if o.ObjectMeta.Annotations == nil {
|
||||
o.ObjectMeta.Annotations = make(map[string]string)
|
||||
}
|
||||
|
||||
parsed, _ := time.Parse(time.RFC3339, o.ObjectMeta.Annotations["grafana.com/updateTimestamp"])
|
||||
return parsed
|
||||
}
|
||||
|
||||
func (o *Dashboard) SetUpdateTimestamp(updateTimestamp time.Time) {
|
||||
if o.ObjectMeta.Annotations == nil {
|
||||
o.ObjectMeta.Annotations = make(map[string]string)
|
||||
}
|
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/updateTimestamp"] = updateTimestamp.Format(time.RFC3339)
|
||||
}
|
||||
|
||||
func (o *Dashboard) GetUpdatedBy() string {
|
||||
if o.ObjectMeta.Annotations == nil {
|
||||
o.ObjectMeta.Annotations = make(map[string]string)
|
||||
}
|
||||
|
||||
return o.ObjectMeta.Annotations["grafana.com/updatedBy"]
|
||||
}
|
||||
|
||||
func (o *Dashboard) SetUpdatedBy(updatedBy string) {
|
||||
if o.ObjectMeta.Annotations == nil {
|
||||
o.ObjectMeta.Annotations = make(map[string]string)
|
||||
}
|
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/updatedBy"] = updatedBy
|
||||
}
|
||||
|
||||
func (o *Dashboard) Copy() resource.Object {
|
||||
return resource.CopyObject(o)
|
||||
}
|
||||
|
||||
func (o *Dashboard) DeepCopyObject() runtime.Object {
|
||||
return o.Copy()
|
||||
}
|
||||
|
||||
func (o *Dashboard) DeepCopy() *Dashboard {
|
||||
cpy := &Dashboard{}
|
||||
o.DeepCopyInto(cpy)
|
||||
return cpy
|
||||
}
|
||||
|
||||
func (o *Dashboard) DeepCopyInto(dst *Dashboard) {
|
||||
dst.TypeMeta.APIVersion = o.TypeMeta.APIVersion
|
||||
dst.TypeMeta.Kind = o.TypeMeta.Kind
|
||||
o.ObjectMeta.DeepCopyInto(&dst.ObjectMeta)
|
||||
o.Spec.DeepCopyInto(&dst.Spec)
|
||||
o.Status.DeepCopyInto(&dst.Status)
|
||||
}
|
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.Object = &Dashboard{}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardList struct {
|
||||
metav1.TypeMeta `json:",inline" yaml:",inline"`
|
||||
metav1.ListMeta `json:"metadata" yaml:"metadata"`
|
||||
Items []Dashboard `json:"items" yaml:"items"`
|
||||
}
|
||||
|
||||
func (o *DashboardList) DeepCopyObject() runtime.Object {
|
||||
return o.Copy()
|
||||
}
|
||||
|
||||
func (o *DashboardList) Copy() resource.ListObject {
|
||||
cpy := &DashboardList{
|
||||
TypeMeta: o.TypeMeta,
|
||||
Items: make([]Dashboard, len(o.Items)),
|
||||
}
|
||||
o.ListMeta.DeepCopyInto(&cpy.ListMeta)
|
||||
for i := 0; i < len(o.Items); i++ {
|
||||
if item, ok := o.Items[i].Copy().(*Dashboard); ok {
|
||||
cpy.Items[i] = *item
|
||||
}
|
||||
}
|
||||
return cpy
|
||||
}
|
||||
|
||||
func (o *DashboardList) GetItems() []resource.Object {
|
||||
items := make([]resource.Object, len(o.Items))
|
||||
for i := 0; i < len(o.Items); i++ {
|
||||
items[i] = &o.Items[i]
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func (o *DashboardList) SetItems(items []resource.Object) {
|
||||
o.Items = make([]Dashboard, len(items))
|
||||
for i := 0; i < len(items); i++ {
|
||||
o.Items[i] = *items[i].(*Dashboard)
|
||||
}
|
||||
}
|
||||
|
||||
func (o *DashboardList) DeepCopy() *DashboardList {
|
||||
cpy := &DashboardList{}
|
||||
o.DeepCopyInto(cpy)
|
||||
return cpy
|
||||
}
|
||||
|
||||
func (o *DashboardList) DeepCopyInto(dst *DashboardList) {
|
||||
resource.CopyObjectInto(dst, o)
|
||||
}
|
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.ListObject = &DashboardList{}
|
||||
|
||||
// Copy methods for all subresource types
|
||||
|
||||
// DeepCopy creates a full deep copy of Spec
|
||||
func (s *DashboardSpec) DeepCopy() *DashboardSpec {
|
||||
cpy := &DashboardSpec{}
|
||||
s.DeepCopyInto(cpy)
|
||||
return cpy
|
||||
}
|
||||
|
||||
// DeepCopyInto deep copies Spec into another Spec object
|
||||
func (s *DashboardSpec) DeepCopyInto(dst *DashboardSpec) {
|
||||
resource.CopyObjectInto(dst, s)
|
||||
}
|
||||
|
||||
// DeepCopy creates a full deep copy of DashboardStatus
|
||||
func (s *DashboardStatus) DeepCopy() *DashboardStatus {
|
||||
cpy := &DashboardStatus{}
|
||||
s.DeepCopyInto(cpy)
|
||||
return cpy
|
||||
}
|
||||
|
||||
// DeepCopyInto deep copies DashboardStatus into another DashboardStatus object
|
||||
func (s *DashboardStatus) DeepCopyInto(dst *DashboardStatus) {
|
||||
resource.CopyObjectInto(dst, s)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v2alpha2
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana-app-sdk/resource"
|
||||
)
|
||||
|
||||
// schema is unexported to prevent accidental overwrites
|
||||
var (
|
||||
schemaDashboard = resource.NewSimpleSchema("dashboard.grafana.app", "v2alpha2", &Dashboard{}, &DashboardList{}, resource.WithKind("Dashboard"),
|
||||
resource.WithPlural("dashboards"), resource.WithScope(resource.NamespacedScope))
|
||||
kindDashboard = resource.Kind{
|
||||
Schema: schemaDashboard,
|
||||
Codecs: map[resource.KindEncoding]resource.Codec{
|
||||
resource.KindEncodingJSON: &DashboardJSONCodec{},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// Kind returns a resource.Kind for this Schema with a JSON codec
|
||||
func DashboardKind() resource.Kind {
|
||||
return kindDashboard
|
||||
}
|
||||
|
||||
// Schema returns a resource.SimpleSchema representation of Dashboard
|
||||
func DashboardSchema() *resource.SimpleSchema {
|
||||
return schemaDashboard
|
||||
}
|
||||
|
||||
// Interface compliance checks
|
||||
var _ resource.Schema = kindDashboard
|
||||
968
apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_spec.cue
Normal file
968
apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_spec.cue
Normal file
@@ -0,0 +1,968 @@
|
||||
// This file is managed by grafana-app-sdk - DO NOT EDIT MANUALLY
|
||||
// Source: apps/dashboard/kinds/v2alpha2/dashboard_spec.cue
|
||||
// To sync changes, run: make generate in apps/dashboard
|
||||
|
||||
package v2alpha2
|
||||
|
||||
DashboardSpec: {
|
||||
annotations: [...AnnotationQueryKind] | *[]
|
||||
|
||||
// Configuration of dashboard cursor sync behavior.
|
||||
// "Off" for no shared crosshair or tooltip (default).
|
||||
// "Crosshair" for shared crosshair.
|
||||
// "Tooltip" for shared crosshair AND shared tooltip.
|
||||
cursorSync: DashboardCursorSync
|
||||
|
||||
// Description of dashboard.
|
||||
description?: string
|
||||
|
||||
// Whether a dashboard is editable or not.
|
||||
editable?: bool | *true
|
||||
|
||||
elements: [ElementReference.name]: Element | *{}
|
||||
|
||||
layout: GridLayoutKind | RowsLayoutKind | AutoGridLayoutKind | TabsLayoutKind
|
||||
|
||||
// Links with references to other dashboards or external websites.
|
||||
links: [...DashboardLink] | *[]
|
||||
|
||||
// When set to true, the dashboard will redraw panels at an interval matching the pixel width.
|
||||
// This will keep data "moving left" regardless of the query refresh rate. This setting helps
|
||||
// avoid dashboards presenting stale live data.
|
||||
liveNow?: bool
|
||||
|
||||
// When set to true, the dashboard will load all panels in the dashboard when it's loaded.
|
||||
preload: bool | *false
|
||||
|
||||
// Plugins only. The version of the dashboard installed together with the plugin.
|
||||
// This is used to determine if the dashboard should be updated when the plugin is updated.
|
||||
revision?: uint16
|
||||
|
||||
// Tags associated with dashboard.
|
||||
tags: [...string] | *[]
|
||||
|
||||
timeSettings: TimeSettingsSpec
|
||||
|
||||
// Title of dashboard.
|
||||
title: string
|
||||
|
||||
// Configured template variables.
|
||||
variables: [...VariableKind] | *[]
|
||||
}
|
||||
|
||||
// Supported dashboard elements
|
||||
Element: PanelKind | LibraryPanelKind // |* more element types in the future
|
||||
|
||||
LibraryPanelKind: {
|
||||
kind: "LibraryPanel"
|
||||
spec: LibraryPanelKindSpec
|
||||
}
|
||||
|
||||
LibraryPanelKindSpec: {
|
||||
// Panel ID for the library panel in the dashboard
|
||||
id: number
|
||||
// Title for the library panel in the dashboard
|
||||
title: string
|
||||
|
||||
libraryPanel: LibraryPanelRef
|
||||
}
|
||||
|
||||
// A library panel is a reusable panel that you can use in any dashboard.
|
||||
// When you make a change to a library panel, that change propagates to all instances of where the panel is used.
|
||||
// Library panels streamline reuse of panels across multiple dashboards.
|
||||
LibraryPanelRef: {
|
||||
// Library panel name
|
||||
name: string
|
||||
// Library panel uid
|
||||
uid: string
|
||||
}
|
||||
|
||||
AnnotationPanelFilter: {
|
||||
// Should the specified panels be included or excluded
|
||||
exclude?: bool | *false
|
||||
|
||||
// Panel IDs that should be included or excluded
|
||||
ids: [...uint32]
|
||||
}
|
||||
|
||||
// "Off" for no shared crosshair or tooltip (default).
|
||||
// "Crosshair" for shared crosshair.
|
||||
// "Tooltip" for shared crosshair AND shared tooltip.
|
||||
DashboardCursorSync: "Crosshair" | "Tooltip" | *"Off"
|
||||
|
||||
// Links with references to other dashboards or external resources
|
||||
DashboardLink: {
|
||||
// Title to display with the link
|
||||
title: string
|
||||
// Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource)
|
||||
// FIXME: The type is generated as `type: DashboardLinkType | dashboardLinkType.Link;` but it should be `type: DashboardLinkType`
|
||||
type: DashboardLinkType
|
||||
// Icon name to be displayed with the link
|
||||
icon: string
|
||||
// Tooltip to display when the user hovers their mouse over it
|
||||
tooltip: string
|
||||
// Link URL. Only required/valid if the type is link
|
||||
url?: string
|
||||
// List of tags to limit the linked dashboards. If empty, all dashboards will be displayed. Only valid if the type is dashboards
|
||||
tags: [...string] | *[]
|
||||
// If true, all dashboards links will be displayed in a dropdown. If false, all dashboards links will be displayed side by side. Only valid if the type is dashboards
|
||||
asDropdown: bool | *false
|
||||
// If true, the link will be opened in a new tab
|
||||
targetBlank: bool | *false
|
||||
// If true, includes current template variables values in the link as query params
|
||||
includeVars: bool | *false
|
||||
// If true, includes current time range in the link as query params
|
||||
keepTime: bool | *false
|
||||
}
|
||||
|
||||
DataSourceRef: {
|
||||
// The plugin type-id
|
||||
type?: string
|
||||
|
||||
// Specific datasource instance
|
||||
uid?: string
|
||||
}
|
||||
|
||||
// A topic is attached to DataFrame metadata in query results.
|
||||
// This specifies where the data should be used.
|
||||
DataTopic: "series" | "annotations" | "alertStates" @cog(kind="enum",memberNames="Series|Annotations|AlertStates")
|
||||
|
||||
// Transformations allow to manipulate data returned by a query before the system applies a visualization.
|
||||
// Using transformations you can: rename fields, join time series data, perform mathematical operations across queries,
|
||||
// use the output of one transformation as the input to another transformation, etc.
|
||||
DataTransformerConfig: {
|
||||
// Unique identifier of transformer
|
||||
id: string
|
||||
// Disabled transformations are skipped
|
||||
disabled?: bool
|
||||
// Optional frame matcher. When missing it will be applied to all results
|
||||
filter?: MatcherConfig
|
||||
// Where to pull DataFrames from as input to transformation
|
||||
topic?: DataTopic
|
||||
// Options to be passed to the transformer
|
||||
// Valid options depend on the transformer id
|
||||
options: _
|
||||
}
|
||||
|
||||
DataLink: {
|
||||
title: string
|
||||
url: string
|
||||
targetBlank?: bool
|
||||
}
|
||||
|
||||
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
|
||||
// Each column within this structure is called a field. A field can represent a single time series or table column.
|
||||
// Field options allow you to change how the data is displayed in your visualizations.
|
||||
FieldConfigSource: {
|
||||
// Defaults are the options applied to all fields.
|
||||
defaults: FieldConfig
|
||||
// Overrides are the options applied to specific fields overriding the defaults.
|
||||
overrides: [...{
|
||||
matcher: MatcherConfig
|
||||
properties: [...DynamicConfigValue]
|
||||
}]
|
||||
}
|
||||
|
||||
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
|
||||
// Each column within this structure is called a field. A field can represent a single time series or table column.
|
||||
// Field options allow you to change how the data is displayed in your visualizations.
|
||||
FieldConfig: {
|
||||
// The display value for this field. This supports template variables blank is auto
|
||||
displayName?: string
|
||||
|
||||
// This can be used by data sources that return and explicit naming structure for values and labels
|
||||
// When this property is configured, this value is used rather than the default naming strategy.
|
||||
displayNameFromDS?: string
|
||||
|
||||
// Human readable field metadata
|
||||
description?: string
|
||||
|
||||
// An explicit path to the field in the datasource. When the frame meta includes a path,
|
||||
// This will default to `${frame.meta.path}/${field.name}
|
||||
//
|
||||
// When defined, this value can be used as an identifier within the datasource scope, and
|
||||
// may be used to update the results
|
||||
path?: string
|
||||
|
||||
// True if data source can write a value to the path. Auth/authz are supported separately
|
||||
writeable?: bool
|
||||
|
||||
// True if data source field supports ad-hoc filters
|
||||
filterable?: bool
|
||||
|
||||
// Unit a field should use. The unit you select is applied to all fields except time.
|
||||
// You can use the units ID availables in Grafana or a custom unit.
|
||||
// Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts
|
||||
// As custom unit, you can use the following formats:
|
||||
// `suffix:<suffix>` for custom unit that should go after value.
|
||||
// `prefix:<prefix>` for custom unit that should go before value.
|
||||
// `time:<format>` For custom date time formats type for example `time:YYYY-MM-DD`.
|
||||
// `si:<base scale><unit characters>` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character.
|
||||
// `count:<unit>` for a custom count unit.
|
||||
// `currency:<unit>` for custom a currency unit.
|
||||
unit?: string
|
||||
|
||||
// Specify the number of decimals Grafana includes in the rendered value.
|
||||
// If you leave this field blank, Grafana automatically truncates the number of decimals based on the value.
|
||||
// For example 1.1234 will display as 1.12 and 100.456 will display as 100.
|
||||
// To display all decimals, set the unit to `String`.
|
||||
decimals?: number
|
||||
|
||||
// The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
|
||||
min?: number
|
||||
// The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
|
||||
max?: number
|
||||
|
||||
// Convert input values into a display string
|
||||
mappings?: [...ValueMapping]
|
||||
|
||||
// Map numeric values to states
|
||||
thresholds?: ThresholdsConfig
|
||||
|
||||
// Panel color configuration
|
||||
color?: FieldColor
|
||||
|
||||
// The behavior when clicking on a result
|
||||
links?: [...]
|
||||
|
||||
// Alternative to empty string
|
||||
noValue?: string
|
||||
|
||||
// custom is specified by the FieldConfig field
|
||||
// in panel plugin schemas.
|
||||
custom?: {...}
|
||||
}
|
||||
|
||||
DynamicConfigValue: {
|
||||
id: string | *""
|
||||
value?: _
|
||||
}
|
||||
|
||||
// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
|
||||
// It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type.
|
||||
MatcherConfig: {
|
||||
// The matcher id. This is used to find the matcher implementation from registry.
|
||||
id: string | *""
|
||||
// The matcher options. This is specific to the matcher implementation.
|
||||
options?: _
|
||||
}
|
||||
|
||||
Threshold: {
|
||||
value: number
|
||||
color: string
|
||||
}
|
||||
|
||||
ThresholdsMode: "absolute" | "percentage"
|
||||
|
||||
ThresholdsConfig: {
|
||||
mode: ThresholdsMode
|
||||
steps: [...Threshold]
|
||||
}
|
||||
|
||||
ValueMapping: ValueMap | RangeMap | RegexMap | SpecialValueMap
|
||||
|
||||
// Supported value mapping types
|
||||
// `value`: Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
|
||||
// `range`: Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
|
||||
// `regex`: Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
|
||||
// `special`: Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A.
|
||||
MappingType: "value" | "range" | "regex" | "special"
|
||||
|
||||
// Maps text values to a color or different display text and color.
|
||||
// For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
|
||||
ValueMap: {
|
||||
type: MappingType & "value"
|
||||
// Map with <value_to_match>: ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } }
|
||||
options: [string]: ValueMappingResult
|
||||
}
|
||||
|
||||
// Maps numerical ranges to a display text and color.
|
||||
// For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
|
||||
RangeMap: {
|
||||
type: MappingType & "range"
|
||||
// Range to match against and the result to apply when the value is within the range
|
||||
options: {
|
||||
// Min value of the range. It can be null which means -Infinity
|
||||
from: float64 | null
|
||||
// Max value of the range. It can be null which means +Infinity
|
||||
to: float64 | null
|
||||
// Config to apply when the value is within the range
|
||||
result: ValueMappingResult
|
||||
}
|
||||
}
|
||||
|
||||
// Maps regular expressions to replacement text and a color.
|
||||
// For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
|
||||
RegexMap: {
|
||||
type: MappingType & "regex"
|
||||
// Regular expression to match against and the result to apply when the value matches the regex
|
||||
options: {
|
||||
// Regular expression to match against
|
||||
pattern: string
|
||||
// Config to apply when the value matches the regex
|
||||
result: ValueMappingResult
|
||||
}
|
||||
}
|
||||
|
||||
// Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color.
|
||||
// See SpecialValueMatch to see the list of special values.
|
||||
// For example, you can configure a special value mapping so that null values appear as N/A.
|
||||
SpecialValueMap: {
|
||||
type: MappingType & "special"
|
||||
options: {
|
||||
// Special value to match against
|
||||
match: SpecialValueMatch
|
||||
// Config to apply when the value matches the special value
|
||||
result: ValueMappingResult
|
||||
}
|
||||
}
|
||||
|
||||
// Special value types supported by the `SpecialValueMap`
|
||||
SpecialValueMatch: "true" | "false" | "null" | "nan" | "null+nan" | "empty" @cog(kind="enum",memberNames="True|False|Null|NaN|NullAndNaN|Empty")
|
||||
|
||||
// Result used as replacement with text and color when the value matches
|
||||
ValueMappingResult: {
|
||||
// Text to display when the value matches
|
||||
text?: string
|
||||
// Text to use when the value matches
|
||||
color?: string
|
||||
// Icon to display when the value matches. Only specific visualizations.
|
||||
icon?: string
|
||||
// Position in the mapping array. Only used internally.
|
||||
index?: int32
|
||||
}
|
||||
|
||||
// Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value.
|
||||
// Continuous color interpolates a color using the percentage of a value relative to min and max.
|
||||
// Accepted values are:
|
||||
// `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold
|
||||
// `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations
|
||||
// `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations
|
||||
// `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode
|
||||
// `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode
|
||||
// `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode
|
||||
// `continuous-YlRd`: Continuous Yellow-Red palette mode
|
||||
// `continuous-BlPu`: Continuous Blue-Purple palette mode
|
||||
// `continuous-YlBl`: Continuous Yellow-Blue palette mode
|
||||
// `continuous-blues`: Continuous Blue palette mode
|
||||
// `continuous-reds`: Continuous Red palette mode
|
||||
// `continuous-greens`: Continuous Green palette mode
|
||||
// `continuous-purples`: Continuous Purple palette mode
|
||||
// `shades`: Shades of a single color. Specify a single color, useful in an override rule.
|
||||
// `fixed`: Fixed color mode. Specify a single color, useful in an override rule.
|
||||
FieldColorModeId: "thresholds" | "palette-classic" | "palette-classic-by-name" | "continuous-GrYlRd" | "continuous-RdYlGr" | "continuous-BlYlRd" | "continuous-YlRd" | "continuous-BlPu" | "continuous-YlBl" | "continuous-blues" | "continuous-reds" | "continuous-greens" | "continuous-purples" | "fixed" | "shades"
|
||||
|
||||
// Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value.
|
||||
FieldColorSeriesByMode: "min" | "max" | "last"
|
||||
|
||||
// Map a field to a color.
|
||||
FieldColor: {
|
||||
// The main color scheme mode.
|
||||
mode: FieldColorModeId
|
||||
// The fixed color value for fixed or shades color modes.
|
||||
fixedColor?: string
|
||||
// Some visualizations need to know how to assign a series color from by value color schemes.
|
||||
seriesBy?: FieldColorSeriesByMode
|
||||
}
|
||||
|
||||
// Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource)
|
||||
DashboardLinkType: "link" | "dashboards"
|
||||
|
||||
// --- Common types ---
|
||||
Kind: {
|
||||
kind: string
|
||||
spec: _
|
||||
metadata?: _
|
||||
}
|
||||
|
||||
// --- Kinds ---
|
||||
VizConfigSpec: {
|
||||
pluginVersion: string
|
||||
options: [string]: _
|
||||
fieldConfig: FieldConfigSource
|
||||
}
|
||||
|
||||
VizConfigKind: {
|
||||
// The kind of a VizConfigKind is the plugin ID
|
||||
kind: string
|
||||
spec: VizConfigSpec
|
||||
}
|
||||
|
||||
AnnotationQuerySpec: {
|
||||
datasource?: DataSourceRef
|
||||
query?: DataQueryKind
|
||||
enable: bool
|
||||
hide: bool
|
||||
iconColor: string
|
||||
name: string
|
||||
builtIn?: bool | *false
|
||||
filter?: AnnotationPanelFilter
|
||||
legacyOptions?: [string]: _ //Catch-all field for datasource-specific properties
|
||||
}
|
||||
|
||||
AnnotationQueryKind: {
|
||||
kind: "AnnotationQuery"
|
||||
spec: AnnotationQuerySpec
|
||||
}
|
||||
|
||||
QueryOptionsSpec: {
|
||||
timeFrom?: string
|
||||
maxDataPoints?: int
|
||||
timeShift?: string
|
||||
queryCachingTTL?: int
|
||||
interval?: string
|
||||
cacheTimeout?: string
|
||||
hideTimeOverride?: bool
|
||||
}
|
||||
|
||||
DataQueryKind: {
|
||||
// The kind of a DataQueryKind is the datasource type
|
||||
kind: string
|
||||
spec: [string]: _
|
||||
}
|
||||
|
||||
PanelQuerySpec: {
|
||||
query: DataQueryKind
|
||||
datasource?: DataSourceRef
|
||||
|
||||
refId: string
|
||||
hidden: bool
|
||||
}
|
||||
|
||||
PanelQueryKind: {
|
||||
kind: "PanelQuery"
|
||||
spec: PanelQuerySpec
|
||||
}
|
||||
|
||||
TransformationKind: {
|
||||
// The kind of a TransformationKind is the transformation ID
|
||||
kind: string
|
||||
spec: DataTransformerConfig
|
||||
}
|
||||
|
||||
QueryGroupSpec: {
|
||||
queries: [...PanelQueryKind]
|
||||
transformations: [...TransformationKind]
|
||||
queryOptions: QueryOptionsSpec
|
||||
}
|
||||
|
||||
QueryGroupKind: {
|
||||
kind: "QueryGroup"
|
||||
spec: QueryGroupSpec
|
||||
}
|
||||
|
||||
TimeRangeOption: {
|
||||
display: string | *"Last 6 hours"
|
||||
from: string | *"now-6h"
|
||||
to: string | *"now"
|
||||
}
|
||||
|
||||
// Time configuration
|
||||
// It defines the default time config for the time picker, the refresh picker for the specific dashboard.
|
||||
TimeSettingsSpec: {
|
||||
// Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc".
|
||||
timezone?: string | *"browser"
|
||||
// Start time range for dashboard.
|
||||
// Accepted values are relative time strings like "now-6h" or absolute time strings like "2020-07-10T08:00:00.000Z".
|
||||
from: string | *"now-6h"
|
||||
// End time range for dashboard.
|
||||
// Accepted values are relative time strings like "now-6h" or absolute time strings like "2020-07-10T08:00:00.000Z".
|
||||
to: string | *"now"
|
||||
// Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
|
||||
autoRefresh: string | *"" // v1: refresh
|
||||
// Interval options available in the refresh picker dropdown.
|
||||
autoRefreshIntervals: [...string] | *["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"] // v1: timepicker.refresh_intervals
|
||||
// Selectable options available in the time picker dropdown. Has no effect on provisioned dashboard.
|
||||
quickRanges?: [...TimeRangeOption] // v1: timepicker.quick_ranges , not exposed in the UI
|
||||
// Whether timepicker is visible or not.
|
||||
hideTimepicker: bool | *false // v1: timepicker.hidden
|
||||
// Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday".
|
||||
weekStart?: "saturday" | "monday" | "sunday"
|
||||
// The month that the fiscal year starts on. 0 = January, 11 = December
|
||||
fiscalYearStartMonth: int | *0
|
||||
// Override the now time by entering a time delay. Use this option to accommodate known delays in data aggregation to avoid null values.
|
||||
nowDelay?: string // v1: timepicker.nowDelay
|
||||
}
|
||||
|
||||
RepeatMode: "variable" // other repeat modes will be added in the future: label, frame
|
||||
|
||||
RepeatOptions: {
|
||||
mode: RepeatMode
|
||||
value: string
|
||||
direction?: "h" | "v"
|
||||
maxPerRow?: int
|
||||
}
|
||||
|
||||
RowRepeatOptions: {
|
||||
mode: RepeatMode
|
||||
value: string
|
||||
}
|
||||
|
||||
TabRepeatOptions: {
|
||||
mode: RepeatMode
|
||||
value: string
|
||||
}
|
||||
|
||||
AutoGridRepeatOptions: {
|
||||
mode: RepeatMode
|
||||
value: string
|
||||
}
|
||||
|
||||
GridLayoutItemSpec: {
|
||||
x: int
|
||||
y: int
|
||||
width: int
|
||||
height: int
|
||||
element: ElementReference // reference to a PanelKind from dashboard.spec.elements Expressed as JSON Schema reference
|
||||
repeat?: RepeatOptions
|
||||
}
|
||||
|
||||
GridLayoutItemKind: {
|
||||
kind: "GridLayoutItem"
|
||||
spec: GridLayoutItemSpec
|
||||
}
|
||||
|
||||
GridLayoutSpec: {
|
||||
items: [...GridLayoutItemKind]
|
||||
}
|
||||
|
||||
GridLayoutKind: {
|
||||
kind: "GridLayout"
|
||||
spec: GridLayoutSpec
|
||||
}
|
||||
|
||||
RowsLayoutKind: {
|
||||
kind: "RowsLayout"
|
||||
spec: RowsLayoutSpec
|
||||
}
|
||||
|
||||
RowsLayoutSpec: {
|
||||
rows: [...RowsLayoutRowKind]
|
||||
}
|
||||
|
||||
RowsLayoutRowKind: {
|
||||
kind: "RowsLayoutRow"
|
||||
spec: RowsLayoutRowSpec
|
||||
}
|
||||
|
||||
RowsLayoutRowSpec: {
|
||||
title?: string
|
||||
collapse?: bool
|
||||
hideHeader?: bool
|
||||
fillScreen?: bool
|
||||
conditionalRendering?: ConditionalRenderingGroupKind
|
||||
repeat?: RowRepeatOptions
|
||||
layout: GridLayoutKind | AutoGridLayoutKind | TabsLayoutKind | RowsLayoutKind
|
||||
}
|
||||
|
||||
AutoGridLayoutKind: {
|
||||
kind: "AutoGridLayout"
|
||||
spec: AutoGridLayoutSpec
|
||||
}
|
||||
|
||||
AutoGridLayoutSpec: {
|
||||
maxColumnCount?: number | *3
|
||||
columnWidthMode: "narrow" | *"standard" | "wide" | "custom"
|
||||
columnWidth?: number
|
||||
rowHeightMode: "short" | *"standard" | "tall" | "custom"
|
||||
rowHeight?: number
|
||||
fillScreen?: bool | *false
|
||||
items: [...AutoGridLayoutItemKind]
|
||||
}
|
||||
|
||||
AutoGridLayoutItemKind: {
|
||||
kind: "AutoGridLayoutItem"
|
||||
spec: AutoGridLayoutItemSpec
|
||||
}
|
||||
|
||||
AutoGridLayoutItemSpec: {
|
||||
element: ElementReference
|
||||
repeat?: AutoGridRepeatOptions
|
||||
conditionalRendering?: ConditionalRenderingGroupKind
|
||||
}
|
||||
|
||||
TabsLayoutKind: {
|
||||
kind: "TabsLayout"
|
||||
spec: TabsLayoutSpec
|
||||
}
|
||||
|
||||
TabsLayoutSpec: {
|
||||
tabs: [...TabsLayoutTabKind]
|
||||
}
|
||||
|
||||
TabsLayoutTabKind: {
|
||||
kind: "TabsLayoutTab"
|
||||
spec: TabsLayoutTabSpec
|
||||
}
|
||||
|
||||
TabsLayoutTabSpec: {
|
||||
title?: string
|
||||
layout: GridLayoutKind | RowsLayoutKind | AutoGridLayoutKind | TabsLayoutKind
|
||||
conditionalRendering?: ConditionalRenderingGroupKind
|
||||
repeat?: TabRepeatOptions
|
||||
}
|
||||
|
||||
PanelSpec: {
|
||||
id: number
|
||||
title: string
|
||||
description: string
|
||||
links: [...DataLink]
|
||||
data: QueryGroupKind
|
||||
vizConfig: VizConfigKind
|
||||
transparent?: bool
|
||||
}
|
||||
|
||||
PanelKind: {
|
||||
kind: "Panel"
|
||||
spec: PanelSpec
|
||||
}
|
||||
|
||||
ElementReference: {
|
||||
kind: "ElementReference"
|
||||
name: string
|
||||
}
|
||||
|
||||
// Start FIXME: variables - in CUE PR - this are things that should be added into the cue schema
|
||||
// TODO: properties such as `hide`, `skipUrlSync`, `multi` are type boolean, and in the old schema they are conditional,
|
||||
// should we make them conditional in the new schema as well? or should we make them required but default to false?
|
||||
|
||||
// Variable types
|
||||
VariableValue: VariableValueSingle | [...VariableValueSingle]
|
||||
|
||||
VariableValueSingle: string | bool | number | CustomVariableValue
|
||||
|
||||
// Custom formatter variable
|
||||
CustomFormatterVariable: {
|
||||
name: string
|
||||
type: VariableType
|
||||
multi: bool
|
||||
includeAll: bool
|
||||
}
|
||||
|
||||
// Custom variable value
|
||||
CustomVariableValue: {
|
||||
// The format name or function used in the expression
|
||||
formatter: *null | string | VariableCustomFormatterFn
|
||||
}
|
||||
|
||||
// Custom formatter function
|
||||
VariableCustomFormatterFn: {
|
||||
value: _
|
||||
legacyVariableModel: {
|
||||
name: string
|
||||
type: VariableType
|
||||
multi: bool
|
||||
includeAll: bool
|
||||
}
|
||||
legacyDefaultFormatter?: VariableCustomFormatterFn
|
||||
}
|
||||
|
||||
// Dashboard variable type
|
||||
// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
|
||||
// `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
|
||||
// `constant`: Define a hidden constant.
|
||||
// `datasource`: Quickly change the data source for an entire dashboard.
|
||||
// `interval`: Interval variables represent time spans.
|
||||
// `textbox`: Display a free text input field with an optional default value.
|
||||
// `custom`: Define the variable options manually using a comma-separated list.
|
||||
// `system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables
|
||||
VariableType: "query" | "adhoc" | "groupby" | "constant" | "datasource" | "interval" | "textbox" | "custom" |
|
||||
"system" | "snapshot"
|
||||
|
||||
VariableKind: QueryVariableKind | TextVariableKind | ConstantVariableKind | DatasourceVariableKind | IntervalVariableKind | CustomVariableKind | GroupByVariableKind | AdhocVariableKind
|
||||
|
||||
// Sort variable options
|
||||
// Accepted values are:
|
||||
// `disabled`: No sorting
|
||||
// `alphabeticalAsc`: Alphabetical ASC
|
||||
// `alphabeticalDesc`: Alphabetical DESC
|
||||
// `numericalAsc`: Numerical ASC
|
||||
// `numericalDesc`: Numerical DESC
|
||||
// `alphabeticalCaseInsensitiveAsc`: Alphabetical Case Insensitive ASC
|
||||
// `alphabeticalCaseInsensitiveDesc`: Alphabetical Case Insensitive DESC
|
||||
// `naturalAsc`: Natural ASC
|
||||
// `naturalDesc`: Natural DESC
|
||||
// VariableSort enum with default value
|
||||
VariableSort: "disabled" | "alphabeticalAsc" | "alphabeticalDesc" | "numericalAsc" | "numericalDesc" | "alphabeticalCaseInsensitiveAsc" | "alphabeticalCaseInsensitiveDesc" | "naturalAsc" | "naturalDesc"
|
||||
|
||||
// Options to config when to refresh a variable
|
||||
// `never`: Never refresh the variable
|
||||
// `onDashboardLoad`: Queries the data source every time the dashboard loads.
|
||||
// `onTimeRangeChanged`: Queries the data source when the dashboard time range changes.
|
||||
VariableRefresh: *"never" | "onDashboardLoad" | "onTimeRangeChanged"
|
||||
|
||||
// Determine if the variable shows on dashboard
|
||||
// Accepted values are `dontHide` (show label and value), `hideLabel` (show value only), `hideVariable` (show nothing).
|
||||
VariableHide: *"dontHide" | "hideLabel" | "hideVariable"
|
||||
|
||||
// Determine the origin of the adhoc variable filter
|
||||
FilterOrigin: "dashboard"
|
||||
|
||||
// FIXME: should we introduce this? --- Variable value option
|
||||
VariableValueOption: {
|
||||
label: string
|
||||
value: VariableValueSingle
|
||||
group?: string
|
||||
}
|
||||
|
||||
// Variable option specification
|
||||
VariableOption: {
|
||||
// Whether the option is selected or not
|
||||
selected?: bool
|
||||
// Text to be displayed for the option
|
||||
text: string | [...string]
|
||||
// Value of the option
|
||||
value: string | [...string]
|
||||
}
|
||||
|
||||
// Query variable specification
|
||||
QueryVariableSpec: {
|
||||
name: string | *""
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
value: ""
|
||||
}
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
refresh: VariableRefresh
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
datasource?: DataSourceRef
|
||||
query: DataQueryKind
|
||||
regex: string | *""
|
||||
sort: VariableSort
|
||||
definition?: string
|
||||
options: [...VariableOption] | *[]
|
||||
multi: bool | *false
|
||||
includeAll: bool | *false
|
||||
allValue?: string
|
||||
placeholder?: string
|
||||
allowCustomValue: bool | *true
|
||||
staticOptions?: [...VariableOption]
|
||||
staticOptionsOrder?: "before" | "after" | "sorted"
|
||||
}
|
||||
|
||||
// Query variable kind
|
||||
QueryVariableKind: {
|
||||
kind: "QueryVariable"
|
||||
spec: QueryVariableSpec
|
||||
}
|
||||
|
||||
// Text variable specification
|
||||
TextVariableSpec: {
|
||||
name: string | *""
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
value: ""
|
||||
}
|
||||
query: string | *""
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
}
|
||||
|
||||
// Text variable kind
|
||||
TextVariableKind: {
|
||||
kind: "TextVariable"
|
||||
spec: TextVariableSpec
|
||||
}
|
||||
|
||||
// Constant variable specification
|
||||
ConstantVariableSpec: {
|
||||
name: string | *""
|
||||
query: string | *""
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
value: ""
|
||||
}
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
}
|
||||
|
||||
// Constant variable kind
|
||||
ConstantVariableKind: {
|
||||
kind: "ConstantVariable"
|
||||
spec: ConstantVariableSpec
|
||||
}
|
||||
|
||||
// Datasource variable specification
|
||||
DatasourceVariableSpec: {
|
||||
name: string | *""
|
||||
pluginId: string | *""
|
||||
refresh: VariableRefresh
|
||||
regex: string | *""
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
value: ""
|
||||
}
|
||||
options: [...VariableOption] | *[]
|
||||
multi: bool | *false
|
||||
includeAll: bool | *false
|
||||
allValue?: string
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
allowCustomValue: bool | *true
|
||||
}
|
||||
|
||||
// Datasource variable kind
|
||||
DatasourceVariableKind: {
|
||||
kind: "DatasourceVariable"
|
||||
spec: DatasourceVariableSpec
|
||||
}
|
||||
|
||||
// Interval variable specification
|
||||
IntervalVariableSpec: {
|
||||
name: string | *""
|
||||
query: string | *""
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
value: ""
|
||||
}
|
||||
options: [...VariableOption] | *[]
|
||||
auto: bool | *false
|
||||
auto_min: string | *""
|
||||
auto_count: int | *0
|
||||
refresh: VariableRefresh
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
}
|
||||
|
||||
// Interval variable kind
|
||||
IntervalVariableKind: {
|
||||
kind: "IntervalVariable"
|
||||
spec: IntervalVariableSpec
|
||||
}
|
||||
|
||||
// Custom variable specification
|
||||
CustomVariableSpec: {
|
||||
name: string | *""
|
||||
query: string | *""
|
||||
current: VariableOption
|
||||
options: [...VariableOption] | *[]
|
||||
multi: bool | *false
|
||||
includeAll: bool | *false
|
||||
allValue?: string
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
allowCustomValue: bool | *true
|
||||
}
|
||||
|
||||
// Custom variable kind
|
||||
CustomVariableKind: {
|
||||
kind: "CustomVariable"
|
||||
spec: CustomVariableSpec
|
||||
}
|
||||
|
||||
// GroupBy variable specification
|
||||
GroupByVariableSpec: {
|
||||
name: string | *""
|
||||
datasource?: DataSourceRef
|
||||
defaultValue?: VariableOption
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
value: ""
|
||||
}
|
||||
options: [...VariableOption] | *[]
|
||||
multi: bool | *false
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
}
|
||||
|
||||
// Group variable kind
|
||||
GroupByVariableKind: {
|
||||
kind: "GroupByVariable"
|
||||
spec: GroupByVariableSpec
|
||||
}
|
||||
|
||||
// Adhoc variable specification
|
||||
AdhocVariableSpec: {
|
||||
name: string | *""
|
||||
datasource?: DataSourceRef
|
||||
baseFilters: [...AdHocFilterWithLabels] | *[]
|
||||
filters: [...AdHocFilterWithLabels] | *[]
|
||||
defaultKeys: [...MetricFindValue] | *[]
|
||||
label?: string
|
||||
hide: VariableHide
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
allowCustomValue: bool | *true
|
||||
}
|
||||
|
||||
// Define the MetricFindValue type
|
||||
MetricFindValue: {
|
||||
text: string
|
||||
value?: string | number
|
||||
group?: string
|
||||
expandable?: bool
|
||||
}
|
||||
|
||||
// Define the AdHocFilterWithLabels type
|
||||
AdHocFilterWithLabels: {
|
||||
key: string
|
||||
operator: string
|
||||
value: string
|
||||
values?: [...string]
|
||||
keyLabel?: string
|
||||
valueLabels?: [...string]
|
||||
forceEdit?: bool
|
||||
origin?: FilterOrigin
|
||||
// @deprecated
|
||||
condition?: string
|
||||
}
|
||||
|
||||
// Adhoc variable kind
|
||||
AdhocVariableKind: {
|
||||
kind: "AdhocVariable"
|
||||
spec: AdhocVariableSpec
|
||||
}
|
||||
|
||||
ConditionalRenderingGroupKind: {
|
||||
kind: "ConditionalRenderingGroup"
|
||||
spec: ConditionalRenderingGroupSpec
|
||||
}
|
||||
|
||||
ConditionalRenderingGroupSpec: {
|
||||
visibility: "show" | "hide"
|
||||
condition: "and" | "or"
|
||||
items: [...ConditionalRenderingVariableKind | ConditionalRenderingDataKind | ConditionalRenderingTimeRangeSizeKind]
|
||||
}
|
||||
|
||||
ConditionalRenderingVariableKind: {
|
||||
kind: "ConditionalRenderingVariable"
|
||||
spec: ConditionalRenderingVariableSpec
|
||||
}
|
||||
|
||||
ConditionalRenderingVariableSpec: {
|
||||
variable: string
|
||||
operator: "equals" | "notEquals"
|
||||
value: string
|
||||
}
|
||||
|
||||
ConditionalRenderingDataKind: {
|
||||
kind: "ConditionalRenderingData"
|
||||
spec: ConditionalRenderingDataSpec
|
||||
}
|
||||
|
||||
ConditionalRenderingDataSpec: {
|
||||
value: bool
|
||||
}
|
||||
|
||||
ConditionalRenderingTimeRangeSizeKind: {
|
||||
kind: "ConditionalRenderingTimeRangeSize"
|
||||
spec: ConditionalRenderingTimeRangeSizeSpec
|
||||
}
|
||||
|
||||
ConditionalRenderingTimeRangeSizeSpec: {
|
||||
value: string
|
||||
}
|
||||
2540
apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_spec_gen.go
Normal file
2540
apps/dashboard/pkg/apis/dashboard/v2alpha2/dashboard_spec_gen.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,34 @@
|
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v2alpha2
|
||||
|
||||
// ConversionStatus is the status of the conversion of the dashboard.
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardConversionStatus struct {
|
||||
// Whether from another version has failed.
|
||||
// If true, means that the dashboard is not valid,
|
||||
// and the caller should instead fetch the stored version.
|
||||
Failed bool `json:"failed"`
|
||||
// The version which was stored when the dashboard was created / updated.
|
||||
// Fetching this version should always succeed.
|
||||
StoredVersion string `json:"storedVersion"`
|
||||
// The error message from the conversion.
|
||||
// Empty if the conversion has not failed.
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
// NewDashboardConversionStatus creates a new DashboardConversionStatus object.
|
||||
func NewDashboardConversionStatus() *DashboardConversionStatus {
|
||||
return &DashboardConversionStatus{}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardStatus struct {
|
||||
// Optional conversion status.
|
||||
Conversion *DashboardConversionStatus `json:"conversion,omitempty"`
|
||||
}
|
||||
|
||||
// NewDashboardStatus creates a new DashboardStatus object.
|
||||
func NewDashboardStatus() *DashboardStatus {
|
||||
return &DashboardStatus{}
|
||||
}
|
||||
10
apps/dashboard/pkg/apis/dashboard/v2alpha2/doc.go
Normal file
10
apps/dashboard/pkg/apis/dashboard/v2alpha2/doc.go
Normal file
@@ -0,0 +1,10 @@
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +k8s:conversion-gen=github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard
|
||||
// +groupName=dashboard.grafana.app
|
||||
|
||||
// NOTE (@radiohead): we do not use package-wide deepcopy generation
|
||||
// because grafana-app-sdk already provides deepcopy functions.
|
||||
// Kinds which are not generated by the SDK are explicitly opted in to deepcopy generation.
|
||||
|
||||
package v2alpha2 // import "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
103
apps/dashboard/pkg/apis/dashboard/v2alpha2/register.go
Normal file
103
apps/dashboard/pkg/apis/dashboard/v2alpha2/register.go
Normal file
@@ -0,0 +1,103 @@
|
||||
package v2alpha2
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
GROUP = "dashboard.grafana.app"
|
||||
VERSION = "v2alpha2"
|
||||
APIVERSION = GROUP + "/" + VERSION
|
||||
)
|
||||
|
||||
var DashboardResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
|
||||
"dashboards", "dashboard", "Dashboard",
|
||||
func() runtime.Object { return &Dashboard{} },
|
||||
func() runtime.Object { return &DashboardList{} },
|
||||
utils.TableColumns{
|
||||
Definition: []metav1.TableColumnDefinition{
|
||||
{Name: "Name", Type: "string", Format: "name"},
|
||||
{Name: "Title", Type: "string", Format: "string", Description: "The dashboard name"},
|
||||
{Name: "Created At", Type: "date"},
|
||||
},
|
||||
Reader: func(obj any) ([]interface{}, error) {
|
||||
dash, ok := obj.(*Dashboard)
|
||||
if ok {
|
||||
if dash != nil {
|
||||
return []interface{}{
|
||||
dash.Name,
|
||||
dash.Spec.Title,
|
||||
dash.CreationTimestamp.UTC().Format(time.RFC3339),
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("expected dashboard")
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
var LibraryPanelResourceInfo = utils.NewResourceInfo(GROUP, VERSION,
|
||||
"librarypanels", "librarypanel", "LibraryPanel",
|
||||
func() runtime.Object { return &LibraryPanel{} },
|
||||
func() runtime.Object { return &LibraryPanelList{} },
|
||||
utils.TableColumns{
|
||||
Definition: []metav1.TableColumnDefinition{
|
||||
{Name: "Name", Type: "string", Format: "name"},
|
||||
{Name: "Title", Type: "string", Description: "The dashboard name"},
|
||||
{Name: "Type", Type: "string", Description: "the panel type"},
|
||||
{Name: "Created At", Type: "date"},
|
||||
},
|
||||
Reader: func(obj any) ([]interface{}, error) {
|
||||
panel, ok := obj.(*LibraryPanel)
|
||||
if ok {
|
||||
if panel != nil {
|
||||
return []interface{}{
|
||||
panel.Name,
|
||||
panel.Spec.Title,
|
||||
panel.Spec.Type,
|
||||
panel.CreationTimestamp.UTC().Format(time.RFC3339),
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("expected library panel")
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
var (
|
||||
SchemeBuilder runtime.SchemeBuilder
|
||||
localSchemeBuilder = &SchemeBuilder
|
||||
AddToScheme = localSchemeBuilder.AddToScheme
|
||||
schemeGroupVersion = schema.GroupVersion{Group: GROUP, Version: VERSION}
|
||||
)
|
||||
|
||||
func init() {
|
||||
localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs)
|
||||
}
|
||||
|
||||
// Adds the list of known types to the given scheme.
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(schemeGroupVersion,
|
||||
&Dashboard{},
|
||||
&DashboardList{},
|
||||
&DashboardWithAccessInfo{},
|
||||
&DashboardVersionList{},
|
||||
&VersionsQueryOptions{},
|
||||
&LibraryPanel{},
|
||||
&LibraryPanelList{},
|
||||
&metav1.PartialObjectMetadata{},
|
||||
&metav1.PartialObjectMetadataList{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, schemeGroupVersion)
|
||||
return nil
|
||||
}
|
||||
|
||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
return RegisterDefaults(scheme)
|
||||
}
|
||||
149
apps/dashboard/pkg/apis/dashboard/v2alpha2/types.go
Normal file
149
apps/dashboard/pkg/apis/dashboard/v2alpha2/types.go
Normal file
@@ -0,0 +1,149 @@
|
||||
package v2alpha2
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
data "github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1"
|
||||
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
|
||||
)
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type DashboardVersionList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
Items []DashboardVersionInfo `json:"items"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
type DashboardVersionInfo struct {
|
||||
// The internal ID for this version (will be replaced with resourceVersion)
|
||||
Version int `json:"version"`
|
||||
|
||||
// If the dashboard came from a previous version, it is set here
|
||||
ParentVersion int `json:"parentVersion,omitempty"`
|
||||
|
||||
// The creation timestamp for this version
|
||||
Created int64 `json:"created"`
|
||||
|
||||
// The user who created this version
|
||||
CreatedBy string `json:"createdBy,omitempty"`
|
||||
|
||||
// Message passed while saving the version
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
// +k8s:conversion-gen:explicit-from=net/url.Values
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type VersionsQueryOptions struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
|
||||
// Path is the URL path
|
||||
// +optional
|
||||
Path string `json:"path,omitempty"`
|
||||
|
||||
// +optional
|
||||
Version int64 `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type LibraryPanel struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
// Standard object's metadata
|
||||
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
|
||||
// +optional
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Panel properties
|
||||
Spec LibraryPanelSpec `json:"spec"`
|
||||
|
||||
// Status will show errors
|
||||
Status *LibraryPanelStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type LibraryPanelList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
Items []LibraryPanel `json:"items"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
type LibraryPanelSpec struct {
|
||||
// The panel type
|
||||
Type string `json:"type"`
|
||||
|
||||
// The panel type
|
||||
PluginVersion string `json:"pluginVersion,omitempty"`
|
||||
|
||||
// The panel title
|
||||
Title string `json:"title,omitempty"`
|
||||
|
||||
// Library panel description
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// The options schema depends on the panel type
|
||||
Options common.Unstructured `json:"options"`
|
||||
|
||||
// The fieldConfig schema depends on the panel type
|
||||
FieldConfig common.Unstructured `json:"fieldConfig"`
|
||||
|
||||
// The default datasource type
|
||||
Datasource *data.DataSourceRef `json:"datasource,omitempty"`
|
||||
|
||||
// The datasource queries
|
||||
// +listType=set
|
||||
Targets []data.DataQuery `json:"targets,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
type LibraryPanelStatus struct {
|
||||
// Translation warnings (mostly things that were in SQL columns but not found in the saved body)
|
||||
Warnings []string `json:"warnings,omitempty"`
|
||||
|
||||
// The properties previously stored in SQL that are not included in this model
|
||||
Missing common.Unstructured `json:"missing,omitempty"`
|
||||
}
|
||||
|
||||
// This is like the legacy DTO where access and metadata are all returned in a single call
|
||||
// +k8s:deepcopy-gen=true
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type DashboardWithAccessInfo struct {
|
||||
Dashboard `json:",inline"`
|
||||
|
||||
Access DashboardAccess `json:"access"`
|
||||
}
|
||||
|
||||
// Information about how the requesting user can use a given dashboard
|
||||
// +k8s:deepcopy-gen=true
|
||||
type DashboardAccess struct {
|
||||
// Metadata fields
|
||||
Slug string `json:"slug,omitempty"`
|
||||
Url string `json:"url,omitempty"`
|
||||
|
||||
// The permissions part
|
||||
CanSave bool `json:"canSave"`
|
||||
CanEdit bool `json:"canEdit"`
|
||||
CanAdmin bool `json:"canAdmin"`
|
||||
CanStar bool `json:"canStar"`
|
||||
CanDelete bool `json:"canDelete"`
|
||||
AnnotationsPermissions *AnnotationPermission `json:"annotationsPermissions"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
type AnnotationPermission struct {
|
||||
Dashboard AnnotationActions `json:"dashboard"`
|
||||
Organization AnnotationActions `json:"organization"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
type AnnotationActions struct {
|
||||
CanAdd bool `json:"canAdd"`
|
||||
CanEdit bool `json:"canEdit"`
|
||||
CanDelete bool `json:"canDelete"`
|
||||
}
|
||||
84
apps/dashboard/pkg/apis/dashboard/v2alpha2/validation.go
Normal file
84
apps/dashboard/pkg/apis/dashboard/v2alpha2/validation.go
Normal file
@@ -0,0 +1,84 @@
|
||||
package v2alpha2
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
json "encoding/json"
|
||||
fmt "fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
|
||||
"cuelang.org/go/cue"
|
||||
"cuelang.org/go/cue/cuecontext"
|
||||
"cuelang.org/go/cue/errors"
|
||||
cuejson "cuelang.org/go/encoding/json"
|
||||
)
|
||||
|
||||
func ValidateDashboardSpec(obj *Dashboard) field.ErrorList {
|
||||
data, err := json.Marshal(obj.Spec)
|
||||
if err != nil {
|
||||
return field.ErrorList{
|
||||
field.Invalid(field.NewPath("spec"), field.OmitValueType{}, err.Error()),
|
||||
}
|
||||
}
|
||||
|
||||
if err := cuejson.Validate(data, getCueSchema()); err != nil {
|
||||
errs := field.ErrorList{}
|
||||
|
||||
for _, e := range errors.Errors(err) {
|
||||
if
|
||||
// We don't want to return confusing "empty disjunction" errors,
|
||||
// because the users don't necessarily understand what to do with them.
|
||||
// For empty disjunctions, CUE will also return more specific errors,
|
||||
// so we can safely ignore the generic ones.
|
||||
strings.Contains(e.Error(), "disjunction") ||
|
||||
// We don't want to return errors about unknown fields either.
|
||||
strings.Contains(e.Error(), "field not allowed") {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.Contains(e.Error(), "mismatched types null and list") {
|
||||
// Go populates empty slices as nil, which the cue validator does not like
|
||||
continue
|
||||
}
|
||||
|
||||
// We want to manually format the error message,
|
||||
// because e.Error() contains the full CUE path.
|
||||
format, args := e.Msg()
|
||||
|
||||
errs = append(errs, field.Invalid(
|
||||
field.NewPath(formatErrorPath(e.Path())),
|
||||
field.OmitValueType{},
|
||||
fmt.Sprintf(format, args...),
|
||||
))
|
||||
}
|
||||
|
||||
return errs
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func formatErrorPath(path []string) string {
|
||||
return strings.Join(path, ".")
|
||||
}
|
||||
|
||||
var (
|
||||
compiledSchema cue.Value
|
||||
getSchemaOnce sync.Once
|
||||
)
|
||||
|
||||
//go:embed dashboard_spec.cue
|
||||
var schemaSource string
|
||||
|
||||
func getCueSchema() cue.Value {
|
||||
getSchemaOnce.Do(func() {
|
||||
cueCtx := cuecontext.New()
|
||||
compiledSchema = cueCtx.CompileString(schemaSource).LookupPath(
|
||||
cue.ParsePath("DashboardSpec"),
|
||||
)
|
||||
})
|
||||
|
||||
return compiledSchema
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
//go:build !ignore_autogenerated
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// Code generated by conversion-gen. DO NOT EDIT.
|
||||
|
||||
package v2alpha2
|
||||
|
||||
import (
|
||||
url "net/url"
|
||||
unsafe "unsafe"
|
||||
|
||||
dashboard "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard"
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
func init() {
|
||||
localSchemeBuilder.Register(RegisterConversions)
|
||||
}
|
||||
|
||||
// RegisterConversions adds conversion functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
func RegisterConversions(s *runtime.Scheme) error {
|
||||
if err := s.AddGeneratedConversionFunc((*AnnotationActions)(nil), (*dashboard.AnnotationActions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(a.(*AnnotationActions), b.(*dashboard.AnnotationActions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*dashboard.AnnotationActions)(nil), (*AnnotationActions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(a.(*dashboard.AnnotationActions), b.(*AnnotationActions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*AnnotationPermission)(nil), (*dashboard.AnnotationPermission)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission(a.(*AnnotationPermission), b.(*dashboard.AnnotationPermission), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*dashboard.AnnotationPermission)(nil), (*AnnotationPermission)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission(a.(*dashboard.AnnotationPermission), b.(*AnnotationPermission), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*DashboardAccess)(nil), (*dashboard.DashboardAccess)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess(a.(*DashboardAccess), b.(*dashboard.DashboardAccess), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*dashboard.DashboardAccess)(nil), (*DashboardAccess)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess(a.(*dashboard.DashboardAccess), b.(*DashboardAccess), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*url.Values)(nil), (*VersionsQueryOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_url_Values_To_v2alpha2_VersionsQueryOptions(a.(*url.Values), b.(*VersionsQueryOptions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func autoConvert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(in *AnnotationActions, out *dashboard.AnnotationActions, s conversion.Scope) error {
|
||||
out.CanAdd = in.CanAdd
|
||||
out.CanEdit = in.CanEdit
|
||||
out.CanDelete = in.CanDelete
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions is an autogenerated conversion function.
|
||||
func Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(in *AnnotationActions, out *dashboard.AnnotationActions, s conversion.Scope) error {
|
||||
return autoConvert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(in *dashboard.AnnotationActions, out *AnnotationActions, s conversion.Scope) error {
|
||||
out.CanAdd = in.CanAdd
|
||||
out.CanEdit = in.CanEdit
|
||||
out.CanDelete = in.CanDelete
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions is an autogenerated conversion function.
|
||||
func Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(in *dashboard.AnnotationActions, out *AnnotationActions, s conversion.Scope) error {
|
||||
return autoConvert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission(in *AnnotationPermission, out *dashboard.AnnotationPermission, s conversion.Scope) error {
|
||||
if err := Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(&in.Dashboard, &out.Dashboard, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(&in.Organization, &out.Organization, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission is an autogenerated conversion function.
|
||||
func Convert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission(in *AnnotationPermission, out *dashboard.AnnotationPermission, s conversion.Scope) error {
|
||||
return autoConvert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission(in *dashboard.AnnotationPermission, out *AnnotationPermission, s conversion.Scope) error {
|
||||
if err := Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(&in.Dashboard, &out.Dashboard, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(&in.Organization, &out.Organization, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission is an autogenerated conversion function.
|
||||
func Convert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission(in *dashboard.AnnotationPermission, out *AnnotationPermission, s conversion.Scope) error {
|
||||
return autoConvert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess(in *DashboardAccess, out *dashboard.DashboardAccess, s conversion.Scope) error {
|
||||
out.Slug = in.Slug
|
||||
out.Url = in.Url
|
||||
out.CanSave = in.CanSave
|
||||
out.CanEdit = in.CanEdit
|
||||
out.CanAdmin = in.CanAdmin
|
||||
out.CanStar = in.CanStar
|
||||
out.CanDelete = in.CanDelete
|
||||
out.AnnotationsPermissions = (*dashboard.AnnotationPermission)(unsafe.Pointer(in.AnnotationsPermissions))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess is an autogenerated conversion function.
|
||||
func Convert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess(in *DashboardAccess, out *dashboard.DashboardAccess, s conversion.Scope) error {
|
||||
return autoConvert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess(in *dashboard.DashboardAccess, out *DashboardAccess, s conversion.Scope) error {
|
||||
out.Slug = in.Slug
|
||||
out.Url = in.Url
|
||||
out.CanSave = in.CanSave
|
||||
out.CanEdit = in.CanEdit
|
||||
out.CanAdmin = in.CanAdmin
|
||||
out.CanStar = in.CanStar
|
||||
out.CanDelete = in.CanDelete
|
||||
out.AnnotationsPermissions = (*AnnotationPermission)(unsafe.Pointer(in.AnnotationsPermissions))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess is an autogenerated conversion function.
|
||||
func Convert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess(in *dashboard.DashboardAccess, out *DashboardAccess, s conversion.Scope) error {
|
||||
return autoConvert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_url_Values_To_v2alpha2_VersionsQueryOptions(in *url.Values, out *VersionsQueryOptions, s conversion.Scope) error {
|
||||
// WARNING: Field TypeMeta does not have json tag, skipping.
|
||||
|
||||
if values, ok := map[string][]string(*in)["path"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_string(&values, &out.Path, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Path = ""
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["version"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_int64(&values, &out.Version, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Version = 0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_url_Values_To_v2alpha2_VersionsQueryOptions is an autogenerated conversion function.
|
||||
func Convert_url_Values_To_v2alpha2_VersionsQueryOptions(in *url.Values, out *VersionsQueryOptions, s conversion.Scope) error {
|
||||
return autoConvert_url_Values_To_v2alpha2_VersionsQueryOptions(in, out, s)
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
//go:build !ignore_autogenerated
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// Code generated by deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v2alpha2
|
||||
|
||||
import (
|
||||
v0alpha1 "github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *AnnotationActions) DeepCopyInto(out *AnnotationActions) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AnnotationActions.
|
||||
func (in *AnnotationActions) DeepCopy() *AnnotationActions {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(AnnotationActions)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *AnnotationPermission) DeepCopyInto(out *AnnotationPermission) {
|
||||
*out = *in
|
||||
out.Dashboard = in.Dashboard
|
||||
out.Organization = in.Organization
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AnnotationPermission.
|
||||
func (in *AnnotationPermission) DeepCopy() *AnnotationPermission {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(AnnotationPermission)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DashboardAccess) DeepCopyInto(out *DashboardAccess) {
|
||||
*out = *in
|
||||
if in.AnnotationsPermissions != nil {
|
||||
in, out := &in.AnnotationsPermissions, &out.AnnotationsPermissions
|
||||
*out = new(AnnotationPermission)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardAccess.
|
||||
func (in *DashboardAccess) DeepCopy() *DashboardAccess {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DashboardAccess)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DashboardVersionInfo) DeepCopyInto(out *DashboardVersionInfo) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardVersionInfo.
|
||||
func (in *DashboardVersionInfo) DeepCopy() *DashboardVersionInfo {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DashboardVersionInfo)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DashboardVersionList) DeepCopyInto(out *DashboardVersionList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]DashboardVersionInfo, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardVersionList.
|
||||
func (in *DashboardVersionList) DeepCopy() *DashboardVersionList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DashboardVersionList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *DashboardVersionList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DashboardWithAccessInfo) DeepCopyInto(out *DashboardWithAccessInfo) {
|
||||
*out = *in
|
||||
in.Dashboard.DeepCopyInto(&out.Dashboard)
|
||||
in.Access.DeepCopyInto(&out.Access)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardWithAccessInfo.
|
||||
func (in *DashboardWithAccessInfo) DeepCopy() *DashboardWithAccessInfo {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DashboardWithAccessInfo)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *DashboardWithAccessInfo) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LibraryPanel) DeepCopyInto(out *LibraryPanel) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
if in.Status != nil {
|
||||
in, out := &in.Status, &out.Status
|
||||
*out = new(LibraryPanelStatus)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LibraryPanel.
|
||||
func (in *LibraryPanel) DeepCopy() *LibraryPanel {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(LibraryPanel)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *LibraryPanel) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LibraryPanelList) DeepCopyInto(out *LibraryPanelList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]LibraryPanel, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LibraryPanelList.
|
||||
func (in *LibraryPanelList) DeepCopy() *LibraryPanelList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(LibraryPanelList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *LibraryPanelList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LibraryPanelSpec) DeepCopyInto(out *LibraryPanelSpec) {
|
||||
*out = *in
|
||||
in.Options.DeepCopyInto(&out.Options)
|
||||
in.FieldConfig.DeepCopyInto(&out.FieldConfig)
|
||||
if in.Datasource != nil {
|
||||
in, out := &in.Datasource, &out.Datasource
|
||||
*out = new(v0alpha1.DataSourceRef)
|
||||
**out = **in
|
||||
}
|
||||
if in.Targets != nil {
|
||||
in, out := &in.Targets, &out.Targets
|
||||
*out = make([]v0alpha1.DataQuery, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LibraryPanelSpec.
|
||||
func (in *LibraryPanelSpec) DeepCopy() *LibraryPanelSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(LibraryPanelSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LibraryPanelStatus) DeepCopyInto(out *LibraryPanelStatus) {
|
||||
*out = *in
|
||||
if in.Warnings != nil {
|
||||
in, out := &in.Warnings, &out.Warnings
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
in.Missing.DeepCopyInto(&out.Missing)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LibraryPanelStatus.
|
||||
func (in *LibraryPanelStatus) DeepCopy() *LibraryPanelStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(LibraryPanelStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VersionsQueryOptions) DeepCopyInto(out *VersionsQueryOptions) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VersionsQueryOptions.
|
||||
func (in *VersionsQueryOptions) DeepCopy() *VersionsQueryOptions {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VersionsQueryOptions)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *VersionsQueryOptions) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
// Code generated by defaulter-gen. DO NOT EDIT.
|
||||
|
||||
package v0alpha1
|
||||
package v2alpha2
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
5094
apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.openapi.go
Normal file
5094
apps/dashboard/pkg/apis/dashboard/v2alpha2/zz_generated.openapi.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,67 @@
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdHocFilterWithLabels,ValueLabels
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdHocFilterWithLabels,Values
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdhocVariableSpec,BaseFilters
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdhocVariableSpec,DefaultKeys
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdhocVariableSpec,Filters
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAnnotationPanelFilter,Ids
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAutoGridLayoutSpec,Items
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardConditionalRenderingGroupSpec,Items
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardCustomVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardDashboardLink,Tags
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardDatasourceVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardFieldConfig,Links
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardFieldConfig,Mappings
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardFieldConfigSource,Overrides
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutSpec,Items
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGroupByVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardIntervalVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardMetadata,Finalizers
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardPanelSpec,Links
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryGroupSpec,Queries
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryGroupSpec,Transformations
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableSpec,StaticOptions
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardRowsLayoutSpec,Rows
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardSpec,Annotations
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardSpec,Links
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardSpec,Tags
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardSpec,Variables
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrArrayOfString,ArrayOfString
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardTabsLayoutSpec,Tabs
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardThresholdsConfig,Steps
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardTimeSettingsSpec,AutoRefreshIntervals
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardTimeSettingsSpec,QuickRanges
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardV2alpha2FieldConfigSourceOverrides,Properties
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,LibraryPanelStatus,Warnings
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind,ConditionalRenderingDataKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind,ConditionalRenderingTimeRangeSizeKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind,ConditionalRenderingVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,AutoGridLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,GridLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,RowsLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,TabsLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,AutoGridLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,GridLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,RowsLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,TabsLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardIntervalVariableSpec,AutoCount
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardIntervalVariableSpec,AutoMin
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardPanelKindOrLibraryPanelKind,LibraryPanelKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardPanelKindOrLibraryPanelKind,PanelKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,AdhocVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,ConstantVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,CustomVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,DatasourceVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,GroupByVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,IntervalVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,QueryVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,TextVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrArrayOfString,ArrayOfString
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrArrayOfString,String
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrFloat64,Float64
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrFloat64,String
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,RangeMap
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,RegexMap
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,SpecialValueMap
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,ValueMap
|
||||
API rule violation: streaming_list_type_json_tags,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardList,ListMeta
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
v0alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
v1beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
v2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
v2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
)
|
||||
|
||||
var appManifestData = app.ManifestData{
|
||||
@@ -36,6 +37,10 @@ var appManifestData = app.ManifestData{
|
||||
{
|
||||
Name: "v2alpha1",
|
||||
},
|
||||
|
||||
{
|
||||
Name: "v2alpha2",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -53,6 +58,7 @@ var kindVersionToGoType = map[string]resource.Kind{
|
||||
"Dashboard/v0alpha1": v0alpha1.DashboardKind(),
|
||||
"Dashboard/v1beta1": v1beta1.DashboardKind(),
|
||||
"Dashboard/v2alpha1": v2alpha1.DashboardKind(),
|
||||
"Dashboard/v2alpha2": v2alpha2.DashboardKind(),
|
||||
}
|
||||
|
||||
// ManifestGoTypeAssociator returns the associated resource.Kind instance for a given Kind and Version, if one exists.
|
||||
|
||||
@@ -6,167 +6,77 @@ import (
|
||||
|
||||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
)
|
||||
|
||||
func RegisterConversions(s *runtime.Scheme) error {
|
||||
// v0 conversions
|
||||
if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V0_to_V1(a.(*dashv0.Dashboard), b.(*dashv1.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V0_to_V2(a.(*dashv0.Dashboard), b.(*dashv2.Dashboard), scope)
|
||||
if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv2alpha1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V0_to_V2alpha1(a.(*dashv0.Dashboard), b.(*dashv2alpha1.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv2alpha2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V0_to_V2alpha2(a.(*dashv0.Dashboard), b.(*dashv2alpha2.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// v1 conversions
|
||||
if err := s.AddConversionFunc((*dashv1.Dashboard)(nil), (*dashv0.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V1_to_V0(a.(*dashv1.Dashboard), b.(*dashv0.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv1.Dashboard)(nil), (*dashv2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V1_to_V2(a.(*dashv1.Dashboard), b.(*dashv2.Dashboard), scope)
|
||||
if err := s.AddConversionFunc((*dashv1.Dashboard)(nil), (*dashv2alpha1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V1_to_V2alpha1(a.(*dashv1.Dashboard), b.(*dashv2alpha1.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv2.Dashboard)(nil), (*dashv0.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2_to_V0(a.(*dashv2.Dashboard), b.(*dashv0.Dashboard), scope)
|
||||
if err := s.AddConversionFunc((*dashv1.Dashboard)(nil), (*dashv2alpha2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V1_to_V2alpha2(a.(*dashv1.Dashboard), b.(*dashv2alpha2.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv2.Dashboard)(nil), (*dashv1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2_to_V1(a.(*dashv2.Dashboard), b.(*dashv1.Dashboard), scope)
|
||||
|
||||
// v2alpha1 conversions
|
||||
if err := s.AddConversionFunc((*dashv2alpha1.Dashboard)(nil), (*dashv0.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2alpha1_to_V0(a.(*dashv2alpha1.Dashboard), b.(*dashv0.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V0_to_V1(in *dashv0.Dashboard, out *dashv1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
out.Spec.Object = in.Spec.Object
|
||||
|
||||
out.Status = dashv1.DashboardStatus{
|
||||
Conversion: &dashv1.DashboardConversionStatus{
|
||||
StoredVersion: dashv0.VERSION,
|
||||
},
|
||||
if err := s.AddConversionFunc((*dashv2alpha1.Dashboard)(nil), (*dashv1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2alpha1_to_V1(a.(*dashv2alpha1.Dashboard), b.(*dashv1.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv2alpha1.Dashboard)(nil), (*dashv2alpha2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2alpha1_to_V2alpha2(a.(*dashv2alpha1.Dashboard), b.(*dashv2alpha2.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := migration.Migrate(out.Spec.Object, schemaversion.LATEST_VERSION); err != nil {
|
||||
out.Status.Conversion.Failed = true
|
||||
out.Status.Conversion.Error = err.Error()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V0_to_V2(in *dashv0.Dashboard, out *dashv2.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO (@radiohead): implement V0 to V2 conversion
|
||||
// This is the bare minimum conversion that is needed to make the dashboard servable.
|
||||
|
||||
if v, ok := in.Spec.Object["title"]; ok {
|
||||
if title, ok := v.(string); ok {
|
||||
out.Spec.Title = title
|
||||
}
|
||||
}
|
||||
|
||||
// We need to make sure the layout is set to some value, otherwise the JSON marshaling will fail.
|
||||
out.Spec.Layout = dashv2.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind{
|
||||
GridLayoutKind: &dashv2.DashboardGridLayoutKind{
|
||||
Kind: "GridLayout",
|
||||
Spec: dashv2.DashboardGridLayoutSpec{},
|
||||
},
|
||||
}
|
||||
|
||||
out.Status = dashv2.DashboardStatus{
|
||||
Conversion: &dashv2.DashboardConversionStatus{
|
||||
StoredVersion: dashv0.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V1_to_V0(in *dashv1.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
out.Spec.Object = in.Spec.Object
|
||||
|
||||
out.Status = dashv0.DashboardStatus{
|
||||
Conversion: &dashv0.DashboardConversionStatus{
|
||||
StoredVersion: dashv1.VERSION,
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V1_to_V2(in *dashv1.Dashboard, out *dashv2.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO (@radiohead): implement V1 to V2 conversion
|
||||
// This is the bare minimum conversion that is needed to make the dashboard servable.
|
||||
|
||||
if v, ok := in.Spec.Object["title"]; ok {
|
||||
if title, ok := v.(string); ok {
|
||||
out.Spec.Title = title
|
||||
}
|
||||
}
|
||||
|
||||
// We need to make sure the layout is set to some value, otherwise the JSON marshaling will fail.
|
||||
out.Spec.Layout = dashv2.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind{
|
||||
GridLayoutKind: &dashv2.DashboardGridLayoutKind{
|
||||
Kind: "GridLayout",
|
||||
Spec: dashv2.DashboardGridLayoutSpec{},
|
||||
},
|
||||
}
|
||||
|
||||
out.Status = dashv2.DashboardStatus{
|
||||
Conversion: &dashv2.DashboardConversionStatus{
|
||||
StoredVersion: dashv1.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V2_to_V0(in *dashv2.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V2 to V0 conversion
|
||||
|
||||
out.Status = dashv0.DashboardStatus{
|
||||
Conversion: &dashv0.DashboardConversionStatus{
|
||||
StoredVersion: dashv2.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V2_to_V1(in *dashv2.Dashboard, out *dashv1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V2 to V1 conversion
|
||||
|
||||
out.Status = dashv1.DashboardStatus{
|
||||
Conversion: &dashv1.DashboardConversionStatus{
|
||||
StoredVersion: dashv2.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
// v2alpha2 conversions
|
||||
if err := s.AddConversionFunc((*dashv2alpha2.Dashboard)(nil), (*dashv0.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2alpha2_to_V0(a.(*dashv2alpha2.Dashboard), b.(*dashv0.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv2alpha2.Dashboard)(nil), (*dashv1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2alpha2_to_V1(a.(*dashv2alpha2.Dashboard), b.(*dashv1.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv2alpha2.Dashboard)(nil), (*dashv2alpha1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2alpha2_to_V2alpha1(a.(*dashv2alpha2.Dashboard), b.(*dashv2alpha1.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
|
||||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/testutil"
|
||||
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
|
||||
@@ -25,7 +26,8 @@ func TestConversionMatrixExist(t *testing.T) {
|
||||
versions := []v1.Object{
|
||||
&dashv0.Dashboard{Spec: common.Unstructured{Object: map[string]any{"title": "dashboardV0"}}},
|
||||
&dashv1.Dashboard{Spec: common.Unstructured{Object: map[string]any{"title": "dashboardV1"}}},
|
||||
&dashv2.Dashboard{Spec: dashv2.DashboardSpec{Title: "dashboardV2"}},
|
||||
&dashv2alpha1.Dashboard{Spec: dashv2alpha1.DashboardSpec{Title: "dashboardV2alpha1"}},
|
||||
&dashv2alpha2.Dashboard{Spec: dashv2alpha2.DashboardSpec{Title: "dashboardV2alpha2"}},
|
||||
}
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
|
||||
78
apps/dashboard/pkg/migration/conversion/v0.go
Normal file
78
apps/dashboard/pkg/migration/conversion/v0.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package conversion
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
|
||||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
|
||||
)
|
||||
|
||||
func Convert_V0_to_V1(in *dashv0.Dashboard, out *dashv1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
out.Spec.Object = in.Spec.Object
|
||||
|
||||
out.Status = dashv1.DashboardStatus{
|
||||
Conversion: &dashv1.DashboardConversionStatus{
|
||||
StoredVersion: dashv0.VERSION,
|
||||
},
|
||||
}
|
||||
|
||||
if err := migration.Migrate(out.Spec.Object, schemaversion.LATEST_VERSION); err != nil {
|
||||
out.Status.Conversion.Failed = true
|
||||
out.Status.Conversion.Error = err.Error()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V0_to_V2alpha1(in *dashv0.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO (@radiohead): implement V0 to V2 conversion
|
||||
// This is the bare minimum conversion that is needed to make the dashboard servable.
|
||||
|
||||
if v, ok := in.Spec.Object["title"]; ok {
|
||||
if title, ok := v.(string); ok {
|
||||
out.Spec.Title = title
|
||||
}
|
||||
}
|
||||
|
||||
// We need to make sure the layout is set to some value, otherwise the JSON marshaling will fail.
|
||||
out.Spec.Layout = dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind{
|
||||
GridLayoutKind: &dashv2alpha1.DashboardGridLayoutKind{
|
||||
Kind: "GridLayout",
|
||||
Spec: dashv2alpha1.DashboardGridLayoutSpec{},
|
||||
},
|
||||
}
|
||||
|
||||
out.Status = dashv2alpha1.DashboardStatus{
|
||||
Conversion: &dashv2alpha1.DashboardConversionStatus{
|
||||
StoredVersion: dashv0.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V0_to_V2alpha2(in *dashv0.Dashboard, out *dashv2alpha2.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V0 to V2alpha2 conversion
|
||||
|
||||
out.Status = dashv2alpha2.DashboardStatus{
|
||||
Conversion: &dashv2alpha2.DashboardConversionStatus{
|
||||
StoredVersion: dashv0.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
71
apps/dashboard/pkg/migration/conversion/v1.go
Normal file
71
apps/dashboard/pkg/migration/conversion/v1.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package conversion
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
|
||||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
)
|
||||
|
||||
func Convert_V1_to_V0(in *dashv1.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
out.Spec.Object = in.Spec.Object
|
||||
|
||||
out.Status = dashv0.DashboardStatus{
|
||||
Conversion: &dashv0.DashboardConversionStatus{
|
||||
StoredVersion: dashv1.VERSION,
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V1_to_V2alpha1(in *dashv1.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO (@radiohead): implement V1 to V2 conversion
|
||||
// This is the bare minimum conversion that is needed to make the dashboard servable.
|
||||
|
||||
if v, ok := in.Spec.Object["title"]; ok {
|
||||
if title, ok := v.(string); ok {
|
||||
out.Spec.Title = title
|
||||
}
|
||||
}
|
||||
|
||||
// We need to make sure the layout is set to some value, otherwise the JSON marshaling will fail.
|
||||
out.Spec.Layout = dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind{
|
||||
GridLayoutKind: &dashv2alpha1.DashboardGridLayoutKind{
|
||||
Kind: "GridLayout",
|
||||
Spec: dashv2alpha1.DashboardGridLayoutSpec{},
|
||||
},
|
||||
}
|
||||
|
||||
out.Status = dashv2alpha1.DashboardStatus{
|
||||
Conversion: &dashv2alpha1.DashboardConversionStatus{
|
||||
StoredVersion: dashv1.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V1_to_V2alpha2(in *dashv1.Dashboard, out *dashv2alpha2.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V1 to V2alpha2 conversion
|
||||
|
||||
out.Status = dashv2alpha2.DashboardStatus{
|
||||
Conversion: &dashv2alpha2.DashboardConversionStatus{
|
||||
StoredVersion: dashv1.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
105
apps/dashboard/pkg/migration/conversion/v2.go
Normal file
105
apps/dashboard/pkg/migration/conversion/v2.go
Normal file
@@ -0,0 +1,105 @@
|
||||
package conversion
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
|
||||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
)
|
||||
|
||||
func Convert_V2alpha1_to_V0(in *dashv2alpha1.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V2 to V0 conversion
|
||||
|
||||
out.Status = dashv0.DashboardStatus{
|
||||
Conversion: &dashv0.DashboardConversionStatus{
|
||||
StoredVersion: dashv2alpha1.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V2alpha1_to_V1(in *dashv2alpha1.Dashboard, out *dashv1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V2 to V1 conversion
|
||||
|
||||
out.Status = dashv1.DashboardStatus{
|
||||
Conversion: &dashv1.DashboardConversionStatus{
|
||||
StoredVersion: dashv2alpha1.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V2alpha1_to_V2alpha2(in *dashv2alpha1.Dashboard, out *dashv2alpha2.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V2alpha1 to V2alpha2 conversion
|
||||
|
||||
out.Status = dashv2alpha2.DashboardStatus{
|
||||
Conversion: &dashv2alpha2.DashboardConversionStatus{
|
||||
StoredVersion: dashv2alpha1.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func Convert_V2alpha2_to_V0(in *dashv2alpha2.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V2alpha2 to V0 conversion
|
||||
|
||||
out.Status = dashv0.DashboardStatus{
|
||||
Conversion: &dashv0.DashboardConversionStatus{
|
||||
StoredVersion: dashv2alpha2.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V2alpha2_to_V1(in *dashv2alpha2.Dashboard, out *dashv1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V2alpha2 to V1 conversion
|
||||
|
||||
out.Status = dashv1.DashboardStatus{
|
||||
Conversion: &dashv1.DashboardConversionStatus{
|
||||
StoredVersion: dashv2alpha2.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_V2alpha2_to_V2alpha1(in *dashv2alpha2.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V2alpha2 to V2alpha1 conversion
|
||||
|
||||
out.Status = dashv2alpha1.DashboardStatus{
|
||||
Conversion: &dashv2alpha1.DashboardConversionStatus{
|
||||
StoredVersion: dashv2alpha2.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
MIN_VERSION = 32
|
||||
MIN_VERSION = 28
|
||||
LATEST_VERSION = 41
|
||||
)
|
||||
|
||||
@@ -26,6 +26,10 @@ type DataSourceInfoProvider interface {
|
||||
|
||||
func GetMigrations(dsInfoProvider DataSourceInfoProvider) map[int]SchemaVersionMigrationFunc {
|
||||
return map[int]SchemaVersionMigrationFunc{
|
||||
29: V29,
|
||||
30: V30,
|
||||
31: V31,
|
||||
32: V32,
|
||||
33: V33(dsInfoProvider),
|
||||
34: V34,
|
||||
35: V35,
|
||||
|
||||
59
apps/dashboard/pkg/migration/schemaversion/v29.go
Normal file
59
apps/dashboard/pkg/migration/schemaversion/v29.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package schemaversion
|
||||
|
||||
// V29 migrates query variables to ensure their refresh property is set to 1 (on dashboard load)
|
||||
// if it is not 1 or 2, and clears their options array if present.
|
||||
//
|
||||
// Example before migration:
|
||||
//
|
||||
// "templating": {
|
||||
// "list": [
|
||||
// { "type": "query", "refresh": 0, "options": [{ "text": "A", "value": "A" }] },
|
||||
// { "type": "query", "refresh": 2, "options": [{ "text": "B", "value": "B" }] },
|
||||
// { "type": "query", "options": [{ "text": "C", "value": "C" }] }
|
||||
// ]
|
||||
// }
|
||||
//
|
||||
// Example after migration:
|
||||
//
|
||||
// "templating": {
|
||||
// "list": [
|
||||
// { "type": "query", "refresh": 1, "options": [] },
|
||||
// { "type": "query", "refresh": 2, "options": [] },
|
||||
// { "type": "query", "refresh": 1, "options": [] }
|
||||
// ]
|
||||
// }
|
||||
func V29(dashboard map[string]interface{}) error {
|
||||
dashboard["schemaVersion"] = 29
|
||||
|
||||
templating, ok := dashboard["templating"].(map[string]interface{})
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
list, ok := templating["list"].([]interface{})
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
for _, v := range list {
|
||||
variable, ok := v.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if variable["type"] != "query" {
|
||||
continue
|
||||
}
|
||||
// Set refresh to 1 if not 1 or 2
|
||||
refresh, hasRefresh := variable["refresh"]
|
||||
refreshInt := 0
|
||||
if r, ok := refresh.(int); ok {
|
||||
refreshInt = r
|
||||
}
|
||||
if !hasRefresh || (refreshInt != 1 && refreshInt != 2) {
|
||||
variable["refresh"] = 1
|
||||
}
|
||||
// Clear options if present
|
||||
if _, hasOptions := variable["options"]; hasOptions {
|
||||
variable["options"] = []interface{}{}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
127
apps/dashboard/pkg/migration/schemaversion/v29_test.go
Normal file
127
apps/dashboard/pkg/migration/schemaversion/v29_test.go
Normal file
@@ -0,0 +1,127 @@
|
||||
package schemaversion_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
|
||||
)
|
||||
|
||||
func TestV29(t *testing.T) {
|
||||
tests := []migrationTestCase{
|
||||
{
|
||||
name: "query variables get migrated with refresh and options",
|
||||
input: map[string]interface{}{
|
||||
"title": "V29 Query Variables Migration Test Dashboard",
|
||||
"schemaVersion": 28,
|
||||
"templating": map[string]interface{}{
|
||||
"list": []interface{}{
|
||||
map[string]interface{}{"type": "query", "name": "never_refresh_with_options", "options": []interface{}{map[string]interface{}{"text": "A", "value": "A"}}, "refresh": 0},
|
||||
map[string]interface{}{"type": "query", "name": "never_refresh_without_options", "options": []interface{}{}, "refresh": 0},
|
||||
map[string]interface{}{"type": "query", "name": "dashboard_refresh_with_options", "options": []interface{}{map[string]interface{}{"text": "A", "value": "A"}}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "dashboard_refresh_without_options", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "timerange_refresh_with_options", "options": []interface{}{map[string]interface{}{"text": "A", "value": "A"}}, "refresh": 2},
|
||||
map[string]interface{}{"type": "query", "name": "timerange_refresh_without_options", "options": []interface{}{}, "refresh": 2},
|
||||
map[string]interface{}{"type": "query", "name": "no_refresh_with_options", "options": []interface{}{map[string]interface{}{"text": "A", "value": "A"}}},
|
||||
map[string]interface{}{"type": "query", "name": "no_refresh_without_options", "options": []interface{}{}},
|
||||
map[string]interface{}{"type": "query", "name": "unknown_refresh_with_options", "options": []interface{}{map[string]interface{}{"text": "A", "value": "A"}}, "refresh": 2001},
|
||||
map[string]interface{}{"type": "query", "name": "unknown_refresh_without_options", "options": []interface{}{}, "refresh": 2001},
|
||||
map[string]interface{}{"type": "custom", "name": "custom", "options": []interface{}{map[string]interface{}{"text": "custom", "value": "custom"}}},
|
||||
map[string]interface{}{"type": "textbox", "name": "textbox", "options": []interface{}{map[string]interface{}{"text": "Hello", "value": "World"}}},
|
||||
map[string]interface{}{"type": "datasource", "name": "datasource", "options": []interface{}{map[string]interface{}{"text": "ds", "value": "ds"}}},
|
||||
map[string]interface{}{"type": "interval", "name": "interval", "options": []interface{}{map[string]interface{}{"text": "1m", "value": "1m"}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V29 Query Variables Migration Test Dashboard",
|
||||
"schemaVersion": 29,
|
||||
"templating": map[string]interface{}{
|
||||
"list": []interface{}{
|
||||
map[string]interface{}{"type": "query", "name": "never_refresh_with_options", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "never_refresh_without_options", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "dashboard_refresh_with_options", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "dashboard_refresh_without_options", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "timerange_refresh_with_options", "options": []interface{}{}, "refresh": 2},
|
||||
map[string]interface{}{"type": "query", "name": "timerange_refresh_without_options", "options": []interface{}{}, "refresh": 2},
|
||||
map[string]interface{}{"type": "query", "name": "no_refresh_with_options", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "no_refresh_without_options", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "unknown_refresh_with_options", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "unknown_refresh_without_options", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "custom", "name": "custom", "options": []interface{}{map[string]interface{}{"text": "custom", "value": "custom"}}},
|
||||
map[string]interface{}{"type": "textbox", "name": "textbox", "options": []interface{}{map[string]interface{}{"text": "Hello", "value": "World"}}},
|
||||
map[string]interface{}{"type": "datasource", "name": "datasource", "options": []interface{}{map[string]interface{}{"text": "ds", "value": "ds"}}},
|
||||
map[string]interface{}{"type": "interval", "name": "interval", "options": []interface{}{map[string]interface{}{"text": "1m", "value": "1m"}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "non-query variables remain unchanged",
|
||||
input: map[string]interface{}{
|
||||
"title": "V29 Non-Query Variables Test Dashboard",
|
||||
"schemaVersion": 28,
|
||||
"templating": map[string]interface{}{
|
||||
"list": []interface{}{
|
||||
map[string]interface{}{"type": "custom", "name": "custom", "options": []interface{}{map[string]interface{}{"text": "custom", "value": "custom"}}},
|
||||
map[string]interface{}{"type": "textbox", "name": "textbox", "options": []interface{}{map[string]interface{}{"text": "Hello", "value": "World"}}},
|
||||
map[string]interface{}{"type": "datasource", "name": "datasource", "options": []interface{}{map[string]interface{}{"text": "ds", "value": "ds"}}},
|
||||
map[string]interface{}{"type": "interval", "name": "interval", "options": []interface{}{map[string]interface{}{"text": "1m", "value": "1m"}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V29 Non-Query Variables Test Dashboard",
|
||||
"schemaVersion": 29,
|
||||
"templating": map[string]interface{}{
|
||||
"list": []interface{}{
|
||||
map[string]interface{}{"type": "custom", "name": "custom", "options": []interface{}{map[string]interface{}{"text": "custom", "value": "custom"}}},
|
||||
map[string]interface{}{"type": "textbox", "name": "textbox", "options": []interface{}{map[string]interface{}{"text": "Hello", "value": "World"}}},
|
||||
map[string]interface{}{"type": "datasource", "name": "datasource", "options": []interface{}{map[string]interface{}{"text": "ds", "value": "ds"}}},
|
||||
map[string]interface{}{"type": "interval", "name": "interval", "options": []interface{}{map[string]interface{}{"text": "1m", "value": "1m"}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all query variables should have options removed",
|
||||
input: map[string]interface{}{
|
||||
"title": "V29 Query Variables Options Removal Test Dashboard",
|
||||
"schemaVersion": 28,
|
||||
"templating": map[string]interface{}{
|
||||
"list": []interface{}{
|
||||
map[string]interface{}{"type": "query", "name": "query1", "options": []interface{}{map[string]interface{}{"text": "A", "value": "A"}}},
|
||||
map[string]interface{}{"type": "query", "name": "query2", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "query3", "options": []interface{}{map[string]interface{}{"text": "B", "value": "B"}, map[string]interface{}{"text": "C", "value": "C"}}, "refresh": 2},
|
||||
map[string]interface{}{"type": "query", "name": "query4", "options": []interface{}{map[string]interface{}{"text": "D", "value": "D"}}, "refresh": 0},
|
||||
map[string]interface{}{"type": "query", "name": "query5", "options": []interface{}{map[string]interface{}{"text": "E", "value": "E"}}, "refresh": 2001},
|
||||
map[string]interface{}{"type": "query", "name": "query6", "options": []interface{}{}},
|
||||
map[string]interface{}{"type": "query", "name": "query7", "options": []interface{}{map[string]interface{}{"text": "F", "value": "F"}}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "query8", "options": []interface{}{map[string]interface{}{"text": "G", "value": "G"}}, "refresh": 2},
|
||||
map[string]interface{}{"type": "query", "name": "query9", "options": []interface{}{map[string]interface{}{"text": "H", "value": "H"}}},
|
||||
map[string]interface{}{"type": "query", "name": "query10", "options": []interface{}{map[string]interface{}{"text": "I", "value": "I"}}, "refresh": 999},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V29 Query Variables Options Removal Test Dashboard",
|
||||
"schemaVersion": 29,
|
||||
"templating": map[string]interface{}{
|
||||
"list": []interface{}{
|
||||
map[string]interface{}{"type": "query", "name": "query1", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "query2", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "query3", "options": []interface{}{}, "refresh": 2},
|
||||
map[string]interface{}{"type": "query", "name": "query4", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "query5", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "query6", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "query7", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "query8", "options": []interface{}{}, "refresh": 2},
|
||||
map[string]interface{}{"type": "query", "name": "query9", "options": []interface{}{}, "refresh": 1},
|
||||
map[string]interface{}{"type": "query", "name": "query10", "options": []interface{}{}, "refresh": 1},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
runMigrationTests(t, tests, schemaversion.V29)
|
||||
}
|
||||
393
apps/dashboard/pkg/migration/schemaversion/v30.go
Normal file
393
apps/dashboard/pkg/migration/schemaversion/v30.go
Normal file
@@ -0,0 +1,393 @@
|
||||
package schemaversion
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// V30 upgrades value mappings and migrates tooltip options for panels.
|
||||
//
|
||||
// This migration addresses two key improvements to panel configurations:
|
||||
// 1. Value mappings upgrade: Converts legacy value mapping format to the new structured format
|
||||
// 2. Tooltip options migration: Renames tooltipOptions to tooltip in specific panel types: timeseries, xychart, xychart2
|
||||
//
|
||||
// The migration works by:
|
||||
// 1. Iterating through all panels in the dashboard, including nested panels in collapsed rows
|
||||
// 2. For each panel, upgrading value mappings in fieldConfig.defaults and fieldConfig.overrides
|
||||
// 3. Migrating tooltip options for timeseries, xychart, and xychart2 panels
|
||||
// 4. Preserving all other panel configurations and options
|
||||
//
|
||||
// Value Mappings Migration:
|
||||
// - Converts legacy mapping types (1 = ValueToText, 2 = RangeToText) to new format
|
||||
// - Handles special "null" values by converting them to SpecialValue mappings
|
||||
// - Preserves threshold colors when available
|
||||
// - Consolidates multiple value mappings into a single ValueToText mapping
|
||||
// - Maintains range mappings as separate RangeToText mappings
|
||||
//
|
||||
// Tooltip Options Migration:
|
||||
// - Renames panel.options.tooltipOptions to panel.options.tooltip
|
||||
// - Only applies to timeseries, xychart, and xychart2 panel types
|
||||
// - Preserves all tooltip configuration options
|
||||
//
|
||||
// Example value mappings transformation:
|
||||
//
|
||||
// Before migration:
|
||||
//
|
||||
// panel: {
|
||||
// "fieldConfig": {
|
||||
// "defaults": {
|
||||
// "mappings": [
|
||||
// { "id": 0, "text": "Up", "type": 1, "value": "1" },
|
||||
// { "id": 1, "text": "Down", "type": 1, "value": "0" },
|
||||
// { "from": "10", "to": "20", "text": "Medium", "type": 2 }
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// After migration:
|
||||
//
|
||||
// panel: {
|
||||
// "fieldConfig": {
|
||||
// "defaults": {
|
||||
// "mappings": [
|
||||
// {
|
||||
// "type": "value",
|
||||
// "options": {
|
||||
// "1": { "text": "Up" },
|
||||
// "0": { "text": "Down" }
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// "type": "range",
|
||||
// "options": {
|
||||
// "from": 10,
|
||||
// "to": 20,
|
||||
// "result": { "text": "Medium" }
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Example tooltip options transformation:
|
||||
//
|
||||
// Before migration:
|
||||
//
|
||||
// panel: {
|
||||
// "type": "timeseries",
|
||||
// "options": {
|
||||
// "tooltipOptions": { "mode": "multi" }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// After migration:
|
||||
//
|
||||
// panel: {
|
||||
// "type": "timeseries",
|
||||
// "options": {
|
||||
// "tooltip": { "mode": "multi" }
|
||||
// }
|
||||
// }
|
||||
func V30(dashboard map[string]interface{}) error {
|
||||
dashboard["schemaVersion"] = 30
|
||||
|
||||
panels, ok := dashboard["panels"].([]interface{})
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, panel := range panels {
|
||||
panelMap, ok := panel.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
upgradeValueMappingsForPanel(panelMap)
|
||||
migrateTooltipOptions(panelMap)
|
||||
|
||||
// Handle nested panels in collapsed rows
|
||||
nestedPanels, hasNested := panelMap["panels"].([]interface{})
|
||||
if !hasNested {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, nestedPanel := range nestedPanels {
|
||||
nestedPanelMap, ok := nestedPanel.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
upgradeValueMappingsForPanel(nestedPanelMap)
|
||||
migrateTooltipOptions(nestedPanelMap)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// upgradeValueMappingsForPanel migrates value mappings from old format to new format
|
||||
func upgradeValueMappingsForPanel(panel map[string]interface{}) {
|
||||
fieldConfig, ok := panel["fieldConfig"].(map[string]interface{})
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
// Upgrade defaults mappings
|
||||
if defaults, ok := fieldConfig["defaults"].(map[string]interface{}); ok {
|
||||
if mappings, ok := defaults["mappings"].([]interface{}); ok {
|
||||
var thresholds map[string]interface{}
|
||||
if t, ok := defaults["thresholds"].(map[string]interface{}); ok {
|
||||
thresholds = t
|
||||
}
|
||||
defaults["mappings"] = upgradeValueMappings(mappings, thresholds)
|
||||
}
|
||||
}
|
||||
|
||||
// Upgrade overrides mappings
|
||||
overrides, hasOverrides := fieldConfig["overrides"].([]interface{})
|
||||
if !hasOverrides {
|
||||
return
|
||||
}
|
||||
|
||||
for _, override := range overrides {
|
||||
overrideMap, ok := override.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
properties, hasProperties := overrideMap["properties"].([]interface{})
|
||||
if !hasProperties {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, property := range properties {
|
||||
propertyMap, ok := property.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if propertyMap["id"] != "mappings" {
|
||||
continue
|
||||
}
|
||||
|
||||
mappings, ok := propertyMap["value"].([]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
propertyMap["value"] = upgradeValueMappings(mappings, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// upgradeValueMappings converts legacy value mappings to new format
|
||||
func upgradeValueMappings(oldMappings []interface{}, thresholds map[string]interface{}) []interface{} {
|
||||
if len(oldMappings) == 0 {
|
||||
return oldMappings
|
||||
}
|
||||
|
||||
valueMaps := map[string]interface{}{
|
||||
"type": "value",
|
||||
"options": map[string]interface{}{},
|
||||
}
|
||||
|
||||
var newMappings []interface{}
|
||||
hasValueMappings := false
|
||||
|
||||
for _, mapping := range oldMappings {
|
||||
if mappingMap, ok := mapping.(map[string]interface{}); ok {
|
||||
// Check if this is already the new format
|
||||
if mappingType, ok := mappingMap["type"].(string); ok && mappingType != "" {
|
||||
if mappingType == "value" {
|
||||
// Consolidate existing value mappings
|
||||
if options, ok := mappingMap["options"].(map[string]interface{}); ok {
|
||||
valueMapsOptions := valueMaps["options"].(map[string]interface{})
|
||||
for k, v := range options {
|
||||
valueMapsOptions[k] = v
|
||||
}
|
||||
hasValueMappings = true
|
||||
}
|
||||
} else {
|
||||
newMappings = append(newMappings, mappingMap)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Handle legacy format
|
||||
var color interface{}
|
||||
if thresholds != nil {
|
||||
// Try to get color from threshold based on the mapping value
|
||||
if value, ok := mappingMap["value"]; ok {
|
||||
if valueStr, ok := value.(string); ok {
|
||||
if numeric, err := strconv.ParseFloat(valueStr, 64); err == nil {
|
||||
color = getActiveThresholdColor(numeric, thresholds)
|
||||
}
|
||||
}
|
||||
}
|
||||
// For range mappings, use the 'from' value to determine color
|
||||
if fromVal, ok := mappingMap["from"]; ok {
|
||||
if fromStr, ok := fromVal.(string); ok {
|
||||
if numeric, err := strconv.ParseFloat(fromStr, 64); err == nil {
|
||||
color = getActiveThresholdColor(numeric, thresholds)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert legacy type numbers to new format
|
||||
if mappingType, ok := mappingMap["type"].(float64); ok {
|
||||
switch int(mappingType) {
|
||||
case 1: // ValueToText
|
||||
if value, ok := mappingMap["value"]; ok {
|
||||
if valueStr, ok := value.(string); ok && valueStr == "null" {
|
||||
// Handle null values as special value mapping
|
||||
// For null values, use the base threshold color (lowest step)
|
||||
if thresholds != nil {
|
||||
color = getBaseThresholdColor(thresholds)
|
||||
}
|
||||
newMappings = append(newMappings, map[string]interface{}{
|
||||
"type": "special",
|
||||
"options": map[string]interface{}{
|
||||
"match": "null",
|
||||
"result": map[string]interface{}{
|
||||
"text": mappingMap["text"],
|
||||
"color": color,
|
||||
},
|
||||
},
|
||||
})
|
||||
} else {
|
||||
// Regular value mapping
|
||||
valueMapsOptions := valueMaps["options"].(map[string]interface{})
|
||||
result := map[string]interface{}{
|
||||
"text": mappingMap["text"],
|
||||
}
|
||||
if color != nil {
|
||||
result["color"] = color
|
||||
}
|
||||
valueMapsOptions[stringifyValue(value)] = result
|
||||
hasValueMappings = true
|
||||
}
|
||||
}
|
||||
case 2: // RangeToText
|
||||
result := map[string]interface{}{
|
||||
"text": mappingMap["text"],
|
||||
}
|
||||
if color != nil {
|
||||
result["color"] = color
|
||||
}
|
||||
|
||||
from, _ := strconv.ParseFloat(stringifyValue(mappingMap["from"]), 64)
|
||||
to, _ := strconv.ParseFloat(stringifyValue(mappingMap["to"]), 64)
|
||||
|
||||
newMappings = append(newMappings, map[string]interface{}{
|
||||
"type": "range",
|
||||
"options": map[string]interface{}{
|
||||
"from": from,
|
||||
"to": to,
|
||||
"result": result,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add consolidated value mappings at the beginning if any exist
|
||||
if hasValueMappings {
|
||||
newMappings = append([]interface{}{valueMaps}, newMappings...)
|
||||
}
|
||||
|
||||
return newMappings
|
||||
}
|
||||
|
||||
// getActiveThresholdColor returns the color for a value based on thresholds
|
||||
func getActiveThresholdColor(value float64, thresholds map[string]interface{}) interface{} {
|
||||
if steps, ok := thresholds["steps"].([]interface{}); ok {
|
||||
var activeStep map[string]interface{}
|
||||
|
||||
for _, step := range steps {
|
||||
if stepMap, ok := step.(map[string]interface{}); ok {
|
||||
if stepValue, ok := stepMap["value"]; ok {
|
||||
if stepValue == nil {
|
||||
// Null value represents negative infinity - this is always the base color
|
||||
activeStep = stepMap
|
||||
continue
|
||||
}
|
||||
|
||||
if stepNum, ok := stepValue.(float64); ok {
|
||||
if value >= stepNum {
|
||||
activeStep = stepMap
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if activeStep != nil {
|
||||
return activeStep["color"]
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// getBaseThresholdColor returns the base threshold color (first step with null value)
|
||||
func getBaseThresholdColor(thresholds map[string]interface{}) interface{} {
|
||||
if steps, ok := thresholds["steps"].([]interface{}); ok {
|
||||
for _, step := range steps {
|
||||
if stepMap, ok := step.(map[string]interface{}); ok {
|
||||
if stepValue, ok := stepMap["value"]; ok {
|
||||
if stepValue == nil {
|
||||
// This is the base color (null value step)
|
||||
return stepMap["color"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// migrateTooltipOptions renames tooltipOptions to tooltip for specific panel types
|
||||
func migrateTooltipOptions(panel map[string]interface{}) {
|
||||
panelType, ok := panel["type"].(string)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
// Only migrate for specific panel types
|
||||
if panelType != "timeseries" && panelType != "xychart" && panelType != "xychart2" {
|
||||
return
|
||||
}
|
||||
|
||||
options, ok := panel["options"].(map[string]interface{})
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
tooltipOptions, ok := options["tooltipOptions"]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
// Rename tooltipOptions to tooltip
|
||||
options["tooltip"] = tooltipOptions
|
||||
delete(options, "tooltipOptions")
|
||||
}
|
||||
|
||||
// stringifyValue converts a value to string
|
||||
func stringifyValue(value interface{}) string {
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
return v
|
||||
case float64:
|
||||
return strconv.FormatFloat(v, 'f', -1, 64)
|
||||
case int:
|
||||
return strconv.Itoa(v)
|
||||
case bool:
|
||||
return strconv.FormatBool(v)
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
499
apps/dashboard/pkg/migration/schemaversion/v30_test.go
Normal file
499
apps/dashboard/pkg/migration/schemaversion/v30_test.go
Normal file
@@ -0,0 +1,499 @@
|
||||
package schemaversion_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
|
||||
)
|
||||
|
||||
func TestV30(t *testing.T) {
|
||||
tests := []migrationTestCase{
|
||||
{
|
||||
name: "panel with legacy value mappings gets upgraded to new format",
|
||||
input: map[string]interface{}{
|
||||
"title": "V30 Value Mappings Migration Test Dashboard",
|
||||
"schemaVersion": 29,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with legacy value mappings",
|
||||
"id": 1,
|
||||
"fieldConfig": map[string]interface{}{
|
||||
"defaults": map[string]interface{}{
|
||||
"thresholds": map[string]interface{}{
|
||||
"mode": "absolute",
|
||||
"steps": []interface{}{
|
||||
map[string]interface{}{
|
||||
"color": "green",
|
||||
"value": nil,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"color": "red",
|
||||
"value": float64(80),
|
||||
},
|
||||
},
|
||||
},
|
||||
"mappings": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": 0,
|
||||
"text": "Up",
|
||||
"type": float64(1),
|
||||
"value": "1",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": 1,
|
||||
"text": "Down",
|
||||
"type": float64(1),
|
||||
"value": "0",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"from": "10",
|
||||
"to": "20",
|
||||
"text": "Medium",
|
||||
"type": float64(2),
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": float64(1),
|
||||
"value": "null",
|
||||
"text": "Null Value",
|
||||
},
|
||||
},
|
||||
},
|
||||
"overrides": []interface{}{
|
||||
map[string]interface{}{
|
||||
"matcher": map[string]interface{}{
|
||||
"id": "byName",
|
||||
"options": "test-field",
|
||||
},
|
||||
"properties": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "mappings",
|
||||
"value": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": 0,
|
||||
"text": "Override Up",
|
||||
"type": float64(1),
|
||||
"value": "1",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V30 Value Mappings Migration Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with legacy value mappings",
|
||||
"id": 1,
|
||||
"fieldConfig": map[string]interface{}{
|
||||
"defaults": map[string]interface{}{
|
||||
"thresholds": map[string]interface{}{
|
||||
"mode": "absolute",
|
||||
"steps": []interface{}{
|
||||
map[string]interface{}{
|
||||
"color": "green",
|
||||
"value": nil,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"color": "red",
|
||||
"value": float64(80),
|
||||
},
|
||||
},
|
||||
},
|
||||
"mappings": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "value",
|
||||
"options": map[string]interface{}{
|
||||
"1": map[string]interface{}{
|
||||
"text": "Up",
|
||||
"color": "green",
|
||||
},
|
||||
"0": map[string]interface{}{
|
||||
"text": "Down",
|
||||
"color": "green",
|
||||
},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "range",
|
||||
"options": map[string]interface{}{
|
||||
"from": float64(10),
|
||||
"to": float64(20),
|
||||
"result": map[string]interface{}{
|
||||
"text": "Medium",
|
||||
"color": "green",
|
||||
},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "special",
|
||||
"options": map[string]interface{}{
|
||||
"match": "null",
|
||||
"result": map[string]interface{}{
|
||||
"text": "Null Value",
|
||||
"color": "green",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"overrides": []interface{}{
|
||||
map[string]interface{}{
|
||||
"matcher": map[string]interface{}{
|
||||
"id": "byName",
|
||||
"options": "test-field",
|
||||
},
|
||||
"properties": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "mappings",
|
||||
"value": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "value",
|
||||
"options": map[string]interface{}{
|
||||
"1": map[string]interface{}{
|
||||
"text": "Override Up",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "panel with tooltip options gets migrated to tooltip",
|
||||
input: map[string]interface{}{
|
||||
"title": "V30 Tooltip Options Migration Test Dashboard",
|
||||
"schemaVersion": 29,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with tooltipOptions",
|
||||
"id": 1,
|
||||
"options": map[string]interface{}{
|
||||
"tooltipOptions": map[string]interface{}{
|
||||
"mode": "multi",
|
||||
},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "xychart",
|
||||
"title": "XY Chart with tooltipOptions",
|
||||
"id": 2,
|
||||
"options": map[string]interface{}{
|
||||
"tooltipOptions": map[string]interface{}{
|
||||
"mode": "single",
|
||||
},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "xychart2",
|
||||
"title": "XY Chart2 with tooltipOptions",
|
||||
"id": 3,
|
||||
"options": map[string]interface{}{
|
||||
"tooltipOptions": map[string]interface{}{
|
||||
"mode": "single",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V30 Tooltip Options Migration Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with tooltipOptions",
|
||||
"id": 1,
|
||||
"options": map[string]interface{}{
|
||||
"tooltip": map[string]interface{}{
|
||||
"mode": "multi",
|
||||
},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "xychart",
|
||||
"title": "XY Chart with tooltipOptions",
|
||||
"id": 2,
|
||||
"options": map[string]interface{}{
|
||||
"tooltip": map[string]interface{}{
|
||||
"mode": "single",
|
||||
},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "xychart2",
|
||||
"title": "XY Chart2 with tooltipOptions",
|
||||
"id": 3,
|
||||
"options": map[string]interface{}{
|
||||
"tooltip": map[string]interface{}{
|
||||
"mode": "single",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "panel with nested panels in collapsed row gets migrated",
|
||||
input: map[string]interface{}{
|
||||
"title": "V30 Nested Panels Migration Test Dashboard",
|
||||
"schemaVersion": 29,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "row",
|
||||
"title": "Collapsed Row",
|
||||
"id": 1,
|
||||
"collapsed": true,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Nested panel with tooltipOptions",
|
||||
"id": 2,
|
||||
"options": map[string]interface{}{
|
||||
"tooltipOptions": map[string]interface{}{
|
||||
"mode": "multi",
|
||||
},
|
||||
},
|
||||
"fieldConfig": map[string]interface{}{
|
||||
"defaults": map[string]interface{}{
|
||||
"mappings": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": 0,
|
||||
"text": "On",
|
||||
"type": float64(1),
|
||||
"value": "1",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V30 Nested Panels Migration Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "row",
|
||||
"title": "Collapsed Row",
|
||||
"id": 1,
|
||||
"collapsed": true,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Nested panel with tooltipOptions",
|
||||
"id": 2,
|
||||
"options": map[string]interface{}{
|
||||
"tooltip": map[string]interface{}{
|
||||
"mode": "multi",
|
||||
},
|
||||
},
|
||||
"fieldConfig": map[string]interface{}{
|
||||
"defaults": map[string]interface{}{
|
||||
"mappings": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "value",
|
||||
"options": map[string]interface{}{
|
||||
"1": map[string]interface{}{
|
||||
"text": "On",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "panel with no mappings or tooltip options remains unchanged",
|
||||
input: map[string]interface{}{
|
||||
"title": "V30 No Changes Test Dashboard",
|
||||
"schemaVersion": 29,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with no relevant configurations",
|
||||
"id": 1,
|
||||
"fieldConfig": map[string]interface{}{
|
||||
"defaults": map[string]interface{}{
|
||||
"unit": "bytes",
|
||||
},
|
||||
},
|
||||
"options": map[string]interface{}{
|
||||
"legend": map[string]interface{}{
|
||||
"displayMode": "list",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V30 No Changes Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with no relevant configurations",
|
||||
"id": 1,
|
||||
"fieldConfig": map[string]interface{}{
|
||||
"defaults": map[string]interface{}{
|
||||
"unit": "bytes",
|
||||
},
|
||||
},
|
||||
"options": map[string]interface{}{
|
||||
"legend": map[string]interface{}{
|
||||
"displayMode": "list",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "panels remain unchanged when no V30 specific migrations apply",
|
||||
input: map[string]interface{}{
|
||||
"title": "V30 Panel Types Unchanged Test Dashboard",
|
||||
"schemaVersion": 29,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "graph",
|
||||
"title": "Graph panel",
|
||||
"id": 1,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "singlestat",
|
||||
"title": "Singlestat panel",
|
||||
"id": 2,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Already timeseries panel",
|
||||
"id": 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V30 Panel Types Unchanged Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "graph",
|
||||
"title": "Graph panel",
|
||||
"id": 1,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "singlestat",
|
||||
"title": "Singlestat panel",
|
||||
"id": 2,
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Already timeseries panel",
|
||||
"id": 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "graph panels with different configurations remain unchanged in V30",
|
||||
input: map[string]interface{}{
|
||||
"title": "V30 Graph Panel Configurations Test Dashboard",
|
||||
"schemaVersion": 29,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "graph",
|
||||
"title": "Graph with series mode and legend values",
|
||||
"id": 1,
|
||||
"xaxis": map[string]interface{}{
|
||||
"mode": "series",
|
||||
},
|
||||
"legend": map[string]interface{}{
|
||||
"values": true,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "graph",
|
||||
"title": "Graph with series mode",
|
||||
"id": 2,
|
||||
"xaxis": map[string]interface{}{
|
||||
"mode": "series",
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "graph",
|
||||
"title": "Graph with histogram mode",
|
||||
"id": 3,
|
||||
"xaxis": map[string]interface{}{
|
||||
"mode": "histogram",
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "graph",
|
||||
"title": "Graph with default configuration",
|
||||
"id": 4,
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V30 Graph Panel Configurations Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "graph",
|
||||
"title": "Graph with series mode and legend values",
|
||||
"id": 1,
|
||||
"xaxis": map[string]interface{}{
|
||||
"mode": "series",
|
||||
},
|
||||
"legend": map[string]interface{}{
|
||||
"values": true,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "graph",
|
||||
"title": "Graph with series mode",
|
||||
"id": 2,
|
||||
"xaxis": map[string]interface{}{
|
||||
"mode": "series",
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "graph",
|
||||
"title": "Graph with histogram mode",
|
||||
"id": 3,
|
||||
"xaxis": map[string]interface{}{
|
||||
"mode": "histogram",
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "graph",
|
||||
"title": "Graph with default configuration",
|
||||
"id": 4,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
runMigrationTests(t, tests, schemaversion.V30)
|
||||
}
|
||||
132
apps/dashboard/pkg/migration/schemaversion/v31.go
Normal file
132
apps/dashboard/pkg/migration/schemaversion/v31.go
Normal file
@@ -0,0 +1,132 @@
|
||||
package schemaversion
|
||||
|
||||
// V31 adds a merge transformer after any labelsToFields transformer in panel transformations.
|
||||
//
|
||||
// This migration addresses data processing workflow optimization by automatically inserting
|
||||
// a merge transformation after the labelsToFields transformation. When the labelsToFields
|
||||
// transformer converts time series labels to individual fields, it can result in multiple
|
||||
// data frames that need to be consolidated for proper visualization and analysis.
|
||||
//
|
||||
// The migration works by:
|
||||
// 1. Iterating through all panels in the dashboard, including nested panels in collapsed rows
|
||||
// 2. Examining the transformations array within each panel
|
||||
// 3. Identifying transformations with id 'labelsToFields'
|
||||
// 4. Inserting a merge transformation with empty options immediately after each labelsToFields transformation
|
||||
// 5. Preserving the original labelsToFields options (mode, keepLabels, valueLabel, etc.) without modification
|
||||
// 6. Using empty options for merge transformations to enable optimal default consolidation behavior
|
||||
// 7. Preserving the original order and configuration of all other transformations
|
||||
//
|
||||
// The migration handles complex scenarios including:
|
||||
// - Multiple labelsToFields transformations within a single panel
|
||||
// - Panels with mixed transformation types
|
||||
// - Nested panels within collapsed row panels
|
||||
// - Panels with no transformations (left unchanged)
|
||||
// - Panels with transformations but no labelsToFields (left unchanged)
|
||||
//
|
||||
// Example transformation:
|
||||
//
|
||||
// Before migration:
|
||||
//
|
||||
// panel: {
|
||||
// "transformations": [
|
||||
// { "id": "organize", "options": {} },
|
||||
// { "id": "labelsToFields", "options": {} },
|
||||
// { "id": "calculateField", "options": {} },
|
||||
// { "id": "labelsToFields", "options": { "mode": "rows", "keepLabels": ["job", "instance"] } },
|
||||
// ]
|
||||
// }
|
||||
//
|
||||
// After migration:
|
||||
//
|
||||
// panel: {
|
||||
// "transformations": [
|
||||
// { "id": "organize", "options": {} },
|
||||
// { "id": "labelsToFields", "options": {} },
|
||||
// { "id": "merge", "options": {} },
|
||||
// { "id": "calculateField", "options": {} },
|
||||
// { "id": "labelsToFields", "options": { "mode": "rows", "keepLabels": ["job", "instance"] } },
|
||||
// { "id": "merge", "options": {} }
|
||||
// ]
|
||||
// }
|
||||
func V31(dashboard map[string]interface{}) error {
|
||||
dashboard["schemaVersion"] = int(31)
|
||||
|
||||
panels, ok := dashboard["panels"].([]interface{})
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Process all panels, including nested ones
|
||||
processPanelsV31(panels)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// processPanelsV31 recursively processes panels, including nested panels within rows
|
||||
func processPanelsV31(panels []interface{}) {
|
||||
for _, panel := range panels {
|
||||
p, ok := panel.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
// Process nested panels if this is a row panel
|
||||
if p["type"] == "row" {
|
||||
nestedPanels, hasNested := p["panels"].([]interface{})
|
||||
if !hasNested {
|
||||
continue
|
||||
}
|
||||
processPanelsV31(nestedPanels)
|
||||
continue
|
||||
}
|
||||
|
||||
transformations, ok := p["transformations"].([]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check if we have any labelsToFields transformations
|
||||
hasLabelsToFields := false
|
||||
for _, transformation := range transformations {
|
||||
t, ok := transformation.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if t["id"] == "labelsToFields" {
|
||||
hasLabelsToFields = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !hasLabelsToFields {
|
||||
continue
|
||||
}
|
||||
|
||||
// Create new transformations array with merge transformations added
|
||||
newTransformations := []interface{}{}
|
||||
|
||||
for _, transformation := range transformations {
|
||||
t, ok := transformation.(map[string]interface{})
|
||||
if !ok {
|
||||
newTransformations = append(newTransformations, transformation)
|
||||
continue
|
||||
}
|
||||
|
||||
// Add the current transformation (preserving all original options)
|
||||
newTransformations = append(newTransformations, transformation)
|
||||
|
||||
// If this is a labelsToFields transformation, add a merge transformation after it
|
||||
// with empty options to enable optimal default consolidation behavior
|
||||
if t["id"] == "labelsToFields" {
|
||||
mergeTransformation := map[string]interface{}{
|
||||
"id": "merge",
|
||||
"options": map[string]interface{}{},
|
||||
}
|
||||
newTransformations = append(newTransformations, mergeTransformation)
|
||||
}
|
||||
}
|
||||
|
||||
// Update the panel with the new transformations
|
||||
p["transformations"] = newTransformations
|
||||
}
|
||||
}
|
||||
336
apps/dashboard/pkg/migration/schemaversion/v31_test.go
Normal file
336
apps/dashboard/pkg/migration/schemaversion/v31_test.go
Normal file
@@ -0,0 +1,336 @@
|
||||
package schemaversion_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
|
||||
)
|
||||
|
||||
func TestV31(t *testing.T) {
|
||||
tests := []migrationTestCase{
|
||||
{
|
||||
name: "panel with basic labelsToFields transformation gets merge transformation added",
|
||||
input: map[string]interface{}{
|
||||
"title": "V31 LabelsToFields Migration Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with basic labelsToFields",
|
||||
"id": 1,
|
||||
"transformations": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "labelsToFields",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V31 LabelsToFields Migration Test Dashboard",
|
||||
"schemaVersion": 31,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with basic labelsToFields",
|
||||
"id": 1,
|
||||
"transformations": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "labelsToFields",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "merge",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "panel with labelsToFields options preserved during migration",
|
||||
input: map[string]interface{}{
|
||||
"title": "V31 LabelsToFields Options Preservation Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with labelsToFields options",
|
||||
"id": 1,
|
||||
"transformations": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "labelsToFields",
|
||||
"options": map[string]interface{}{
|
||||
"mode": "rows",
|
||||
"keepLabels": []interface{}{"job", "instance"},
|
||||
"valueLabel": "value",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V31 LabelsToFields Options Preservation Test Dashboard",
|
||||
"schemaVersion": 31,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with labelsToFields options",
|
||||
"id": 1,
|
||||
"transformations": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "labelsToFields",
|
||||
"options": map[string]interface{}{
|
||||
"mode": "rows",
|
||||
"keepLabels": []interface{}{"job", "instance"},
|
||||
"valueLabel": "value",
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "merge",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "panel with multiple labelsToFields transformations",
|
||||
input: map[string]interface{}{
|
||||
"title": "V31 Multiple LabelsToFields Migration Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with multiple labelsToFields",
|
||||
"id": 1,
|
||||
"transformations": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "organize",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "labelsToFields",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "calculateField",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "labelsToFields",
|
||||
"options": map[string]interface{}{
|
||||
"mode": "rows",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V31 Multiple LabelsToFields Migration Test Dashboard",
|
||||
"schemaVersion": 31,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with multiple labelsToFields",
|
||||
"id": 1,
|
||||
"transformations": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "organize",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "labelsToFields",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "merge",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "calculateField",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "labelsToFields",
|
||||
"options": map[string]interface{}{
|
||||
"mode": "rows",
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "merge",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "panel with no transformations remains unchanged",
|
||||
input: map[string]interface{}{
|
||||
"title": "V31 No Transformations Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with no transformations",
|
||||
"id": 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V31 No Transformations Test Dashboard",
|
||||
"schemaVersion": 31,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with no transformations",
|
||||
"id": 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "panel with transformations but no labelsToFields remains unchanged",
|
||||
input: map[string]interface{}{
|
||||
"title": "V31 Other Transformations Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with other transformations",
|
||||
"id": 1,
|
||||
"transformations": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "organize",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "reduce",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V31 Other Transformations Test Dashboard",
|
||||
"schemaVersion": 31,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with other transformations",
|
||||
"id": 1,
|
||||
"transformations": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "organize",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "reduce",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "nested panels in row with labelsToFields transformation",
|
||||
input: map[string]interface{}{
|
||||
"title": "V31 Nested Panels Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "row",
|
||||
"title": "Row with nested panels",
|
||||
"id": 1,
|
||||
"collapsed": false,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Nested panel with labelsToFields",
|
||||
"id": 2,
|
||||
"transformations": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "labelsToFields",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Nested panel without labelsToFields",
|
||||
"id": 3,
|
||||
"transformations": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "organize",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V31 Nested Panels Test Dashboard",
|
||||
"schemaVersion": 31,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "row",
|
||||
"title": "Row with nested panels",
|
||||
"id": 1,
|
||||
"collapsed": false,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Nested panel with labelsToFields",
|
||||
"id": 2,
|
||||
"transformations": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "labelsToFields",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"id": "merge",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Nested panel without labelsToFields",
|
||||
"id": 3,
|
||||
"transformations": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": "organize",
|
||||
"options": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "dashboard with no panels",
|
||||
input: map[string]interface{}{
|
||||
"title": "V31 No Panels Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V31 No Panels Test Dashboard",
|
||||
"schemaVersion": 31,
|
||||
},
|
||||
},
|
||||
}
|
||||
runMigrationTests(t, tests, schemaversion.V31)
|
||||
}
|
||||
27
apps/dashboard/pkg/migration/schemaversion/v32.go
Normal file
27
apps/dashboard/pkg/migration/schemaversion/v32.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package schemaversion
|
||||
|
||||
// V32 is a no-op migration that serves as a placeholder for consistency.
|
||||
//
|
||||
// The migration performs no modifications to the dashboard structure and simply
|
||||
// updates the schema version number.
|
||||
// Example (no changes made):
|
||||
//
|
||||
// Before migration:
|
||||
//
|
||||
// dashboard: {
|
||||
// "title": "My Dashboard",
|
||||
// "schemaVersion": 31,
|
||||
// "panels": [...]
|
||||
// }
|
||||
//
|
||||
// After migration:
|
||||
//
|
||||
// dashboard: {
|
||||
// "title": "My Dashboard",
|
||||
// "schemaVersion": 32,
|
||||
// "panels": [...] // unchanged
|
||||
// }
|
||||
func V32(dashboard map[string]interface{}) error {
|
||||
dashboard["schemaVersion"] = int(32)
|
||||
return nil
|
||||
}
|
||||
38
apps/dashboard/pkg/migration/schemaversion/v32_test.go
Normal file
38
apps/dashboard/pkg/migration/schemaversion/v32_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package schemaversion_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
|
||||
)
|
||||
|
||||
func TestV32(t *testing.T) {
|
||||
tests := []migrationTestCase{
|
||||
{
|
||||
name: "v32 no-op migration updates schema version only",
|
||||
input: map[string]interface{}{
|
||||
"title": "V32 No-Op Migration Test Dashboard",
|
||||
"schemaVersion": 31,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel remains unchanged",
|
||||
"id": 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"title": "V32 No-Op Migration Test Dashboard",
|
||||
"schemaVersion": 32,
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "timeseries",
|
||||
"title": "Panel remains unchanged",
|
||||
"id": 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
runMigrationTests(t, tests, schemaversion.V32)
|
||||
}
|
||||
137
apps/dashboard/pkg/migration/testdata/input/v29.query_variables_refresh_and_options.json
vendored
Normal file
137
apps/dashboard/pkg/migration/testdata/input/v29.query_variables_refresh_and_options.json
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
{
|
||||
"title": "V29 Query Variables Refresh and Options Migration Test Dashboard",
|
||||
"schemaVersion": 28,
|
||||
"templating": {
|
||||
"list": [
|
||||
{
|
||||
"name": "never_refresh_with_options",
|
||||
"type": "query",
|
||||
"datasource": "prometheus",
|
||||
"options": [
|
||||
{"text": "A", "value": "A"},
|
||||
{"text": "B", "value": "B"}
|
||||
],
|
||||
"refresh": 0
|
||||
},
|
||||
{
|
||||
"name": "never_refresh_without_options",
|
||||
"type": "query",
|
||||
"datasource": "prometheus",
|
||||
"options": [],
|
||||
"refresh": 0
|
||||
},
|
||||
{
|
||||
"name": "dashboard_refresh_with_options",
|
||||
"type": "query",
|
||||
"datasource": "prometheus",
|
||||
"options": [
|
||||
{"text": "C", "value": "C"}
|
||||
],
|
||||
"refresh": 1
|
||||
},
|
||||
{
|
||||
"name": "dashboard_refresh_without_options",
|
||||
"type": "query",
|
||||
"datasource": "prometheus",
|
||||
"options": [],
|
||||
"refresh": 1
|
||||
},
|
||||
{
|
||||
"name": "timerange_refresh_with_options",
|
||||
"type": "query",
|
||||
"datasource": "prometheus",
|
||||
"options": [
|
||||
{"text": "D", "value": "D"},
|
||||
{"text": "E", "value": "E"}
|
||||
],
|
||||
"refresh": 2
|
||||
},
|
||||
{
|
||||
"name": "timerange_refresh_without_options",
|
||||
"type": "query",
|
||||
"datasource": "prometheus",
|
||||
"options": [],
|
||||
"refresh": 2
|
||||
},
|
||||
{
|
||||
"name": "no_refresh_with_options",
|
||||
"type": "query",
|
||||
"datasource": "prometheus",
|
||||
"options": [
|
||||
{"text": "F", "value": "F"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "no_refresh_without_options",
|
||||
"type": "query",
|
||||
"datasource": "prometheus",
|
||||
"options": []
|
||||
},
|
||||
{
|
||||
"name": "unknown_refresh_with_options",
|
||||
"type": "query",
|
||||
"datasource": "prometheus",
|
||||
"options": [
|
||||
{"text": "G", "value": "G"}
|
||||
],
|
||||
"refresh": 2001
|
||||
},
|
||||
{
|
||||
"name": "unknown_refresh_without_options",
|
||||
"type": "query",
|
||||
"datasource": "prometheus",
|
||||
"options": [],
|
||||
"refresh": 2001
|
||||
},
|
||||
{
|
||||
"name": "custom_variable",
|
||||
"type": "custom",
|
||||
"options": [
|
||||
{"text": "custom", "value": "custom"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "textbox_variable",
|
||||
"type": "textbox",
|
||||
"options": [
|
||||
{"text": "Hello", "value": "World"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "datasource_variable",
|
||||
"type": "datasource",
|
||||
"options": [
|
||||
{"text": "ds", "value": "ds"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "interval_variable",
|
||||
"type": "interval",
|
||||
"options": [
|
||||
{"text": "1m", "value": "1m"}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Test Panel",
|
||||
"type": "timeseries",
|
||||
"datasource": "prometheus",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "up"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"time": {
|
||||
"from": "now-6h",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"refresh_intervals": ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"]
|
||||
}
|
||||
}
|
||||
214
apps/dashboard/pkg/migration/testdata/input/v30.value_mappings_and_tooltip_options.json
vendored
Normal file
214
apps/dashboard/pkg/migration/testdata/input/v30.value_mappings_and_tooltip_options.json
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
{
|
||||
"title": "V30 Value Mappings and Tooltip Options Migration Test Dashboard",
|
||||
"schemaVersion": 29,
|
||||
"panels": [
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with legacy value mappings and tooltip options",
|
||||
"id": 1,
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
},
|
||||
"mappings": [
|
||||
{
|
||||
"id": 0,
|
||||
"text": "Up",
|
||||
"type": 1,
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"text": "Down",
|
||||
"type": 1,
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"from": "10",
|
||||
"to": "20",
|
||||
"text": "Medium",
|
||||
"type": 2
|
||||
},
|
||||
{
|
||||
"type": 1,
|
||||
"value": "null",
|
||||
"text": "Null Value"
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"matcher": {
|
||||
"id": "byName",
|
||||
"options": "test-field"
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"id": "mappings",
|
||||
"value": [
|
||||
{
|
||||
"id": 0,
|
||||
"text": "Override Up",
|
||||
"type": 1,
|
||||
"value": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"tooltipOptions": {
|
||||
"mode": "multi"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "xychart",
|
||||
"title": "XY Chart with tooltip options only",
|
||||
"id": 2,
|
||||
"options": {
|
||||
"tooltipOptions": {
|
||||
"mode": "single"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "xychart2",
|
||||
"title": "XY Chart2 with tooltip options",
|
||||
"id": 3,
|
||||
"options": {
|
||||
"tooltipOptions": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "graph",
|
||||
"title": "Graph panel gets migrated to timeseries and tooltip",
|
||||
"id": 4,
|
||||
"options": {
|
||||
"tooltip": {
|
||||
"mode": "single"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "stat",
|
||||
"title": "Panel with complex value mappings",
|
||||
"id": 5,
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"mappings": [
|
||||
{
|
||||
"id": 0,
|
||||
"text": "Critical",
|
||||
"type": 1,
|
||||
"value": "100"
|
||||
},
|
||||
{
|
||||
"from": "50",
|
||||
"to": "99",
|
||||
"text": "Warning",
|
||||
"type": 2
|
||||
},
|
||||
{
|
||||
"from": "0",
|
||||
"to": "49",
|
||||
"text": "OK",
|
||||
"type": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "row",
|
||||
"title": "Collapsed Row with nested panels",
|
||||
"id": 6,
|
||||
"collapsed": true,
|
||||
"panels": [
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Nested panel with both migrations",
|
||||
"id": 7,
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"mappings": [
|
||||
{
|
||||
"id": 0,
|
||||
"text": "On",
|
||||
"type": 1,
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"text": "Off",
|
||||
"type": 1,
|
||||
"value": "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"tooltipOptions": {
|
||||
"mode": "multi"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with no relevant configurations",
|
||||
"id": 8,
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "bytes"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "stat",
|
||||
"title": "Panel with empty mappings array - should return null",
|
||||
"id": 9,
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"mappings": []
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"matcher": {
|
||||
"id": "byName",
|
||||
"options": "empty-field"
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"id": "mappings",
|
||||
"value": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
126
apps/dashboard/pkg/migration/testdata/input/v31.labels_to_fields_merge.json
vendored
Normal file
126
apps/dashboard/pkg/migration/testdata/input/v31.labels_to_fields_merge.json
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"title": "V31 LabelsToFields Merge Migration Test Dashboard",
|
||||
"schemaVersion": 30,
|
||||
"panels": [
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with basic labelsToFields transformation",
|
||||
"id": 1,
|
||||
"transformations": [
|
||||
{
|
||||
"id": "labelsToFields",
|
||||
"options": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with labelsToFields options preserved",
|
||||
"id": 9,
|
||||
"transformations": [
|
||||
{
|
||||
"id": "labelsToFields",
|
||||
"options": {
|
||||
"mode": "rows",
|
||||
"keepLabels": ["job", "instance", "region"],
|
||||
"valueLabel": "value"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with multiple labelsToFields transformations",
|
||||
"id": 2,
|
||||
"transformations": [
|
||||
{
|
||||
"id": "organize",
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "labelsToFields",
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "calculateField",
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "labelsToFields",
|
||||
"options": {
|
||||
"mode": "rows"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with no transformations",
|
||||
"id": 3
|
||||
},
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with other transformations only",
|
||||
"id": 4,
|
||||
"transformations": [
|
||||
{
|
||||
"id": "organize",
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "reduce",
|
||||
"options": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "row",
|
||||
"title": "Row with nested panels",
|
||||
"id": 5,
|
||||
"collapsed": false,
|
||||
"panels": [
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Nested panel with labelsToFields",
|
||||
"id": 6,
|
||||
"transformations": [
|
||||
{
|
||||
"id": "labelsToFields",
|
||||
"options": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Nested panel without labelsToFields",
|
||||
"id": 7,
|
||||
"transformations": [
|
||||
{
|
||||
"id": "organize",
|
||||
"options": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Panel with labelsToFields and existing merge",
|
||||
"id": 8,
|
||||
"transformations": [
|
||||
{
|
||||
"id": "labelsToFields",
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "merge",
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": "reduce",
|
||||
"options": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user