Support importing local cue modules when generating TS types with cog (#96876)

* Support importing local cue modules when generating TS types with cog

* Generate enums as unions of values instead of an actual `enum` statement

* Update transformers to use the new TS enums

* Update go workspaces

---------

Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
This commit is contained in:
Kévin Gomez 2024-11-28 10:45:31 +01:00 committed by GitHub
parent c8caf787d4
commit c8d3ea58f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 280 additions and 415 deletions

View File

@ -59,10 +59,10 @@ require (
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/term v0.26.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/time v0.6.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect

View File

@ -141,8 +141,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -153,8 +153,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=

10
go.mod
View File

@ -171,15 +171,15 @@ require (
go.uber.org/atomic v1.11.0 // @grafana/alerting-backend
go.uber.org/goleak v1.3.0 // @grafana/grafana-search-and-storage
gocloud.dev v0.40.0 // @grafana/grafana-app-platform-squad
golang.org/x/crypto v0.28.0 // @grafana/grafana-backend-group
golang.org/x/crypto v0.29.0 // @grafana/grafana-backend-group
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // @grafana/alerting-backend
golang.org/x/mod v0.21.0 // indirect; @grafana/grafana-backend-group
golang.org/x/net v0.30.0 // @grafana/oss-big-tent @grafana/partner-datasources
golang.org/x/mod v0.22.0 // indirect; @grafana/grafana-backend-group
golang.org/x/net v0.31.0 // @grafana/oss-big-tent @grafana/partner-datasources
golang.org/x/oauth2 v0.23.0 // @grafana/identity-access-team
golang.org/x/sync v0.9.0 // @grafana/alerting-backend
golang.org/x/text v0.20.0 // @grafana/grafana-backend-group
golang.org/x/time v0.6.0 // @grafana/grafana-backend-group
golang.org/x/tools v0.26.0 // @grafana/grafana-as-code
golang.org/x/tools v0.27.0 // @grafana/grafana-as-code
gonum.org/v1/gonum v0.15.1 // @grafana/observability-metrics
google.golang.org/api v0.193.0 // @grafana/grafana-backend-group
google.golang.org/grpc v1.67.1 // @grafana/plugins-platform-backend
@ -431,7 +431,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // @grafana/identity-access-team
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/term v0.26.0 // indirect
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect
google.golang.org/genproto v0.0.0-20240820151423-278611b39280 // indirect; @grafana/grafana-backend-group
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect

20
go.sum
View File

@ -3516,8 +3516,8 @@ golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1m
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@ -3595,8 +3595,8 @@ golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -3695,8 +3695,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@ -3931,8 +3931,8 @@ golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -4062,8 +4062,8 @@ golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@ -989,6 +989,9 @@ github.com/grafana/alerting v0.0.0-20240917171353-6c25eb6eff10 h1:oDbLKM34O+JUF9
github.com/grafana/alerting v0.0.0-20240917171353-6c25eb6eff10/go.mod h1:GMLi6d09Xqo96fCVUjNk//rcjP5NKEdjOzfWIffD5r4=
github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 h1:qhugDMdQ4Vp68H0tp/0iN17DM2ehRo1rLEdOFe/gB8I=
github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2/go.mod h1:w/aiO1POVIeXUQyl0VQSZjl5OAGDTL5aX+4v0RA1tcw=
github.com/grafana/cog v0.0.4/go.mod h1:lzetOuhGUl/JaSACiJoHvBokf9/fS6PEFaWZvnQu2vs=
github.com/grafana/cog v0.0.5 h1:BCa+10i3KvV+KMSQuxlN1DS9cZEwN+EAFc7ZmXqHxQE=
github.com/grafana/cog v0.0.5/go.mod h1:lzetOuhGUl/JaSACiJoHvBokf9/fS6PEFaWZvnQu2vs=
github.com/grafana/cuetsy v0.1.10/go.mod h1:Ix97+CPD8ws9oSSxR3/Lf4ahU1I4Np83kjJmDVnLZvc=
github.com/grafana/go-gelf/v2 v2.0.1 h1:BOChP0h/jLeD+7F9mL7tq10xVkDG15he3T1zHuQaWak=
github.com/grafana/go-gelf/v2 v2.0.1/go.mod h1:lexHie0xzYGwCgiRGcvZ723bSNyNI8ZRD4s0CLobh90=
@ -1783,6 +1786,7 @@ golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
@ -1796,6 +1800,7 @@ golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457 h1:zf5N6UOrA487eEFacMePxjXAJctxKmyjKUsjA11Uzuk=
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=

View File

@ -6,46 +6,47 @@ import (
"context"
"os"
"cuelang.org/go/cue/cuecontext"
"github.com/grafana/cog"
)
type codegenTargets struct {
schemaPath string
outputPath string
modulePath string
outputPath string
cueImportsMap map[string]string
packagesImportMap map[string]string
}
func main() {
cueCtx := cuecontext.New()
targets := []codegenTargets{
{
schemaPath: "../packages/grafana-schema/src/schema/dashboard/v2alpha0/dashboard.schema.cue",
modulePath: "../packages/grafana-schema/src/schema/dashboard/v2alpha0/",
outputPath: "../packages/grafana-schema/src/schema/dashboard/v2alpha0/dashboard.gen.ts",
cueImportsMap: map[string]string{
"github.com/grafana/grafana/packages/grafana-schema/src/common": "../packages/grafana-schema/src/common",
},
packagesImportMap: map[string]string{
"common": "@grafana/schema",
},
},
}
for _, target := range targets {
rawSchema, err := os.ReadFile(target.schemaPath)
if err != nil {
panic(err)
}
value := cueCtx.CompileBytes(rawSchema)
if value.Err() != nil {
panic(value.Err())
}
codegenPipeline := cog.TypesFromSchema().
CUEValue("dashboard", value).
Typescript()
CUEModule(
target.modulePath,
cog.CUEImports(target.cueImportsMap),
).
Typescript(cog.TypescriptConfig{
ImportsMap: target.packagesImportMap,
EnumsAsUnionTypes: true,
})
tsBytes, err := codegenPipeline.Run(context.Background())
files, err := codegenPipeline.Run(context.Background())
if err != nil {
panic(err)
}
if err := os.WriteFile(target.outputPath, tsBytes, 0644); err != nil {
if err := os.WriteFile(target.outputPath, files[0].Data, 0644); err != nil {
panic(err)
}
}

View File

@ -2,13 +2,11 @@ module github.com/grafana/grafana/kindsv2
go 1.23.1
require (
cuelang.org/go v0.8.2
github.com/grafana/cog v0.0.0-20241029201114-f7f7db0c1070
)
require github.com/grafana/cog v0.0.5
require (
cuelabs.dev/go/oci/ociregistry v0.0.0-20240906074133-82eb438dd565 // indirect
cuelang.org/go v0.8.2 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/proto v1.13.2 // indirect
@ -36,11 +34,11 @@ require (
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/yalue/merged_fs v1.3.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.26.0 // indirect
golang.org/x/tools v0.27.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

View File

@ -26,8 +26,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grafana/codejen v0.0.4-0.20230321061741-77f656893a3d h1:hrXbGJ5jgp6yNITzs5o+zXq0V5yT3siNJ+uM8LGwWKk=
github.com/grafana/codejen v0.0.4-0.20230321061741-77f656893a3d/go.mod h1:zmwwM/DRyQB7pfuBjTWII3CWtxcXh8LTwAYGfDfpR6s=
github.com/grafana/cog v0.0.0-20241029201114-f7f7db0c1070 h1:ncAkFmIq3UbPiPhQ2CuBzdTuwnDqLsFFNqEIXKaiPGA=
github.com/grafana/cog v0.0.0-20241029201114-f7f7db0c1070/go.mod h1:FqZi9WZ/Uzvs3tvo7l+OViThCpfvu3KDGDqHCB2LNbg=
github.com/grafana/cog v0.0.5 h1:BCa+10i3KvV+KMSQuxlN1DS9cZEwN+EAFc7ZmXqHxQE=
github.com/grafana/cog v0.0.5/go.mod h1:lzetOuhGUl/JaSACiJoHvBokf9/fS6PEFaWZvnQu2vs=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@ -73,20 +73,20 @@ github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4d
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/yalue/merged_fs v1.3.0 h1:qCeh9tMPNy/i8cwDsQTJ5bLr6IRxbs6meakNE5O+wyY=
github.com/yalue/merged_fs v1.3.0/go.mod h1:WqqchfVYQyclV2tnR7wtRhBddzBvLVR83Cjw9BKQw0M=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

View File

@ -1,5 +1,8 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
import * as common from '@grafana/schema';
export interface DashboardV2Spec {
// Unique numeric identifier for the dashboard.
// `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances.
@ -42,7 +45,7 @@ export interface DashboardV2Spec {
export const defaultDashboardV2Spec = (): DashboardV2Spec => ({
title: "",
cursorSync: DashboardCursorSync.Off,
cursorSync: "Off",
preload: false,
editable: true,
links: [],
@ -69,13 +72,9 @@ export const defaultAnnotationPanelFilter = (): AnnotationPanelFilter => ({
// "Off" for no shared crosshair or tooltip (default).
// "Crosshair" for shared crosshair.
// "Tooltip" for shared crosshair AND shared tooltip.
export enum DashboardCursorSync {
Off = "Off",
Crosshair = "Crosshair",
Tooltip = "Tooltip",
}
export type DashboardCursorSync = "Off" | "Crosshair" | "Tooltip";
export const defaultDashboardCursorSync = (): DashboardCursorSync => (DashboardCursorSync.Off);
export const defaultDashboardCursorSync = (): DashboardCursorSync => ("Off");
// Links with references to other dashboards or external resources
export interface DashboardLink {
@ -104,7 +103,7 @@ export interface DashboardLink {
export const defaultDashboardLink = (): DashboardLink => ({
title: "",
type: DashboardLinkType.Link,
type: "link",
icon: "",
tooltip: "",
tags: [],
@ -124,14 +123,6 @@ export interface DataSourceRef {
export const defaultDataSourceRef = (): DataSourceRef => ({
});
export enum DataTopic {
AlertStates = "alertStates",
Annotations = "annotations",
Series = "series",
}
export const defaultDataTopic = (): DataTopic => (DataTopic.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.
@ -143,7 +134,7 @@ export interface DataTransformerConfig {
// 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;
topic?: common.DataTopic;
// Options to be passed to the transformer
// Valid options depend on the transformer id
options: any;
@ -263,12 +254,9 @@ export const defaultThreshold = (): Threshold => ({
color: "",
});
export enum ThresholdsMode {
Absolute = "absolute",
Percentage = "percentage",
}
export type ThresholdsMode = "absolute" | "percentage";
export const defaultThresholdsMode = (): ThresholdsMode => (ThresholdsMode.Absolute);
export const defaultThresholdsMode = (): ThresholdsMode => ("absolute");
export interface ThresholdsConfig {
mode: ThresholdsMode;
@ -276,7 +264,7 @@ export interface ThresholdsConfig {
}
export const defaultThresholdsConfig = (): ThresholdsConfig => ({
mode: ThresholdsMode.Absolute,
mode: "absolute",
steps: [],
});
@ -289,14 +277,9 @@ export const defaultValueMapping = (): ValueMapping => (defaultValueMap());
// `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.
export enum MappingType {
ValueToText = "value",
RangeToText = "range",
RegexToText = "regex",
SpecialValue = "special",
}
export type MappingType = "value" | "range" | "regex" | "special";
export const defaultMappingType = (): MappingType => (MappingType.ValueToText);
export const defaultMappingType = (): MappingType => ("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.
@ -372,22 +355,15 @@ export interface SpecialValueMap {
export const defaultSpecialValueMap = (): SpecialValueMap => ({
type: "special",
options: {
match: SpecialValueMatch.True,
match: "true",
result: defaultValueMappingResult(),
},
});
// Special value types supported by the `SpecialValueMap`
export enum SpecialValueMatch {
True = "true",
False = "false",
Null = "null",
NotANumber = "nan",
NullAndNaN = "null+nan",
Empty = "empty",
}
export type SpecialValueMatch = "true" | "false" | "null" | "nan" | "null+nan" | "empty";
export const defaultSpecialValueMatch = (): SpecialValueMatch => (SpecialValueMatch.True);
export const defaultSpecialValueMatch = (): SpecialValueMatch => ("true");
// Result used as replacement with text and color when the value matches
export interface ValueMappingResult {
@ -422,34 +398,14 @@ export const defaultValueMappingResult = (): ValueMappingResult => ({
// `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.
export enum FieldColorModeId {
Thresholds = "thresholds",
PaletteClassic = "palette-classic",
PaletteClassicByName = "palette-classic-by-name",
ContinuousGrYlRd = "continuous-GrYlRd",
ContinuousRdYlGr = "continuous-RdYlGr",
ContinuousBlYlRd = "continuous-BlYlRd",
ContinuousYlRd = "continuous-YlRd",
ContinuousBlPu = "continuous-BlPu",
ContinuousYlBl = "continuous-YlBl",
ContinuousBlues = "continuous-blues",
ContinuousReds = "continuous-reds",
ContinuousGreens = "continuous-greens",
ContinuousPurples = "continuous-purples",
Fixed = "fixed",
Shades = "shades",
}
export type 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";
export const defaultFieldColorModeId = (): FieldColorModeId => (FieldColorModeId.Thresholds);
export const defaultFieldColorModeId = (): FieldColorModeId => ("thresholds");
// 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.
export enum FieldColorSeriesByMode {
Min = "min",
Max = "max",
Last = "last",
}
export type FieldColorSeriesByMode = "min" | "max" | "last";
export const defaultFieldColorSeriesByMode = (): FieldColorSeriesByMode => (FieldColorSeriesByMode.Min);
export const defaultFieldColorSeriesByMode = (): FieldColorSeriesByMode => ("min");
// Map a field to a color.
export interface FieldColor {
@ -462,16 +418,13 @@ export interface FieldColor {
}
export const defaultFieldColor = (): FieldColor => ({
mode: FieldColorModeId.Thresholds,
mode: "thresholds",
});
// Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource)
export enum DashboardLinkType {
Link = "link",
Dashboards = "dashboards",
}
export type DashboardLinkType = "link" | "dashboards";
export const defaultDashboardLinkType = (): DashboardLinkType => (DashboardLinkType.Link);
export const defaultDashboardLinkType = (): DashboardLinkType => ("link");
// --- Common types ---
export interface Kind {
@ -790,7 +743,7 @@ export interface CustomFormatterVariable {
export const defaultCustomFormatterVariable = (): CustomFormatterVariable => ({
name: "",
type: VariableType.Query,
type: "query",
multi: false,
includeAll: false,
});
@ -821,7 +774,7 @@ export const defaultVariableCustomFormatterFn = (): VariableCustomFormatterFn =>
value: {},
legacyVariableModel: {
name: "",
type: VariableType.Query,
type: "query",
multi: false,
includeAll: false,
},
@ -836,20 +789,9 @@ export const defaultVariableCustomFormatterFn = (): VariableCustomFormatterFn =>
// `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
export enum VariableType {
Query = "query",
Adhoc = "adhoc",
Groupby = "groupby",
Constant = "constant",
Datasource = "datasource",
Interval = "interval",
Textbox = "textbox",
Custom = "custom",
System = "system",
Snapshot = "snapshot",
}
export type VariableType = "query" | "adhoc" | "groupby" | "constant" | "datasource" | "interval" | "textbox" | "custom" | "system" | "snapshot";
export const defaultVariableType = (): VariableType => (VariableType.Query);
export const defaultVariableType = (): VariableType => ("query");
// Sort variable options
// Accepted values are:
@ -863,41 +805,23 @@ export const defaultVariableType = (): VariableType => (VariableType.Query);
// `naturalAsc`: Natural ASC
// `naturalDesc`: Natural DESC
// VariableSort enum with default value
export enum VariableSort {
Disabled = "disabled",
AlphabeticalAsc = "alphabeticalAsc",
AlphabeticalDesc = "alphabeticalDesc",
NumericalAsc = "numericalAsc",
NumericalDesc = "numericalDesc",
AlphabeticalCaseInsensitiveAsc = "alphabeticalCaseInsensitiveAsc",
AlphabeticalCaseInsensitiveDesc = "alphabeticalCaseInsensitiveDesc",
NaturalAsc = "naturalAsc",
NaturalDesc = "naturalDesc",
}
export type VariableSort = "disabled" | "alphabeticalAsc" | "alphabeticalDesc" | "numericalAsc" | "numericalDesc" | "alphabeticalCaseInsensitiveAsc" | "alphabeticalCaseInsensitiveDesc" | "naturalAsc" | "naturalDesc";
export const defaultVariableSort = (): VariableSort => (VariableSort.Disabled);
export const defaultVariableSort = (): VariableSort => ("disabled");
// 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.
export enum VariableRefresh {
Never = "never",
OnDashboardLoad = "onDashboardLoad",
OnTimeRangeChanged = "onTimeRangeChanged",
}
export type VariableRefresh = "never" | "onDashboardLoad" | "onTimeRangeChanged";
export const defaultVariableRefresh = (): VariableRefresh => (VariableRefresh.Never);
export const defaultVariableRefresh = (): VariableRefresh => ("never");
// Determine if the variable shows on dashboard
// Accepted values are `dontHide` (show label and value), `hideLabel` (show value only), `hideVariable` (show nothing).
export enum VariableHide {
DontHide = "dontHide",
HideLabel = "hideLabel",
HideVariable = "hideVariable",
}
export type VariableHide = "dontHide" | "hideLabel" | "hideVariable";
export const defaultVariableHide = (): VariableHide => (VariableHide.DontHide);
export const defaultVariableHide = (): VariableHide => ("dontHide");
// FIXME: should we introduce this? --- Variable value option
export interface VariableValueOption {
@ -950,13 +874,13 @@ export interface QueryVariableSpec {
export const defaultQueryVariableSpec = (): QueryVariableSpec => ({
name: "",
current: { text: "", value: "", },
hide: VariableHide.DontHide,
refresh: VariableRefresh.Never,
hide: "dontHide",
refresh: "never",
skipUrlSync: false,
datasource: defaultDataSourceRef(),
query: "",
regex: "",
sort: VariableSort.Disabled,
sort: "disabled",
options: [],
multi: false,
includeAll: false,
@ -988,7 +912,7 @@ export const defaultTextVariableSpec = (): TextVariableSpec => ({
name: "",
current: { text: "", value: "", },
query: "",
hide: VariableHide.DontHide,
hide: "dontHide",
skipUrlSync: false,
});
@ -1018,7 +942,7 @@ export const defaultConstantVariableSpec = (): ConstantVariableSpec => ({
name: "",
query: "",
current: { text: "", value: "", },
hide: VariableHide.DontHide,
hide: "dontHide",
skipUrlSync: false,
});
@ -1054,14 +978,14 @@ export interface DatasourceVariableSpec {
export const defaultDatasourceVariableSpec = (): DatasourceVariableSpec => ({
name: "",
pluginId: "",
refresh: VariableRefresh.Never,
refresh: "never",
regex: "",
current: { text: "", value: "", },
defaultOptionEnabled: false,
options: [],
multi: false,
includeAll: false,
hide: VariableHide.DontHide,
hide: "dontHide",
skipUrlSync: false,
});
@ -1100,8 +1024,8 @@ export const defaultIntervalVariableSpec = (): IntervalVariableSpec => ({
auto: false,
auto_min: "",
auto_count: 0,
refresh: VariableRefresh.Never,
hide: VariableHide.DontHide,
refresh: "never",
hide: "dontHide",
skipUrlSync: false,
});
@ -1138,7 +1062,7 @@ export const defaultCustomVariableSpec = (): CustomVariableSpec => ({
options: [],
multi: false,
includeAll: false,
hide: VariableHide.DontHide,
hide: "dontHide",
skipUrlSync: false,
});
@ -1175,7 +1099,7 @@ export const defaultGroupByVariableSpec = (): GroupByVariableSpec => ({
options: [],
multi: false,
includeAll: false,
hide: VariableHide.DontHide,
hide: "dontHide",
skipUrlSync: false,
});
@ -1209,7 +1133,7 @@ export const defaultAdhocVariableSpec = (): AdhocVariableSpec => ({
baseFilters: [],
filters: [],
defaultKeys: [],
hide: VariableHide.DontHide,
hide: "dontHide",
skipUrlSync: false,
});

View File

@ -1,4 +1,8 @@
package dashboard
package v2alpha0
import (
"github.com/grafana/grafana/packages/grafana-schema/src/common"
)
DashboardV2Spec: {
// Unique numeric identifier for the dashboard.
@ -102,8 +106,6 @@ DataSourceRef: {
uid?: string
}
DataTopic: "alertStates" | "annotations" | "series"
// 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.
@ -115,7 +117,7 @@ DataTransformerConfig: {
// 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
topic?: common.DataTopic
// Options to be passed to the transformer
// Valid options depend on the transformer id
options: _

View File

@ -1,21 +1,15 @@
import {
DashboardCursorSync,
DashboardLinkType,
DashboardV2Spec,
VariableHide,
VariableRefresh,
VariableSort,
} from './dashboard.gen';
import { DashboardV2Spec } from './dashboard.gen';
export const handyTestingSchema: DashboardV2Spec = {
title: 'Test Dashboard',
description: 'Test Description',
id: 1,
title: 'Default Dashboard',
description: 'This is a default dashboard',
cursorSync: 'Off',
liveNow: false,
preload: false,
editable: true,
preload: true,
schemaVersion: 40,
tags: ['tag1', 'tag2'],
liveNow: true,
cursorSync: DashboardCursorSync.Crosshair,
timeSettings: {
autoRefresh: '5s',
autoRefreshIntervals: ['5s', '10s', '30s'],
@ -132,7 +126,7 @@ export const handyTestingSchema: DashboardV2Spec = {
targetBlank: false,
title: 'Test Link',
tooltip: '',
type: DashboardLinkType.Dashboards,
type: 'dashboards',
url: 'http://test.com',
},
],
@ -152,17 +146,17 @@ export const handyTestingSchema: DashboardV2Spec = {
},
definition: 'definition1',
description: 'A query variable',
hide: VariableHide.DontHide,
hide: 'dontHide',
includeAll: true,
label: 'Query Variable',
multi: true,
name: 'queryVar',
options: [],
query: 'query1',
refresh: VariableRefresh.OnDashboardLoad,
refresh: 'onDashboardLoad',
regex: 'regex1',
skipUrlSync: false,
sort: VariableSort.Disabled,
sort: 'disabled',
},
},
{
@ -174,7 +168,7 @@ export const handyTestingSchema: DashboardV2Spec = {
value: 'option1',
},
description: 'A custom variable',
hide: VariableHide.DontHide,
hide: 'dontHide',
includeAll: true,
label: 'Custom Variable',
multi: true,
@ -205,14 +199,14 @@ export const handyTestingSchema: DashboardV2Spec = {
},
defaultOptionEnabled: true,
description: 'A datasource variable',
hide: VariableHide.DontHide,
hide: 'dontHide',
includeAll: false,
label: 'Datasource Variable',
multi: false,
name: 'datasourceVar',
options: [],
pluginId: 'datasource1',
refresh: VariableRefresh.OnDashboardLoad,
refresh: 'onDashboardLoad',
regex: 'regex1',
skipUrlSync: false,
},
@ -225,7 +219,7 @@ export const handyTestingSchema: DashboardV2Spec = {
value: 'value4',
},
description: 'A constant variable',
hide: VariableHide.DontHide,
hide: 'dontHide',
label: 'Constant Variable',
name: 'constantVar',
query: 'value4',
@ -243,7 +237,7 @@ export const handyTestingSchema: DashboardV2Spec = {
value: '1m',
},
description: 'An interval variable',
hide: VariableHide.DontHide,
hide: 'dontHide',
label: 'Interval Variable',
name: 'intervalVar',
options: [
@ -264,7 +258,7 @@ export const handyTestingSchema: DashboardV2Spec = {
},
],
query: '1m,5m,10m',
refresh: VariableRefresh.OnDashboardLoad,
refresh: 'onDashboardLoad',
skipUrlSync: false,
},
},
@ -276,7 +270,7 @@ export const handyTestingSchema: DashboardV2Spec = {
value: 'value6',
},
description: 'A text variable',
hide: VariableHide.DontHide,
hide: 'dontHide',
label: 'Text Variable',
name: 'textVar',
query: 'value6',
@ -295,7 +289,7 @@ export const handyTestingSchema: DashboardV2Spec = {
uid: 'datasource2',
},
description: 'A group by variable',
hide: VariableHide.DontHide,
hide: 'dontHide',
includeAll: false,
label: 'Group By Variable',
multi: false,
@ -351,7 +345,7 @@ export const handyTestingSchema: DashboardV2Spec = {
value: 'value3',
},
],
hide: VariableHide.DontHide,
hide: 'dontHide',
label: 'Adhoc Variable',
name: 'adhocVar',
skipUrlSync: false,

View File

@ -134,17 +134,17 @@ require (
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/term v0.26.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.26.0 // indirect
golang.org/x/tools v0.27.0 // indirect
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect
gonum.org/v1/gonum v0.15.1 // indirect
google.golang.org/genproto v0.0.0-20240820151423-278611b39280 // indirect

View File

@ -381,8 +381,8 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk=
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
@ -392,8 +392,8 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -403,8 +403,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
@ -433,8 +433,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
@ -452,8 +452,8 @@ golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@ -35,8 +35,8 @@ require (
github.com/x448/float16 v0.8.4 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect

View File

@ -77,8 +77,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
@ -91,8 +91,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

View File

@ -78,13 +78,13 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/term v0.26.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.26.0 // indirect
golang.org/x/tools v0.27.0 // indirect
google.golang.org/genproto v0.0.0-20240820151423-278611b39280 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect

View File

@ -221,8 +221,8 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk=
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
@ -241,8 +241,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
@ -259,8 +259,8 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
@ -277,8 +277,8 @@ golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@ -35,9 +35,9 @@ require (
go.opentelemetry.io/otel v1.32.0 // indirect; @grafana/grafana-backend-group
go.opentelemetry.io/otel/sdk v1.32.0 // indirect; @grafana/grafana-backend-group
go.opentelemetry.io/otel/trace v1.32.0 // indirect; @grafana/grafana-backend-group
golang.org/x/crypto v0.28.0 // indirect; @grafana/grafana-backend-group
golang.org/x/mod v0.21.0 // @grafana/grafana-backend-group
golang.org/x/net v0.30.0 // indirect; @grafana/oss-big-tent @grafana/partner-datasources
golang.org/x/crypto v0.29.0 // indirect; @grafana/grafana-backend-group
golang.org/x/mod v0.22.0 // @grafana/grafana-backend-group
golang.org/x/net v0.31.0 // indirect; @grafana/oss-big-tent @grafana/partner-datasources
golang.org/x/oauth2 v0.23.0 // @grafana/identity-access-team
golang.org/x/sync v0.9.0 // indirect; @grafana/alerting-backend
golang.org/x/text v0.20.0 // indirect; @grafana/grafana-backend-group

View File

@ -262,8 +262,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk=
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
@ -272,8 +272,8 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -283,8 +283,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=

View File

@ -6,10 +6,10 @@ require (
github.com/google/go-cmp v0.6.0
github.com/google/subcommands v1.2.0
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
golang.org/x/tools v0.26.0
golang.org/x/tools v0.27.0
)
require (
golang.org/x/mod v0.21.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/sync v0.9.0 // indirect
)

View File

@ -4,9 +4,9 @@ github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=

View File

@ -111,12 +111,12 @@ require (
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/goleak v1.3.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.26.0 // indirect
golang.org/x/tools v0.27.0 // indirect
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect
gonum.org/v1/gonum v0.15.1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect

View File

@ -297,15 +297,15 @@ golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -337,8 +337,8 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@ -1131,8 +1131,8 @@ func TestFoldersGetAPIEndpointK8S(t *testing.T) {
},
expectedCode: http.StatusOK,
expectedOutput: []dtos.FolderSearchHit{
dtos.FolderSearchHit{UID: "foo", Title: "Folder 1"},
dtos.FolderSearchHit{UID: "qux", Title: "Folder 3"},
{UID: "foo", Title: "Folder 1"},
{UID: "qux", Title: "Folder 3"},
},
permissions: folderReadAndCreatePermission,
},
@ -1146,7 +1146,7 @@ func TestFoldersGetAPIEndpointK8S(t *testing.T) {
params: "?parentUid=foo",
expectedCode: http.StatusOK,
expectedOutput: []dtos.FolderSearchHit{
dtos.FolderSearchHit{UID: "bar", Title: "Folder 2", ParentUID: "foo"},
{UID: "bar", Title: "Folder 2", ParentUID: "foo"},
},
permissions: folderReadAndCreatePermission,
},

View File

@ -18,7 +18,6 @@ import {
GroupByVariableKind,
defaultVariableHide,
VariableOption,
VariableRefresh,
} from '@grafana/schema/dist/esm/schema/dashboard/v2alpha0/dashboard.gen';
import { getIntervalsQueryFromNewIntervalModel } from '../utils/utils';
@ -53,7 +52,7 @@ export function sceneVariablesSetToVariables(set: SceneVariables, keepQueryOptio
let options: VariableOption[] = [];
// Not sure if we actually have to still support this option given
// that it's not exposed in the UI
if (transformVariableRefreshToEnum(variable.state.refresh) === VariableRefresh.Never || keepQueryOptions) {
if (transformVariableRefreshToEnum(variable.state.refresh) === 'never' || keepQueryOptions) {
options = variableValueOptionsToVariableOptions(variable.state);
}
variables.push({
@ -269,7 +268,7 @@ export function sceneVariablesSetToSchemaV2Variables(
if (sceneUtils.isQueryVariable(variable)) {
// Not sure if we actually have to still support this option given
// that it's not exposed in the UI
if (transformVariableRefreshToEnum(variable.state.refresh) === VariableRefresh.Never || keepQueryOptions) {
if (transformVariableRefreshToEnum(variable.state.refresh) === 'never' || keepQueryOptions) {
options = variableValueOptionsToVariableOptions(variable.state);
}
//query: DataQueryKind | string;
@ -325,7 +324,7 @@ export function sceneVariablesSetToSchemaV2Variables(
current: currentVariableOption,
options: [],
regex: variable.state.regex,
refresh: VariableRefresh.OnDashboardLoad,
refresh: 'onDashboardLoad',
pluginId: variable.state.pluginId,
defaultOptionEnabled: !!variable.state.defaultOptionEnabled,
multi: variable.state.isMulti || false,
@ -361,7 +360,7 @@ export function sceneVariablesSetToSchemaV2Variables(
text: variable.state.value,
},
query: intervals,
refresh: VariableRefresh.OnTimeRangeChanged,
refresh: 'onTimeRangeChanged',
options: variable.state.intervals.map((interval) => ({
value: interval,
text: interval,

View File

@ -53,7 +53,7 @@ describe('transformSaveModelSchemaV2ToScene', () => {
expect(scene.state.title).toEqual(dash.title);
expect(scene.state.description).toEqual(dash.description);
expect(scene.state.editable).toEqual(dash.editable);
expect(scene.state.preload).toEqual(true);
expect(scene.state.preload).toEqual(false);
expect(scene.state.version).toEqual(dash.schemaVersion);
expect(scene.state.tags).toEqual(dash.tags);

View File

@ -78,7 +78,7 @@ import { registerPanelInteractionsReporter } from './transformSaveModelToScene';
import {
transformCursorSyncV2ToV1,
transformSortVariableToEnumV1,
transformValueMappingsToV1,
transformMappingsToV1,
transformVariableHideToEnumV1,
transformVariableRefreshToEnumV1,
} from './transformToV1TypesUtils';
@ -233,7 +233,7 @@ function buildVizPanel(panel: PanelKind): VizPanel {
description: panel.spec.description,
pluginId: panel.spec.vizConfig.kind,
options: panel.spec.vizConfig.spec.options,
fieldConfig: transformValueMappingsToV1(panel.spec.vizConfig.spec.fieldConfig),
fieldConfig: transformMappingsToV1(panel.spec.vizConfig.spec.fieldConfig),
pluginVersion: panel.spec.vizConfig.spec.pluginVersion,
// FIXME: Transparent is not added to the schema yet
// displayMode: panel.spec.transparent ? 'transparent' : undefined,

View File

@ -8,7 +8,6 @@ import {
TransformationKind,
FieldConfigSource,
DashboardLink,
DashboardCursorSync,
DataTransformerConfig,
PanelQuerySpec,
DataQueryKind,
@ -34,7 +33,7 @@ import { dashboardSceneGraph } from '../utils/dashboardSceneGraph';
import { getQueryRunnerFor } from '../utils/utils';
import { sceneVariablesSetToSchemaV2Variables } from './sceneVariablesSetToVariables';
import { transformDashboardLinksToEnums, transformCursorSynctoEnum } from './transformToV2TypesUtils';
import { transformCursorSynctoEnum } from './transformToV2TypesUtils';
// FIXME: This is temporary to avoid creating partial types for all the new schema, it has some performance implications, but it's fine for now
type DeepPartial<T> = T extends object
@ -58,7 +57,7 @@ export function transformSceneToSaveModelSchemaV2(scene: DashboardScene, isSnaps
liveNow: getLiveNow(oldDash),
preload: oldDash.preload,
editable: oldDash.editable,
links: transformDashboardLinksToEnums(oldDash.links),
links: oldDash.links,
tags: oldDash.tags,
schemaVersion: DASHBOARD_SCHEMA_VERSION,
// EOF dashboard settings
@ -385,9 +384,6 @@ function isDashboardSchemaV2(dash: any): dash is DashboardV2Spec {
if (typeof dash.cursorSync !== 'string') {
return false;
}
if (!Object.values(DashboardCursorSync).includes(dash.cursorSync)) {
return false;
}
if (typeof dash.liveNow !== 'boolean') {
return false;
}

View File

@ -5,24 +5,26 @@ import {
VariableSort as VariableSortV1,
DashboardCursorSync as DashboardCursorSyncV1,
defaultDashboardCursorSync,
MappingType as MappingTypeV1,
ThresholdsMode as ThresholdsModeV1,
} from '@grafana/schema';
import {
DashboardCursorSync,
MappingType,
VariableHide,
VariableRefresh,
VariableSort,
FieldConfigSource,
SpecialValueMatch,
ThresholdsMode,
} from '@grafana/schema/dist/esm/schema/dashboard/v2alpha0/dashboard.gen';
export function transformVariableRefreshToEnumV1(refresh?: VariableRefresh): VariableRefreshV1 {
switch (refresh) {
case VariableRefresh.Never:
case 'never':
return VariableRefreshV1.never;
case VariableRefresh.OnDashboardLoad:
case 'onDashboardLoad':
return VariableRefreshV1.onDashboardLoad;
case VariableRefresh.OnTimeRangeChanged:
case 'onTimeRangeChanged':
return VariableRefreshV1.onTimeRangeChanged;
default:
return VariableRefreshV1.never;
@ -31,11 +33,11 @@ export function transformVariableRefreshToEnumV1(refresh?: VariableRefresh): Var
export function transformVariableHideToEnumV1(hide?: VariableHide): VariableHideV1 {
switch (hide) {
case VariableHide.DontHide:
case 'dontHide':
return VariableHideV1.dontHide;
case VariableHide.HideLabel:
case 'hideLabel':
return VariableHideV1.hideLabel;
case VariableHide.HideVariable:
case 'hideVariable':
return VariableHideV1.hideVariable;
default:
return VariableHideV1.dontHide;
@ -44,15 +46,23 @@ export function transformVariableHideToEnumV1(hide?: VariableHide): VariableHide
export function transformSortVariableToEnumV1(sort?: VariableSort): VariableSortV1 {
switch (sort) {
case VariableSort.Disabled:
case 'disabled':
return VariableSortV1.disabled;
case VariableSort.NumericalAsc:
case 'numericalAsc':
return VariableSortV1.numericalAsc;
case VariableSort.NumericalDesc:
case 'alphabeticalCaseInsensitiveAsc':
return VariableSortV1.alphabeticalCaseInsensitiveAsc;
case 'alphabeticalCaseInsensitiveDesc':
return VariableSortV1.alphabeticalCaseInsensitiveDesc;
case 'numericalDesc':
return VariableSortV1.numericalDesc;
case VariableSort.AlphabeticalAsc:
case 'naturalAsc':
return VariableSortV1.naturalAsc;
case 'naturalDesc':
return VariableSortV1.naturalDesc;
case 'alphabeticalAsc':
return VariableSortV1.alphabeticalAsc;
case VariableSort.AlphabeticalDesc:
case 'alphabeticalDesc':
return VariableSortV1.alphabeticalDesc;
default:
return VariableSortV1.disabled;
@ -61,11 +71,11 @@ export function transformSortVariableToEnumV1(sort?: VariableSort): VariableSort
export function transformCursorSyncV2ToV1(cursorSync: DashboardCursorSync): DashboardCursorSyncV1 {
switch (cursorSync) {
case DashboardCursorSync.Crosshair:
case 'Crosshair':
return DashboardCursorSyncV1.Crosshair;
case DashboardCursorSync.Tooltip:
case 'Tooltip':
return DashboardCursorSyncV1.Tooltip;
case DashboardCursorSync.Off:
case 'Off':
return DashboardCursorSyncV1.Off;
default:
return defaultDashboardCursorSync;
@ -74,24 +84,35 @@ export function transformCursorSyncV2ToV1(cursorSync: DashboardCursorSync): Dash
function transformSpecialValueMatchToV1(match: SpecialValueMatch): SpecialValueMatchV1 {
switch (match) {
case SpecialValueMatch.True:
case 'true':
return SpecialValueMatchV1.True;
case SpecialValueMatch.False:
case 'false':
return SpecialValueMatchV1.False;
case SpecialValueMatch.Null:
case 'null':
return SpecialValueMatchV1.Null;
case SpecialValueMatch.NotANumber:
case 'nan':
return SpecialValueMatchV1.NaN;
case SpecialValueMatch.NullAndNaN:
case 'null+nan':
return SpecialValueMatchV1.NullAndNaN;
case SpecialValueMatch.Empty:
case 'empty':
return SpecialValueMatchV1.Empty;
default:
throw new Error(`Unknown match type: ${match}`);
}
}
export function transformValueMappingsToV1(fieldConfig: FieldConfigSource): FieldConfigSourceV1 {
export function transformMappingsToV1(fieldConfig: FieldConfigSource): FieldConfigSourceV1 {
const getThresholdsMode = (mode: ThresholdsMode): ThresholdsModeV1 => {
switch (mode) {
case 'absolute':
return ThresholdsModeV1.Absolute;
case 'percentage':
return ThresholdsModeV1.Percentage;
default:
return ThresholdsModeV1.Absolute;
}
};
return {
...fieldConfig,
defaults: {
@ -101,17 +122,17 @@ export function transformValueMappingsToV1(fieldConfig: FieldConfigSource): Fiel
case 'value':
return {
...mapping,
type: MappingType.ValueToText,
type: MappingTypeV1.ValueToText,
};
case 'range':
return {
...mapping,
type: MappingType.RangeToText,
type: MappingTypeV1.RangeToText,
};
case 'regex':
return {
...mapping,
type: MappingType.RegexToText,
type: MappingTypeV1.RegexToText,
};
case 'special':
return {
@ -120,12 +141,16 @@ export function transformValueMappingsToV1(fieldConfig: FieldConfigSource): Fiel
...mapping.options,
match: transformSpecialValueMatchToV1(mapping.options.match),
},
type: MappingType.SpecialValue,
type: MappingTypeV1.SpecialValue,
};
default:
return mapping;
}
}),
thresholds: fieldConfig.defaults.thresholds && {
...fieldConfig.defaults.thresholds,
mode: getThresholdsMode(fieldConfig.defaults.thresholds.mode),
},
},
};
}

View File

@ -1,20 +1,12 @@
import { DashboardLink as DashboardLinkTypeV1 } from '@grafana/schema';
import {
DashboardCursorSync,
DashboardLinkType,
VariableRefresh,
VariableHide,
VariableSort,
defaultVariableHide,
defaultVariableSort,
defaultVariableRefresh,
defaultDashboardLinkType,
defaultDashboardCursorSync,
} from '@grafana/schema/dist/esm/schema/dashboard/v2alpha0/dashboard.gen';
import {
transformCursorSynctoEnum,
transformDashboardLinksToEnums,
transformVariableRefreshToEnum,
transformVariableHideToEnum,
transformSortVariableToEnum,
@ -23,86 +15,39 @@ import {
describe('transformToV2TypesUtils', () => {
describe('transformCursorSynctoEnum', () => {
it('should return the correct enum value for cursor sync', () => {
expect(transformCursorSynctoEnum(0)).toBe(DashboardCursorSync.Off);
expect(transformCursorSynctoEnum(1)).toBe(DashboardCursorSync.Crosshair);
expect(transformCursorSynctoEnum(2)).toBe(DashboardCursorSync.Tooltip);
expect(transformCursorSynctoEnum(0)).toBe('Off');
expect(transformCursorSynctoEnum(1)).toBe('Crosshair');
expect(transformCursorSynctoEnum(2)).toBe('Tooltip');
expect(transformCursorSynctoEnum(undefined)).toBe(defaultDashboardCursorSync());
});
});
describe('transformDashboardLinksToEnums', () => {
const links: DashboardLinkTypeV1[] = [
{
type: 'link',
asDropdown: false,
icon: '',
includeVars: false,
keepTime: false,
tags: [],
title: '',
url: '',
targetBlank: false,
tooltip: '',
},
{
type: 'dashboards',
asDropdown: false,
icon: '',
includeVars: false,
keepTime: false,
tags: [],
title: '',
url: '',
targetBlank: false,
tooltip: '',
},
{
// @ts-expect-error Testing invalid type
type: 'non-valid-type',
asDropdown: false,
icon: '',
includeVars: false,
keepTime: false,
tags: [],
title: '',
url: '',
targetBlank: false,
tooltip: '',
},
];
const transformedLinks = transformDashboardLinksToEnums(links);
expect(transformedLinks[0].type).toBe(DashboardLinkType.Link);
expect(transformedLinks[1].type).toBe(DashboardLinkType.Dashboards);
expect(transformedLinks[2].type).toBe(defaultDashboardLinkType());
});
});
describe('transformVariableRefreshToEnum', () => {
it('should return the correct enum value for variable refresh', () => {
expect(transformVariableRefreshToEnum(0)).toBe(VariableRefresh.Never);
expect(transformVariableRefreshToEnum(1)).toBe(VariableRefresh.OnDashboardLoad);
expect(transformVariableRefreshToEnum(2)).toBe(VariableRefresh.OnTimeRangeChanged);
expect(transformVariableRefreshToEnum(0)).toBe('never');
expect(transformVariableRefreshToEnum(1)).toBe('onDashboardLoad');
expect(transformVariableRefreshToEnum(2)).toBe('onTimeRangeChanged');
expect(transformVariableRefreshToEnum(undefined)).toBe(defaultVariableRefresh());
});
});
describe('transformVariableHideToEnum', () => {
it('should return the correct enum value for variable hide', () => {
expect(transformVariableHideToEnum(0)).toBe(VariableHide.DontHide);
expect(transformVariableHideToEnum(1)).toBe(VariableHide.HideLabel);
expect(transformVariableHideToEnum(2)).toBe(VariableHide.HideVariable);
expect(transformVariableHideToEnum(0)).toBe('dontHide');
expect(transformVariableHideToEnum(1)).toBe('hideLabel');
expect(transformVariableHideToEnum(2)).toBe('hideVariable');
expect(transformVariableHideToEnum(undefined)).toBe(defaultVariableHide());
});
});
describe('transformSortVariableToEnum', () => {
it('should return the correct enum value for variable sort', () => {
expect(transformSortVariableToEnum(0)).toBe(VariableSort.Disabled);
expect(transformSortVariableToEnum(1)).toBe(VariableSort.AlphabeticalAsc);
expect(transformSortVariableToEnum(2)).toBe(VariableSort.AlphabeticalDesc);
expect(transformSortVariableToEnum(3)).toBe(VariableSort.NumericalAsc);
expect(transformSortVariableToEnum(4)).toBe(VariableSort.NumericalDesc);
expect(transformSortVariableToEnum(0)).toBe('disabled');
expect(transformSortVariableToEnum(1)).toBe('alphabeticalAsc');
expect(transformSortVariableToEnum(2)).toBe('alphabeticalDesc');
expect(transformSortVariableToEnum(3)).toBe('numericalAsc');
expect(transformSortVariableToEnum(4)).toBe('numericalDesc');
expect(transformSortVariableToEnum(undefined)).toBe(defaultVariableSort());
});
});

View File

@ -1,65 +1,41 @@
import {
DashboardLink as DashboardLinkV1,
VariableHide as VariableHideV1,
VariableRefresh as VariableRefreshV1,
VariableSort as VariableSortV1,
DashboardCursorSync as DashboardCursorSyncV1,
DashboardLinkType as DashboardLinkTypeV1,
} from '@grafana/schema';
import {
DashboardCursorSync,
defaultDashboardV2Spec,
DashboardLinkType,
DashboardLink,
defaultVariableHide,
defaultVariableRefresh,
defaultVariableSort,
VariableHide,
VariableRefresh,
VariableSort,
defaultDashboardLinkType,
} from '@grafana/schema/dist/esm/schema/dashboard/v2alpha0/dashboard.gen';
export function transformCursorSynctoEnum(cursorSync?: DashboardCursorSyncV1): DashboardCursorSync {
switch (cursorSync) {
case 0:
return DashboardCursorSync.Off;
return 'Off';
case 1:
return DashboardCursorSync.Crosshair;
return 'Crosshair';
case 2:
return DashboardCursorSync.Tooltip;
return 'Tooltip';
default:
return defaultDashboardV2Spec().cursorSync;
}
}
function transformDashboardLinkTypeToEnum(linkType: DashboardLinkTypeV1): DashboardLinkType {
switch (linkType) {
case 'link':
return DashboardLinkType.Link;
case 'dashboards':
return DashboardLinkType.Dashboards;
default:
return defaultDashboardLinkType();
}
}
export function transformDashboardLinksToEnums(links: DashboardLinkV1[]): DashboardLink[] {
return links.map((link) => {
return {
...link,
type: transformDashboardLinkTypeToEnum(link.type),
};
});
}
export function transformVariableRefreshToEnum(refresh?: VariableRefreshV1): VariableRefresh {
switch (refresh) {
case 0:
return VariableRefresh.Never;
return 'never';
case 1:
return VariableRefresh.OnDashboardLoad;
return 'onDashboardLoad';
case 2:
return VariableRefresh.OnTimeRangeChanged;
return 'onTimeRangeChanged';
default:
return defaultVariableRefresh();
}
@ -67,11 +43,11 @@ export function transformVariableRefreshToEnum(refresh?: VariableRefreshV1): Var
export function transformVariableHideToEnum(hide?: VariableHideV1): VariableHide {
switch (hide) {
case 0:
return VariableHide.DontHide;
return 'dontHide';
case 1:
return VariableHide.HideLabel;
return 'hideLabel';
case 2:
return VariableHide.HideVariable;
return 'hideVariable';
default:
return defaultVariableHide();
}
@ -79,15 +55,15 @@ export function transformVariableHideToEnum(hide?: VariableHideV1): VariableHide
export function transformSortVariableToEnum(sort?: VariableSortV1): VariableSort {
switch (sort) {
case 0:
return VariableSort.Disabled;
return 'disabled';
case 1:
return VariableSort.AlphabeticalAsc;
return 'alphabeticalAsc';
case 2:
return VariableSort.AlphabeticalDesc;
return 'alphabeticalDesc';
case 3:
return VariableSort.NumericalAsc;
return 'numericalAsc';
case 4:
return VariableSort.NumericalDesc;
return 'numericalDesc';
default:
return defaultVariableSort();
}