mirror of
https://github.com/grafana/grafana.git
synced 2026-07-03 03:37:53 +00:00
Chore: Remove remaining ptr constructor helper functions (#124553)
This commit is contained in:
parent
658b26b1ef
commit
7622538db5
138 changed files with 1163 additions and 1123 deletions
|
|
@ -7,6 +7,7 @@ tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint
|
|||
require (
|
||||
4d63.com/gocheckcompilerdirectives v1.3.0 // indirect
|
||||
4d63.com/gochecknoglobals v0.2.2 // indirect
|
||||
charm.land/lipgloss/v2 v2.0.3 // indirect
|
||||
codeberg.org/chavacava/garif v0.2.0 // indirect
|
||||
codeberg.org/polyfloyd/go-errorlint v1.9.0 // indirect
|
||||
dev.gaijin.team/go/exhaustruct/v4 v4.0.0 // indirect
|
||||
|
|
@ -19,47 +20,53 @@ require (
|
|||
github.com/Antonboom/nilnil v1.1.1 // indirect
|
||||
github.com/Antonboom/testifylint v1.6.4 // indirect
|
||||
github.com/BurntSushi/toml v1.6.0 // indirect
|
||||
github.com/ClickHouse/clickhouse-go-linter v1.2.0 // indirect
|
||||
github.com/Djarvur/go-err113 v0.1.1 // indirect
|
||||
github.com/Masterminds/semver/v3 v3.4.0 // indirect
|
||||
github.com/MirrexOne/unqueryvet v1.5.3 // indirect
|
||||
github.com/Masterminds/semver/v3 v3.5.0 // indirect
|
||||
github.com/MirrexOne/unqueryvet v1.5.4 // indirect
|
||||
github.com/OpenPeeDeeP/depguard/v2 v2.2.1 // indirect
|
||||
github.com/alecthomas/chroma/v2 v2.23.1 // indirect
|
||||
github.com/alecthomas/chroma/v2 v2.24.1 // indirect
|
||||
github.com/alecthomas/go-check-sumtype v0.3.1 // indirect
|
||||
github.com/alexkohler/nakedret/v2 v2.0.6 // indirect
|
||||
github.com/alexkohler/prealloc v1.0.2 // indirect
|
||||
github.com/alexkohler/prealloc v1.1.0 // indirect
|
||||
github.com/alfatraining/structtag v1.0.0 // indirect
|
||||
github.com/alingse/asasalint v0.0.11 // indirect
|
||||
github.com/alingse/nilnesserr v0.2.0 // indirect
|
||||
github.com/ashanbrown/forbidigo/v2 v2.3.0 // indirect
|
||||
github.com/ashanbrown/makezero/v2 v2.1.0 // indirect
|
||||
github.com/ashanbrown/forbidigo/v2 v2.3.1 // indirect
|
||||
github.com/ashanbrown/makezero/v2 v2.2.1 // indirect
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bkielbasa/cyclop v1.2.3 // indirect
|
||||
github.com/blizzy78/varnamelen v0.8.0 // indirect
|
||||
github.com/bombsimon/wsl/v4 v4.7.0 // indirect
|
||||
github.com/bombsimon/wsl/v5 v5.6.0 // indirect
|
||||
github.com/bombsimon/wsl/v5 v5.8.0 // indirect
|
||||
github.com/breml/bidichk v0.3.3 // indirect
|
||||
github.com/breml/errchkjson v0.4.1 // indirect
|
||||
github.com/butuzov/ireturn v0.4.0 // indirect
|
||||
github.com/butuzov/ireturn v0.4.1 // indirect
|
||||
github.com/butuzov/mirror v1.3.0 // indirect
|
||||
github.com/catenacyber/perfsprint v0.10.1 // indirect
|
||||
github.com/ccojocar/zxcvbn-go v1.0.4 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/charithe/durationcheck v0.0.11 // indirect
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
|
||||
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
||||
github.com/charmbracelet/lipgloss v1.1.0 // indirect
|
||||
github.com/charmbracelet/x/ansi v0.10.1 // indirect
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251205161215-1948445e3318 // indirect
|
||||
github.com/charmbracelet/x/ansi v0.11.7 // indirect
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
|
||||
github.com/charmbracelet/x/term v0.2.1 // indirect
|
||||
github.com/charmbracelet/x/term v0.2.2 // indirect
|
||||
github.com/charmbracelet/x/termios v0.1.1 // indirect
|
||||
github.com/charmbracelet/x/windows v0.2.2 // indirect
|
||||
github.com/ckaznocha/intrange v0.3.1 // indirect
|
||||
github.com/clipperhouse/displaywidth v0.11.0 // indirect
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
|
||||
github.com/curioswitch/go-reassign v0.3.0 // indirect
|
||||
github.com/daixiang0/gci v0.13.7 // indirect
|
||||
github.com/dave/dst v0.27.3 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/denis-tingaikin/go-header v0.5.0 // indirect
|
||||
github.com/dlclark/regexp2 v1.11.5 // indirect
|
||||
github.com/dlclark/regexp2 v1.12.0 // indirect
|
||||
github.com/ettle/strcase v0.2.0 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/fatih/color v1.19.0 // indirect
|
||||
github.com/fatih/structtag v1.2.0 // indirect
|
||||
github.com/firefart/nonamedreturns v1.0.6 // indirect
|
||||
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
||||
|
|
@ -76,18 +83,19 @@ require (
|
|||
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
|
||||
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/godoc-lint/godoc-lint v0.11.1 // indirect
|
||||
github.com/godoc-lint/godoc-lint v0.11.2 // indirect
|
||||
github.com/gofrs/flock v0.13.0 // indirect
|
||||
github.com/golangci/asciicheck v0.5.0 // indirect
|
||||
github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 // indirect
|
||||
github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202 // indirect
|
||||
github.com/golangci/go-printf-func-name v0.1.1 // indirect
|
||||
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
|
||||
github.com/golangci/golangci-lint/v2 v2.9.0 // indirect
|
||||
github.com/golangci/golangci-lint/v2 v2.12.2 // indirect
|
||||
github.com/golangci/golines v0.15.0 // indirect
|
||||
github.com/golangci/misspell v0.8.0 // indirect
|
||||
github.com/golangci/nilerr v0.0.0-20250918000102-015671e622fe // indirect
|
||||
github.com/golangci/plugin-module-register v0.1.2 // indirect
|
||||
github.com/golangci/revgrep v0.8.0 // indirect
|
||||
github.com/golangci/rowserrcheck v0.0.0-20260419091836-c5f79b8a11ba // indirect
|
||||
github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e // indirect
|
||||
github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e // indirect
|
||||
github.com/google/go-cmp v0.7.0 // indirect
|
||||
|
|
@ -97,16 +105,16 @@ require (
|
|||
github.com/gostaticanalysis/forcetypeassert v0.2.0 // indirect
|
||||
github.com/gostaticanalysis/nilerr v0.1.2 // indirect
|
||||
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
|
||||
github.com/hashicorp/go-version v1.8.0 // indirect
|
||||
github.com/hashicorp/go-version v1.9.0 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/hexops/gotextdiff v1.0.3 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jgautheron/goconst v1.8.2 // indirect
|
||||
github.com/jgautheron/goconst v1.10.0 // indirect
|
||||
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
|
||||
github.com/jjti/go-spancheck v0.6.5 // indirect
|
||||
github.com/julz/importas v0.2.0 // indirect
|
||||
github.com/karamaru-alpha/copyloopvar v1.2.2 // indirect
|
||||
github.com/kisielk/errcheck v1.9.0 // indirect
|
||||
github.com/kisielk/errcheck v1.10.0 // indirect
|
||||
github.com/kkHAIKE/contextcheck v1.1.6 // indirect
|
||||
github.com/kulti/thelper v0.7.1 // indirect
|
||||
github.com/kunwardeep/paralleltest v1.0.15 // indirect
|
||||
|
|
@ -118,27 +126,28 @@ require (
|
|||
github.com/ldez/tagliatelle v0.7.2 // indirect
|
||||
github.com/ldez/usetesting v0.5.0 // indirect
|
||||
github.com/leonklingele/grouper v1.1.2 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.4.0 // indirect
|
||||
github.com/macabu/inamedparam v0.2.0 // indirect
|
||||
github.com/manuelarte/embeddedstructfieldcheck v0.4.0 // indirect
|
||||
github.com/manuelarte/funcorder v0.5.0 // indirect
|
||||
github.com/manuelarte/funcorder v0.6.0 // indirect
|
||||
github.com/maratori/testableexamples v1.0.1 // indirect
|
||||
github.com/maratori/testpackage v1.1.2 // indirect
|
||||
github.com/matoous/godox v1.1.0 // indirect
|
||||
github.com/matryer/is v1.4.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/mgechev/revive v1.14.0 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.23 // indirect
|
||||
github.com/mgechev/revive v1.15.0 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/moricho/tparallel v0.3.2 // indirect
|
||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||
github.com/muesli/termenv v0.16.0 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/nakabonne/nestif v0.3.1 // indirect
|
||||
github.com/nishanths/exhaustive v0.12.0 // indirect
|
||||
github.com/nishanths/predeclared v0.2.2 // indirect
|
||||
github.com/nunnatsa/ginkgolinter v0.22.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/nunnatsa/ginkgolinter v0.23.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.3.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/polyfloyd/go-errorlint v1.8.0 // indirect
|
||||
github.com/prometheus/client_golang v1.22.0 // indirect
|
||||
|
|
@ -154,19 +163,20 @@ require (
|
|||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||
github.com/ryancurrah/gomodguard v1.4.1 // indirect
|
||||
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
|
||||
github.com/ryancurrah/gomodguard/v2 v2.1.3 // indirect
|
||||
github.com/ryanrolds/sqlclosecheck v0.6.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
||||
github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect
|
||||
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
|
||||
github.com/sashamelentyev/usestdlibvars v1.29.0 // indirect
|
||||
github.com/securego/gosec/v2 v2.22.11 // indirect
|
||||
github.com/securego/gosec/v2 v2.26.1 // indirect
|
||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
|
||||
github.com/sirupsen/logrus v1.9.4 // indirect
|
||||
github.com/sivchari/containedctx v1.0.3 // indirect
|
||||
github.com/sonatard/noctx v0.4.0 // indirect
|
||||
github.com/sonatard/noctx v0.5.1 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/sourcegraph/go-diff v0.7.0 // indirect
|
||||
github.com/sourcegraph/go-diff v0.8.0 // indirect
|
||||
github.com/spf13/afero v1.15.0 // indirect
|
||||
github.com/spf13/cast v1.7.1 // indirect
|
||||
github.com/spf13/cobra v1.10.2 // indirect
|
||||
|
|
@ -177,15 +187,15 @@ require (
|
|||
github.com/stretchr/objx v0.5.2 // indirect
|
||||
github.com/stretchr/testify v1.11.1 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/tetafro/godot v1.5.4 // indirect
|
||||
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 // indirect
|
||||
github.com/tetafro/godot v1.5.6 // indirect
|
||||
github.com/timakin/bodyclose v0.0.0-20260129054331-73d1f95b84b4 // indirect
|
||||
github.com/timonwong/loggercheck v0.11.0 // indirect
|
||||
github.com/tomarrell/wrapcheck/v2 v2.12.0 // indirect
|
||||
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
|
||||
github.com/ultraware/funlen v0.2.0 // indirect
|
||||
github.com/ultraware/whitespace v0.2.0 // indirect
|
||||
github.com/uudashr/gocognit v1.2.0 // indirect
|
||||
github.com/uudashr/iface v1.4.1 // indirect
|
||||
github.com/uudashr/gocognit v1.2.1 // indirect
|
||||
github.com/uudashr/iface v1.4.2 // indirect
|
||||
github.com/xen0n/gosmopolitan v1.3.0 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
github.com/yagipy/maintidx v1.0.0 // indirect
|
||||
|
|
@ -193,7 +203,7 @@ require (
|
|||
github.com/ykadowak/zerologlint v0.1.5 // indirect
|
||||
gitlab.com/bosi/decorder v0.4.2 // indirect
|
||||
go-simpler.org/musttag v0.14.0 // indirect
|
||||
go-simpler.org/sloglint v0.11.1 // indirect
|
||||
go-simpler.org/sloglint v0.12.0 // indirect
|
||||
go.augendre.info/arangolint v0.4.0 // indirect
|
||||
go.augendre.info/fatcontext v0.9.0 // indirect
|
||||
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||
|
|
@ -201,16 +211,16 @@ require (
|
|||
go.uber.org/zap v1.27.0 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
|
||||
golang.org/x/exp/typeparams v0.0.0-20251125195548-87e1e737ad39 // indirect
|
||||
golang.org/x/mod v0.33.0 // indirect
|
||||
golang.org/x/net v0.50.0 // indirect
|
||||
golang.org/x/sync v0.19.0 // indirect
|
||||
golang.org/x/sys v0.41.0 // indirect
|
||||
golang.org/x/text v0.34.0 // indirect
|
||||
golang.org/x/tools v0.42.0 // indirect
|
||||
google.golang.org/protobuf v1.36.8 // indirect
|
||||
golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 // indirect
|
||||
golang.org/x/mod v0.35.0 // indirect
|
||||
golang.org/x/net v0.53.0 // indirect
|
||||
golang.org/x/sync v0.20.0 // indirect
|
||||
golang.org/x/sys v0.43.0 // indirect
|
||||
golang.org/x/text v0.36.0 // indirect
|
||||
golang.org/x/tools v0.44.0 // indirect
|
||||
google.golang.org/protobuf v1.36.10 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
honnef.co/go/tools v0.6.1 // indirect
|
||||
honnef.co/go/tools v0.7.0 // indirect
|
||||
mvdan.cc/gofumpt v0.9.2 // indirect
|
||||
mvdan.cc/unparam v0.0.0-20251027182757-5beb8c8f8f15 // indirect
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
4d63.com/gocheckcompilerdirectives v1.3.0/go.mod h1:ofsJ4zx2QAuIP/NO/NAh1ig6R1Fb18/GI7RVMwz7kAY=
|
||||
4d63.com/gochecknoglobals v0.2.2 h1:H1vdnwnMaZdQW/N+NrkT1SZMTBmcwHe9Vq8lJcYYTtU=
|
||||
4d63.com/gochecknoglobals v0.2.2/go.mod h1:lLxwTQjL5eIesRbvnzIP3jZtG140FnTdz+AlMa+ogt0=
|
||||
charm.land/lipgloss/v2 v2.0.3 h1:yM2zJ4Cf5Y51b7RHIwioil4ApI/aypFXXVHSwlM6RzU=
|
||||
charm.land/lipgloss/v2 v2.0.3/go.mod h1:7myLU9iG/3xluAWzpY/fSxYYHCgoKTie7laxk6ATwXA=
|
||||
codeberg.org/chavacava/garif v0.2.0 h1:F0tVjhYbuOCnvNcU3YSpO6b3Waw6Bimy4K0mM8y6MfY=
|
||||
codeberg.org/chavacava/garif v0.2.0/go.mod h1:P2BPbVbT4QcvLZrORc2T29szK3xEOlnl0GiPTJmEqBQ=
|
||||
codeberg.org/polyfloyd/go-errorlint v1.9.0 h1:VkdEEmA1VBpH6ecQoMR4LdphVI3fA4RrCh2an7YmodI=
|
||||
|
|
@ -30,16 +32,22 @@ github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg
|
|||
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
||||
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/ClickHouse/clickhouse-go-linter v1.2.0 h1:zbm174up3hTKjp0wKZVnTzRiG7tSF5XZF0FJG/MuCBI=
|
||||
github.com/ClickHouse/clickhouse-go-linter v1.2.0/go.mod h1:pLorS7ffPTfuUV9M0SJgfHA/h/WQPQUk2FWG9x74cQ4=
|
||||
github.com/Djarvur/go-err113 v0.1.1 h1:eHfopDqXRwAi+YmCUas75ZE0+hoBHJ2GQNLYRSxao4g=
|
||||
github.com/Djarvur/go-err113 v0.1.1/go.mod h1:IaWJdYFLg76t2ihfflPZnM1LIQszWOsFDh2hhhAVF6k=
|
||||
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
|
||||
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
|
||||
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||
github.com/Masterminds/semver/v3 v3.5.0 h1:kQceYJfbupGfZOKZQg0kou0DgAKhzDg2NZPAwZ/2OOE=
|
||||
github.com/Masterminds/semver/v3 v3.5.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||
github.com/MirrexOne/unqueryvet v1.2.1 h1:M+zdXMq84g+E1YOLa7g7ExN3dWfZQrdDSTCM7gC+m/A=
|
||||
github.com/MirrexOne/unqueryvet v1.2.1/go.mod h1:IWwCwMQlSWjAIteW0t+28Q5vouyktfujzYznSIWiuOg=
|
||||
github.com/MirrexOne/unqueryvet v1.5.3 h1:LpT3rsH+IY3cQddWF9bg4C7jsbASdGnrOSofY8IPEiw=
|
||||
github.com/MirrexOne/unqueryvet v1.5.3/go.mod h1:fs9Zq6eh1LRIhsDIsxf9PONVUjYdFHdtkHIgZdJnyPU=
|
||||
github.com/MirrexOne/unqueryvet v1.5.4 h1:38QOxShO7JmMWT+eCdDMbcUgGCOeJphVkzzRgyLJgsQ=
|
||||
github.com/MirrexOne/unqueryvet v1.5.4/go.mod h1:fs9Zq6eh1LRIhsDIsxf9PONVUjYdFHdtkHIgZdJnyPU=
|
||||
github.com/OpenPeeDeeP/depguard/v2 v2.2.1 h1:vckeWVESWp6Qog7UZSARNqfu/cZqvki8zsuj3piCMx4=
|
||||
github.com/OpenPeeDeeP/depguard/v2 v2.2.1/go.mod h1:q4DKzC4UcVaAvcfd41CZh0PWpGgzrVxUYBlgKNGquUo=
|
||||
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
|
||||
|
|
@ -48,6 +56,8 @@ github.com/alecthomas/chroma/v2 v2.20.0 h1:sfIHpxPyR07/Oylvmcai3X/exDlE8+FA820NT
|
|||
github.com/alecthomas/chroma/v2 v2.20.0/go.mod h1:e7tViK0xh/Nf4BYHl00ycY6rV7b8iXBksI9E359yNmA=
|
||||
github.com/alecthomas/chroma/v2 v2.23.1 h1:nv2AVZdTyClGbVQkIzlDm/rnhk1E9bU9nXwmZ/Vk/iY=
|
||||
github.com/alecthomas/chroma/v2 v2.23.1/go.mod h1:NqVhfBR0lte5Ouh3DcthuUCTUpDC9cxBOfyMbMQPs3o=
|
||||
github.com/alecthomas/chroma/v2 v2.24.1 h1:m5ffpfZbIb++k8AqFEKy9uVgY12xIQtBsQlc6DfZJQM=
|
||||
github.com/alecthomas/chroma/v2 v2.24.1/go.mod h1:l+ohZ9xRXIbGe7cIW+YZgOGbvuVLjMps/FYN/CwuabI=
|
||||
github.com/alecthomas/go-check-sumtype v0.3.1 h1:u9aUvbGINJxLVXiFvHUlPEaD7VDULsrxJb4Aq31NLkU=
|
||||
github.com/alecthomas/go-check-sumtype v0.3.1/go.mod h1:A8TSiN3UPRw3laIgWEUOHHLPa6/r9MtoigdlP5h3K/E=
|
||||
github.com/alecthomas/repr v0.5.1 h1:E3G4t2QbHTSNpPKBgMTln5KLkZHLOcU7r37J4pXBuIg=
|
||||
|
|
@ -59,6 +69,8 @@ github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pO
|
|||
github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE=
|
||||
github.com/alexkohler/prealloc v1.0.2 h1:MPo8cIkGkZytq7WNH9UHv3DIX1mPz1RatPXnZb0zHWQ=
|
||||
github.com/alexkohler/prealloc v1.0.2/go.mod h1:fT39Jge3bQrfA7nPMDngUfvUbQGQeJyGQnR+913SCig=
|
||||
github.com/alexkohler/prealloc v1.1.0 h1:cKGRBqlXw5iyQGLYhrXrDlcHxugXpTq4tQ5c91wkf8M=
|
||||
github.com/alexkohler/prealloc v1.1.0/go.mod h1:fT39Jge3bQrfA7nPMDngUfvUbQGQeJyGQnR+913SCig=
|
||||
github.com/alfatraining/structtag v1.0.0 h1:2qmcUqNcCoyVJ0up879K614L9PazjBSFruTB0GOFjCc=
|
||||
github.com/alfatraining/structtag v1.0.0/go.mod h1:p3Xi5SwzTi+Ryj64DqjLWz7XurHxbGsq6y3ubePJPus=
|
||||
github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw=
|
||||
|
|
@ -69,10 +81,14 @@ github.com/ashanbrown/forbidigo/v2 v2.1.0 h1:NAxZrWqNUQiDz19FKScQ/xvwzmij6BiOw3S
|
|||
github.com/ashanbrown/forbidigo/v2 v2.1.0/go.mod h1:0zZfdNAuZIL7rSComLGthgc/9/n2FqspBOH90xlCHdA=
|
||||
github.com/ashanbrown/forbidigo/v2 v2.3.0 h1:OZZDOchCgsX5gvToVtEBoV2UWbFfI6RKQTir2UZzSxo=
|
||||
github.com/ashanbrown/forbidigo/v2 v2.3.0/go.mod h1:5p6VmsG5/1xx3E785W9fouMxIOkvY2rRV9nMdWadd6c=
|
||||
github.com/ashanbrown/forbidigo/v2 v2.3.1 h1:KAZijvQ7zeIBKbhikT4jCm0TLYXC4u78bTiLh/8JROI=
|
||||
github.com/ashanbrown/forbidigo/v2 v2.3.1/go.mod h1:2QDkLTzU6TV937eFROamXrW92M3paehdae4HCDCOZCM=
|
||||
github.com/ashanbrown/makezero/v2 v2.0.1 h1:r8GtKetWOgoJ4sLyUx97UTwyt2dO7WkGFHizn/Lo8TY=
|
||||
github.com/ashanbrown/makezero/v2 v2.0.1/go.mod h1:kKU4IMxmYW1M4fiEHMb2vc5SFoPzXvgbMR9gIp5pjSw=
|
||||
github.com/ashanbrown/makezero/v2 v2.1.0 h1:snuKYMbqosNokUKm+R6/+vOPs8yVAi46La7Ck6QYSaE=
|
||||
github.com/ashanbrown/makezero/v2 v2.1.0/go.mod h1:aEGT/9q3S8DHeE57C88z2a6xydvgx8J5hgXIGWgo0MY=
|
||||
github.com/ashanbrown/makezero/v2 v2.2.1 h1:A7uU8dgB1PA9aelTxHMfHIQ8Qev8AB3JLxJUBUsejqM=
|
||||
github.com/ashanbrown/makezero/v2 v2.2.1/go.mod h1:aEGT/9q3S8DHeE57C88z2a6xydvgx8J5hgXIGWgo0MY=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
|
|
@ -87,12 +103,16 @@ github.com/bombsimon/wsl/v5 v5.2.0 h1:PyCCwd3Q7abGs3e34IW4jLYlBS+FbsU6iK+Tb3NnDp
|
|||
github.com/bombsimon/wsl/v5 v5.2.0/go.mod h1:Gp8lD04z27wm3FANIUPZycXp+8huVsn0oxc+n4qfV9I=
|
||||
github.com/bombsimon/wsl/v5 v5.6.0 h1:4z+/sBqC5vUmSp1O0mS+czxwH9+LKXtCWtHH9rZGQL8=
|
||||
github.com/bombsimon/wsl/v5 v5.6.0/go.mod h1:Uqt2EfrMj2NV8UGoN1f1Y3m0NpUVCsUdrNCdet+8LvU=
|
||||
github.com/bombsimon/wsl/v5 v5.8.0 h1:JTkyfs4yl8SPejrCF2GdABXE+mO1WvM7iUYzRWlsxDs=
|
||||
github.com/bombsimon/wsl/v5 v5.8.0/go.mod h1:AbOLsulgkqP4ZnitHf9gwPtCOGlrzkk0jb0uNxRSY0o=
|
||||
github.com/breml/bidichk v0.3.3 h1:WSM67ztRusf1sMoqH6/c4OBCUlRVTKq+CbSeo0R17sE=
|
||||
github.com/breml/bidichk v0.3.3/go.mod h1:ISbsut8OnjB367j5NseXEGGgO/th206dVa427kR8YTE=
|
||||
github.com/breml/errchkjson v0.4.1 h1:keFSS8D7A2T0haP9kzZTi7o26r7kE3vymjZNeNDRDwg=
|
||||
github.com/breml/errchkjson v0.4.1/go.mod h1:a23OvR6Qvcl7DG/Z4o0el6BRAjKnaReoPQFciAl9U3s=
|
||||
github.com/butuzov/ireturn v0.4.0 h1:+s76bF/PfeKEdbG8b54aCocxXmi0wvYdOVsWxVO7n8E=
|
||||
github.com/butuzov/ireturn v0.4.0/go.mod h1:ghI0FrCmap8pDWZwfPisFD1vEc56VKH4NpQUxDHta70=
|
||||
github.com/butuzov/ireturn v0.4.1 h1:vWb3NO4t77iku/sjCQ/2pHTQeOmxEhjIriJqRLg1Y+I=
|
||||
github.com/butuzov/ireturn v0.4.1/go.mod h1:q+DXKzTDV5guNuXLnIab9fKXizTn2miZHLhxH7V/GB4=
|
||||
github.com/butuzov/mirror v1.3.0 h1:HdWCXzmwlQHdVhwvsfBb2Au0r3HyINry3bDWLYXiKoc=
|
||||
github.com/butuzov/mirror v1.3.0/go.mod h1:AEij0Z8YMALaq4yQj9CPPVYOyJQyiexpQEQgihajRfI=
|
||||
github.com/catenacyber/perfsprint v0.9.1 h1:5LlTp4RwTooQjJCvGEFV6XksZvWE7wCOUvjD2z0vls0=
|
||||
|
|
@ -109,18 +129,34 @@ github.com/charithe/durationcheck v0.0.11 h1:g1/EX1eIiKS57NTWsYtHDZ/APfeXKhye1Di
|
|||
github.com/charithe/durationcheck v0.0.11/go.mod h1:x5iZaixRNl8ctbM+3B2RrPG5t856TxRyVQEnbIEM2X4=
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
|
||||
github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q=
|
||||
github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q=
|
||||
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
|
||||
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251205161215-1948445e3318 h1:OqDqxQZliC7C8adA7KjelW3OjtAxREfeHkNcd66wpeI=
|
||||
github.com/charmbracelet/ultraviolet v0.0.0-20251205161215-1948445e3318/go.mod h1:Y6kE2GzHfkyQQVCSL9r2hwokSrIlHGzZG+71+wDYSZI=
|
||||
github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE=
|
||||
github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q=
|
||||
github.com/charmbracelet/x/ansi v0.10.1 h1:rL3Koar5XvX0pHGfovN03f5cxLbCF2YvLeyz7D2jVDQ=
|
||||
github.com/charmbracelet/x/ansi v0.10.1/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
|
||||
github.com/charmbracelet/x/ansi v0.11.7 h1:kzv1kJvjg2S3r9KHo8hDdHFQLEqn4RBCb39dAYC84jI=
|
||||
github.com/charmbracelet/x/ansi v0.11.7/go.mod h1:9qGpnAVYz+8ACONkZBUWPtL7lulP9No6p1epAihUZwQ=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
|
||||
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
|
||||
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
|
||||
github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
|
||||
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
|
||||
github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
|
||||
github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
|
||||
github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM=
|
||||
github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=
|
||||
github.com/ckaznocha/intrange v0.3.1 h1:j1onQyXvHUsPWujDH6WIjhyH26gkRt/txNlV7LspvJs=
|
||||
github.com/ckaznocha/intrange v0.3.1/go.mod h1:QVepyz1AkUoFQkpEqksSYpNpUo3c5W7nWh/s6SHIJJk=
|
||||
github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=
|
||||
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
github.com/curioswitch/go-reassign v0.3.0 h1:dh3kpQHuADL3cobV/sSGETA8DOv457dwl+fbBAhrQPs=
|
||||
github.com/curioswitch/go-reassign v0.3.0/go.mod h1:nApPCCTtqLJN/s8HfItCcKV0jIPwluBOvZP+dsJGA88=
|
||||
|
|
@ -138,10 +174,14 @@ github.com/denis-tingaikin/go-header v0.5.0 h1:SRdnP5ZKvcO9KKRP1KJrhFR3RrlGuD+42
|
|||
github.com/denis-tingaikin/go-header v0.5.0/go.mod h1:mMenU5bWrok6Wl2UsZjy+1okegmwQ3UgWl4V1D8gjlY=
|
||||
github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
|
||||
github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/dlclark/regexp2 v1.12.0 h1:0j4c5qQmnC6XOWNjP3PIXURXN2gWx76rd3KvgdPkCz8=
|
||||
github.com/dlclark/regexp2 v1.12.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q=
|
||||
github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A=
|
||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||
github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w=
|
||||
github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE=
|
||||
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
|
||||
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
|
||||
github.com/firefart/nonamedreturns v1.0.6 h1:vmiBcKV/3EqKY3ZiPxCINmpS431OcE1S47AQUwhrg8E=
|
||||
|
|
@ -197,6 +237,8 @@ github.com/godoc-lint/godoc-lint v0.10.0 h1:OcyrziBi18sQSEpib6NesVHEJ/Xcng97Nune
|
|||
github.com/godoc-lint/godoc-lint v0.10.0/go.mod h1:KleLcHu/CGSvkjUH2RvZyoK1MBC7pDQg4NxMYLcBBsw=
|
||||
github.com/godoc-lint/godoc-lint v0.11.1 h1:z9as8Qjiy6miRIa3VRymTa+Gt2RLnGICVikcvlUVOaA=
|
||||
github.com/godoc-lint/godoc-lint v0.11.1/go.mod h1:BAqayheFSuZrEAqCRxgw9MyvsM+S/hZwJbU1s/ejRj8=
|
||||
github.com/godoc-lint/godoc-lint v0.11.2 h1:Bp0FkJWoSdNsBikdNgIcgtaoo+xz6I/Y9s5WSBQUeeM=
|
||||
github.com/godoc-lint/godoc-lint v0.11.2/go.mod h1:iVpGdL1JCikNH2gGeAn3Hh+AgN5Gx/I/cxV+91L41jo=
|
||||
github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E=
|
||||
github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0=
|
||||
github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw=
|
||||
|
|
@ -205,6 +247,8 @@ github.com/golangci/asciicheck v0.5.0 h1:jczN/BorERZwK8oiFBOGvlGPknhvq0bjnysTj4n
|
|||
github.com/golangci/asciicheck v0.5.0/go.mod h1:5RMNAInbNFw2krqN6ibBxN/zfRFa9S6tA1nPdM0l8qQ=
|
||||
github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 h1:WUvBfQL6EW/40l6OmeSBYQJNSif4O11+bmWEz+C7FYw=
|
||||
github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32/go.mod h1:NUw9Zr2Sy7+HxzdjIULge71wI6yEg1lWQr7Evcu8K0E=
|
||||
github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202 h1:CbTB8KpqnViI6lIXxp03Oclc4VFHi3K4BWC1TacsZ+A=
|
||||
github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202/go.mod h1:NUw9Zr2Sy7+HxzdjIULge71wI6yEg1lWQr7Evcu8K0E=
|
||||
github.com/golangci/go-printf-func-name v0.1.1 h1:hIYTFJqAGp1iwoIfsNTpoq1xZAarogrvjO9AfiW3B4U=
|
||||
github.com/golangci/go-printf-func-name v0.1.1/go.mod h1:Es64MpWEZbh0UBtTAICOZiB+miW53w/K9Or/4QogJss=
|
||||
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d h1:viFft9sS/dxoYY0aiOTsLKO2aZQAPT4nlQCsimGcSGE=
|
||||
|
|
@ -213,6 +257,8 @@ github.com/golangci/golangci-lint/v2 v2.5.0 h1:BDRg4ASm4J1y/DSRY6zwJ5tr5Yy8ZqbZ7
|
|||
github.com/golangci/golangci-lint/v2 v2.5.0/go.mod h1:IJtWJBZkLbx7AVrIUzLd8Oi3ADtwaNpWbR3wthVWHcc=
|
||||
github.com/golangci/golangci-lint/v2 v2.9.0 h1:x5RRwa/jpNEjOnbSQSTam47QBsB50NMzCCUKe4GY/0U=
|
||||
github.com/golangci/golangci-lint/v2 v2.9.0/go.mod h1:gAPaJitu6HsyiuwJYO+WtKT9WmCpQZHR+gkXlCw1bRY=
|
||||
github.com/golangci/golangci-lint/v2 v2.12.2 h1:7+d1uY0bq1MU2UV3R5pW5Q7QWdcoq4naMRXM+gsJKrs=
|
||||
github.com/golangci/golangci-lint/v2 v2.12.2/go.mod h1:opqHHuIcTG2R+4akzWMd4o1BnD9/1LcjICWOujr91U8=
|
||||
github.com/golangci/golines v0.0.0-20250217134842-442fd0091d95 h1:AkK+w9FZBXlU/xUmBtSJN1+tAI4FIvy5WtnUnY8e4p8=
|
||||
github.com/golangci/golines v0.0.0-20250217134842-442fd0091d95/go.mod h1:k9mmcyWKSTMcPPvQUCfRWWQ9VHJ1U9Dc0R7kaXAgtnQ=
|
||||
github.com/golangci/golines v0.15.0 h1:Qnph25g8Y1c5fdo1X7GaRDGgnMHgnxh4Gk4VfPTtRx0=
|
||||
|
|
@ -227,6 +273,8 @@ github.com/golangci/plugin-module-register v0.1.2 h1:e5WM6PO6NIAEcij3B053CohVp3H
|
|||
github.com/golangci/plugin-module-register v0.1.2/go.mod h1:1+QGTsKBvAIvPvoY/os+G5eoqxWn70HYDm2uvUyGuVw=
|
||||
github.com/golangci/revgrep v0.8.0 h1:EZBctwbVd0aMeRnNUsFogoyayvKHyxlV3CdUA46FX2s=
|
||||
github.com/golangci/revgrep v0.8.0/go.mod h1:U4R/s9dlXZsg8uJmaR1GrloUr14D7qDl8gi2iPXJH8k=
|
||||
github.com/golangci/rowserrcheck v0.0.0-20260419091836-c5f79b8a11ba h1:lqtcnSMDuuJdu/LrKWi5RJzpSNLOJXYe/nzQutTI5kg=
|
||||
github.com/golangci/rowserrcheck v0.0.0-20260419091836-c5f79b8a11ba/go.mod h1:sCBNcpRmhJCtbFGz49+IM3ETTFf7QdJ30AeYCd43NKk=
|
||||
github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e h1:ai0EfmVYE2bRA5htgAG9r7s3tHsfjIhN98WshBTJ9jM=
|
||||
github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e/go.mod h1:Vrn4B5oR9qRwM+f54koyeH3yzphlecwERs0el27Fr/s=
|
||||
github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e h1:gD6P7NEo7Eqtt0ssnqSJNNndxe69DOQ24A5h7+i3KpM=
|
||||
|
|
@ -239,6 +287,7 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX
|
|||
github.com/google/pprof v0.0.0-20250607225305-033d6d78b36a h1://KbezygeMJZCSHH+HgUZiTeSoiuFspbMg1ge+eFj18=
|
||||
github.com/google/pprof v0.0.0-20250607225305-033d6d78b36a/go.mod h1:5hDyRhoBCxViHszMt12TnOpEI4VVi+U8Gm9iphldiMA=
|
||||
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6 h1:EEHtgt9IwisQ2AZ4pIsMjahcegHh6rmhqxzIRQIyepY=
|
||||
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 h1:z2ogiKUYzX5Is6zr/vP9vJGqPwcdqsWjOt+V8J7+bTc=
|
||||
github.com/gordonklaus/ineffassign v0.2.0 h1:Uths4KnmwxNJNzq87fwQQDDnbNb7De00VOk9Nu0TySs=
|
||||
github.com/gordonklaus/ineffassign v0.2.0/go.mod h1:TIpymnagPSexySzs7F9FnO1XFTy8IT3a59vmZp5Y9Lw=
|
||||
github.com/gostaticanalysis/analysisutil v0.7.1 h1:ZMCjoue3DtDWQ5WyU16YbjbQEQ3VuzwxALrpYd+HeKk=
|
||||
|
|
@ -262,6 +311,8 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe
|
|||
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go-version v1.8.0 h1:KAkNb1HAiZd1ukkxDFGmokVZe1Xy9HG6NUp+bPle2i4=
|
||||
github.com/hashicorp/go-version v1.8.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go-version v1.9.0 h1:CeOIz6k+LoN3qX9Z0tyQrPtiB1DFYRPfCIBtaXPSCnA=
|
||||
github.com/hashicorp/go-version v1.9.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
||||
|
|
@ -270,6 +321,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
|
|||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/jgautheron/goconst v1.8.2 h1:y0XF7X8CikZ93fSNT6WBTb/NElBu9IjaY7CCYQrCMX4=
|
||||
github.com/jgautheron/goconst v1.8.2/go.mod h1:A0oxgBCHy55NQn6sYpO7UdnA9p+h7cPtoOZUmvNIako=
|
||||
github.com/jgautheron/goconst v1.10.0 h1:Ptt+OoE4NaEWKhLrWrrN3IpZdGLiqaf7WLnEX/iv4Jw=
|
||||
github.com/jgautheron/goconst v1.10.0/go.mod h1:0p+wv1lFOiUr0IlNNT1nrm6+8DB8u2sU6KHGzFRXHDc=
|
||||
github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs=
|
||||
github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c=
|
||||
github.com/jjti/go-spancheck v0.6.5 h1:lmi7pKxa37oKYIMScialXUK6hP3iY5F1gu+mLBPgYB8=
|
||||
|
|
@ -282,6 +335,8 @@ github.com/karamaru-alpha/copyloopvar v1.2.2 h1:yfNQvP9YaGQR7VaWLYcfZUlRP2eo2vhE
|
|||
github.com/karamaru-alpha/copyloopvar v1.2.2/go.mod h1:oY4rGZqZ879JkJMtX3RRkcXRkmUvH0x35ykgaKgsgJY=
|
||||
github.com/kisielk/errcheck v1.9.0 h1:9xt1zI9EBfcYBvdU1nVrzMzzUPUtPKs9bVSIM3TAb3M=
|
||||
github.com/kisielk/errcheck v1.9.0/go.mod h1:kQxWMMVZgIkDq7U8xtG/n2juOjbLgZtedi0D+/VL/i8=
|
||||
github.com/kisielk/errcheck v1.10.0 h1:Lvs/YAHP24YKg08LA8oDw2z9fJVme090RAXd90S+rrw=
|
||||
github.com/kisielk/errcheck v1.10.0/go.mod h1:kQxWMMVZgIkDq7U8xtG/n2juOjbLgZtedi0D+/VL/i8=
|
||||
github.com/kkHAIKE/contextcheck v1.1.6 h1:7HIyRcnyzxL9Lz06NGhiKvenXq7Zw6Q0UQu/ttjfJCE=
|
||||
github.com/kkHAIKE/contextcheck v1.1.6/go.mod h1:3dDbMRNBFaq8HFXWC1JyvDSPm43CmE6IuHam8Wr0rkg=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
|
|
@ -319,12 +374,16 @@ github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84Yrj
|
|||
github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/lucasb-eyer/go-colorful v1.4.0 h1:UtrWVfLdarDgc44HcS7pYloGHJUjHV/4FwW4TvVgFr4=
|
||||
github.com/lucasb-eyer/go-colorful v1.4.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/macabu/inamedparam v0.2.0 h1:VyPYpOc10nkhI2qeNUdh3Zket4fcZjEWe35poddBCpE=
|
||||
github.com/macabu/inamedparam v0.2.0/go.mod h1:+Pee9/YfGe5LJ62pYXqB89lJ+0k5bsR8Wgz/C0Zlq3U=
|
||||
github.com/manuelarte/embeddedstructfieldcheck v0.4.0 h1:3mAIyaGRtjK6EO9E73JlXLtiy7ha80b2ZVGyacxgfww=
|
||||
github.com/manuelarte/embeddedstructfieldcheck v0.4.0/go.mod h1:z8dFSyXqp+fC6NLDSljRJeNQJJDWnY7RoWFzV3PC6UM=
|
||||
github.com/manuelarte/funcorder v0.5.0 h1:llMuHXXbg7tD0i/LNw8vGnkDTHFpTnWqKPI85Rknc+8=
|
||||
github.com/manuelarte/funcorder v0.5.0/go.mod h1:Yt3CiUQthSBMBxjShjdXMexmzpP8YGvGLjrxJNkO2hA=
|
||||
github.com/manuelarte/funcorder v0.6.0 h1:0hBngc4fa1IgNiI65A7sFGkMvoMCc878RjqB5V7rWP0=
|
||||
github.com/manuelarte/funcorder v0.6.0/go.mod h1:id3NDhXdQBmeqXH7eVC6Z89xS6JxvZ8kF9xUxpArU/g=
|
||||
github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s93SLMxb2vI=
|
||||
github.com/maratori/testableexamples v1.0.0/go.mod h1:4rhjL1n20TUTT4vdh3RDqSizKLyXp7K2u6HgraZCGzE=
|
||||
github.com/maratori/testableexamples v1.0.1 h1:HfOQXs+XgfeRBJ+Wz0XfH+FHnoY9TVqL6Fcevpzy4q8=
|
||||
|
|
@ -344,14 +403,20 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
|
|||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw=
|
||||
github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
||||
github.com/mgechev/revive v1.12.0 h1:Q+/kkbbwerrVYPv9d9efaPGmAO/NsxwW/nE6ahpQaCU=
|
||||
github.com/mgechev/revive v1.12.0/go.mod h1:VXsY2LsTigk8XU9BpZauVLjVrhICMOV3k1lpB3CXrp8=
|
||||
github.com/mgechev/revive v1.14.0 h1:CC2Ulb3kV7JFYt+izwORoS3VT/+Plb8BvslI/l1yZsc=
|
||||
github.com/mgechev/revive v1.14.0/go.mod h1:MvnujelCZBZCaoDv5B3foPo6WWgULSSFxvfxp7GsPfo=
|
||||
github.com/mgechev/revive v1.15.0 h1:vJ0HzSBzfNyPbHKolgiFjHxLek9KUijhqh42yGoqZ8Q=
|
||||
github.com/mgechev/revive v1.15.0/go.mod h1:LlAKO3QQe9OJ0pVZzI2GPa8CbXGZ/9lNpCGvK4T/a8A=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/moricho/tparallel v0.3.2 h1:odr8aZVFA3NZrNybggMkYO3rgPRcqjeQUlBBFVxKHTI=
|
||||
github.com/moricho/tparallel v0.3.2/go.mod h1:OQ+K3b4Ln3l2TZveGCywybl68glfLEwFGqvnjok8b+U=
|
||||
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
|
||||
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
||||
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
|
||||
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
|
|
@ -366,12 +431,16 @@ github.com/nunnatsa/ginkgolinter v0.21.0 h1:IYwuX+ajy3G1MezlMLB1BENRtFj16+Evyi4u
|
|||
github.com/nunnatsa/ginkgolinter v0.21.0/go.mod h1:QlzY9UP9zaqu58FjYxhp9bnjuwXwG1bfW5rid9ChNMw=
|
||||
github.com/nunnatsa/ginkgolinter v0.22.0 h1:o9g7JN6efdBxAHhejvPkodEjWsOBze9zDnPePsvC/Qg=
|
||||
github.com/nunnatsa/ginkgolinter v0.22.0/go.mod h1:zIFAk36fhcHQIiYOGXLbrGTXz7cvpufhRYem6ToCVnY=
|
||||
github.com/nunnatsa/ginkgolinter v0.23.0 h1:x3o4DGYOWbBMP/VdNQKgSj+25aJKx2Pe6lHr8gBcgf8=
|
||||
github.com/nunnatsa/ginkgolinter v0.23.0/go.mod h1:9qN1+0akwXEccwV1CAcCDfcoBlWXHB+ML9884pL4SZ4=
|
||||
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
|
||||
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
|
||||
github.com/onsi/ginkgo/v2 v2.27.2 h1:LzwLj0b89qtIy6SSASkzlNvX6WktqurSHwkk2ipF/Ns=
|
||||
github.com/onsi/ginkgo/v2 v2.28.2 h1:DTrMfpqxiNUyQ3Y0zhn1n3cOO2euFgQPYIpkWwxVFps=
|
||||
github.com/onsi/gomega v1.38.0 h1:c/WX+w8SLAinvuKKQFh77WEucCnPk4j2OTUr7lt7BeY=
|
||||
github.com/onsi/gomega v1.38.0/go.mod h1:OcXcwId0b9QsE7Y49u+BTrL4IdKOBOKnD6VQNTJEB6o=
|
||||
github.com/onsi/gomega v1.38.2 h1:eZCjf2xjZAqe+LeWvKb5weQ+NcPwX84kqJ0cZNxok2A=
|
||||
github.com/onsi/gomega v1.39.1 h1:1IJLAad4zjPn2PsnhH70V4DKRFlrCzGBNrNaru+Vf28=
|
||||
github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
|
||||
github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU=
|
||||
github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w=
|
||||
|
|
@ -381,6 +450,8 @@ github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT9
|
|||
github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pelletier/go-toml/v2 v2.3.1 h1:MYEvvGnQjeNkRF1qUuGolNtNExTDwct51yp7olPtrEc=
|
||||
github.com/pelletier/go-toml/v2 v2.3.1/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
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=
|
||||
|
|
@ -420,8 +491,12 @@ github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7
|
|||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryancurrah/gomodguard v1.4.1 h1:eWC8eUMNZ/wM/PWuZBv7JxxqT5fiIKSIyTvjb7Elr+g=
|
||||
github.com/ryancurrah/gomodguard v1.4.1/go.mod h1:qnMJwV1hX9m+YJseXEBhd2s90+1Xn6x9dLz11ualI1I=
|
||||
github.com/ryancurrah/gomodguard/v2 v2.1.3 h1:E7sz3PJwE9Ba1reVxSpF6XLCPJZ74Kfw/LabTNM4GIA=
|
||||
github.com/ryancurrah/gomodguard/v2 v2.1.3/go.mod h1:CQicdLGatWMxLX53JzoBjYlsNZhHbmLv2AVa0s2aivU=
|
||||
github.com/ryanrolds/sqlclosecheck v0.5.1 h1:dibWW826u0P8jNLsLN+En7+RqWWTYrjCB9fJfSfdyCU=
|
||||
github.com/ryanrolds/sqlclosecheck v0.5.1/go.mod h1:2g3dUjoS6AL4huFdv6wn55WpLIDjY7ZgUR4J8HOO/XQ=
|
||||
github.com/ryanrolds/sqlclosecheck v0.6.0 h1:pEyL9okISdg1F1SEpJNlrEotkTGerv5BMk7U4AG0eVg=
|
||||
github.com/ryanrolds/sqlclosecheck v0.6.0/go.mod h1:xyX16hsDaCMXHrMJ3JMzGf5OpDfHTOTTQrT7HOFUmeU=
|
||||
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
|
||||
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
|
||||
github.com/sanposhiho/wastedassign/v2 v2.1.0 h1:crurBF7fJKIORrV85u9UUpePDYGWnwvv3+A96WvwXT0=
|
||||
|
|
@ -436,6 +511,8 @@ github.com/securego/gosec/v2 v2.22.8 h1:3NMpmfXO8wAVFZPNsd3EscOTa32Jyo6FLLlW53be
|
|||
github.com/securego/gosec/v2 v2.22.8/go.mod h1:ZAw8K2ikuH9qDlfdV87JmNghnVfKB1XC7+TVzk6Utto=
|
||||
github.com/securego/gosec/v2 v2.22.11 h1:tW+weM/hCM/GX3iaCV91d5I6hqaRT2TPsFM1+USPXwg=
|
||||
github.com/securego/gosec/v2 v2.22.11/go.mod h1:KE4MW/eH0GLWztkbt4/7XpyH0zJBBnu7sYB4l6Wn7Mw=
|
||||
github.com/securego/gosec/v2 v2.26.1 h1:gdkttGhQFVehqRJ8grKH4DrpqM/QlPKNHBnl8QgcEC4=
|
||||
github.com/securego/gosec/v2 v2.26.1/go.mod h1:57UW4p0uoP3kxoTkhoo3axLdVAi+OWrLg/Ax/kdqtPE=
|
||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
|
||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
|
||||
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
|
||||
|
|
@ -448,10 +525,14 @@ github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+W
|
|||
github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4=
|
||||
github.com/sonatard/noctx v0.4.0 h1:7MC/5Gg4SQ4lhLYR6mvOP6mQVSxCrdyiExo7atBs27o=
|
||||
github.com/sonatard/noctx v0.4.0/go.mod h1:64XdbzFb18XL4LporKXp8poqZtPKbCrqQ402CV+kJas=
|
||||
github.com/sonatard/noctx v0.5.1 h1:wklWg9c9ZYugOAk7qG4yP4PBrlQsmSLPTvW1K4PRQMs=
|
||||
github.com/sonatard/noctx v0.5.1/go.mod h1:64XdbzFb18XL4LporKXp8poqZtPKbCrqQ402CV+kJas=
|
||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
||||
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
||||
github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0=
|
||||
github.com/sourcegraph/go-diff v0.7.0/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs=
|
||||
github.com/sourcegraph/go-diff v0.8.0 h1:ipIyu4cTsLbIrln4l0qtHA3r0a7gyK4ntKjtQytHhvY=
|
||||
github.com/sourcegraph/go-diff v0.8.0/go.mod h1:hWlcO7Al+UZStZAP8rBumHpCK5ZHQ5BXsMls8p4+F5E=
|
||||
github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA=
|
||||
github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo=
|
||||
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||
|
|
@ -490,8 +571,12 @@ github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpR
|
|||
github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY=
|
||||
github.com/tetafro/godot v1.5.4 h1:u1ww+gqpRLiIA16yF2PV1CV1n/X3zhyezbNXC3E14Sg=
|
||||
github.com/tetafro/godot v1.5.4/go.mod h1:eOkMrVQurDui411nBY2FA05EYH01r14LuWY/NrVDVcU=
|
||||
github.com/tetafro/godot v1.5.6 h1:IEkrFCwXaYHlOn4mGzGS3F3dkP6m9t0jpwqBFPIkKiA=
|
||||
github.com/tetafro/godot v1.5.6/go.mod h1:eOkMrVQurDui411nBY2FA05EYH01r14LuWY/NrVDVcU=
|
||||
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 h1:9LPGD+jzxMlnk5r6+hJnar67cgpDIz/iyD+rfl5r2Vk=
|
||||
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460=
|
||||
github.com/timakin/bodyclose v0.0.0-20260129054331-73d1f95b84b4 h1:SiHe5XLTn9sFWJ5pBwJ5FN/4j34q9ZlOAD//kMoMYp0=
|
||||
github.com/timakin/bodyclose v0.0.0-20260129054331-73d1f95b84b4/go.mod h1:sDHLK7rb/59v/ZxZ7KtymgcoxuUMxjXq8gtu9VMOK8M=
|
||||
github.com/timonwong/loggercheck v0.11.0 h1:jdaMpYBl+Uq9mWPXv1r8jc5fC3gyXx4/WGwTnnNKn4M=
|
||||
github.com/timonwong/loggercheck v0.11.0/go.mod h1:HEAWU8djynujaAVX7QI65Myb8qgfcZ1uKbdpg3ZzKl8=
|
||||
github.com/tomarrell/wrapcheck/v2 v2.11.0 h1:BJSt36snX9+4WTIXeJ7nvHBQBcm1h2SjQMSlmQ6aFSU=
|
||||
|
|
@ -506,8 +591,12 @@ github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSW
|
|||
github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8=
|
||||
github.com/uudashr/gocognit v1.2.0 h1:3BU9aMr1xbhPlvJLSydKwdLN3tEUUrzPSSM8S4hDYRA=
|
||||
github.com/uudashr/gocognit v1.2.0/go.mod h1:k/DdKPI6XBZO1q7HgoV2juESI2/Ofj9AcHPZhBBdrTU=
|
||||
github.com/uudashr/gocognit v1.2.1 h1:CSJynt5txTnORn/DkhiB4mZjwPuifyASC8/6Q0I/QS4=
|
||||
github.com/uudashr/gocognit v1.2.1/go.mod h1:acaubQc6xYlXFEMb9nWX2dYBzJ/bIjEkc1zzvyIZg5Q=
|
||||
github.com/uudashr/iface v1.4.1 h1:J16Xl1wyNX9ofhpHmQ9h9gk5rnv2A6lX/2+APLTo0zU=
|
||||
github.com/uudashr/iface v1.4.1/go.mod h1:pbeBPlbuU2qkNDn0mmfrxP2X+wjPMIQAy+r1MBXSXtg=
|
||||
github.com/uudashr/iface v1.4.2 h1:06Vq5RKVYThBsj0Bnw4oasMjD1r+7CE/bcKOA8dVSvg=
|
||||
github.com/uudashr/iface v1.4.2/go.mod h1:pbeBPlbuU2qkNDn0mmfrxP2X+wjPMIQAy+r1MBXSXtg=
|
||||
github.com/xen0n/gosmopolitan v1.3.0 h1:zAZI1zefvo7gcpbCOrPSHJZJYA9ZgLfJqtKzZ5pHqQM=
|
||||
github.com/xen0n/gosmopolitan v1.3.0/go.mod h1:rckfr5T6o4lBtM1ga7mLGKZmLxswUoH1zxHgNXOsEt4=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
||||
|
|
@ -532,6 +621,8 @@ go-simpler.org/musttag v0.14.0 h1:XGySZATqQYSEV3/YTy+iX+aofbZZllJaqwFWs+RTtSo=
|
|||
go-simpler.org/musttag v0.14.0/go.mod h1:uP8EymctQjJ4Z1kUnjX0u2l60WfUdQxCwSNKzE1JEOE=
|
||||
go-simpler.org/sloglint v0.11.1 h1:xRbPepLT/MHPTCA6TS/wNfZrDzkGvCCqUv4Bdwc3H7s=
|
||||
go-simpler.org/sloglint v0.11.1/go.mod h1:2PowwiCOK8mjiF+0KGifVOT8ZsCNiFzvfyJeJOIt8MQ=
|
||||
go-simpler.org/sloglint v0.12.0 h1:UzWDlLWNE5FLqsvyq3tWYHuQMbqrervOhT8qPl4Mmw4=
|
||||
go-simpler.org/sloglint v0.12.0/go.mod h1:jBjjC2bm8rYrs88oTRlFX497kWjJsyZWYoNaXkGRI6I=
|
||||
go.augendre.info/arangolint v0.2.0 h1:2NP/XudpPmfBhQKX4rMk+zDYIj//qbt4hfZmSSTcpj8=
|
||||
go.augendre.info/arangolint v0.2.0/go.mod h1:Vx4KSJwu48tkE+8uxuf0cbBnAPgnt8O1KWiT7bljq7w=
|
||||
go.augendre.info/arangolint v0.4.0 h1:xSCZjRoS93nXazBSg5d0OGCi9APPLNMmmLrC995tR50=
|
||||
|
|
@ -566,6 +657,8 @@ golang.org/x/exp/typeparams v0.0.0-20250911091902-df9299821621 h1:Yl4H5w2RV7L/dv
|
|||
golang.org/x/exp/typeparams v0.0.0-20250911091902-df9299821621/go.mod h1:4Mzdyp/6jzw9auFDJ3OMF5qksa7UvPnzKqTVGcb04ms=
|
||||
golang.org/x/exp/typeparams v0.0.0-20251125195548-87e1e737ad39 h1:yzGKB4T4r1nFi65o7dQ96ERTfU2trk8Ige9aqqADqf4=
|
||||
golang.org/x/exp/typeparams v0.0.0-20251125195548-87e1e737ad39/go.mod h1:4Mzdyp/6jzw9auFDJ3OMF5qksa7UvPnzKqTVGcb04ms=
|
||||
golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 h1:qWFG1Dj7TBjOjOvhEOkmyGPVoquqUKnIU0lEVLp8xyk=
|
||||
golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358/go.mod h1:4Mzdyp/6jzw9auFDJ3OMF5qksa7UvPnzKqTVGcb04ms=
|
||||
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.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
|
|
@ -579,6 +672,8 @@ golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
|
|||
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
|
||||
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
|
||||
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
|
||||
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
|
||||
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
|
||||
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=
|
||||
|
|
@ -596,6 +691,8 @@ golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
|||
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
||||
golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
|
||||
golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
|
||||
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
|
||||
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
|
||||
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-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
|
@ -609,6 +706,8 @@ golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
|
|||
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
|
@ -633,6 +732,8 @@ golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
|||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
|
||||
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
|
||||
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
|
|
@ -651,6 +752,8 @@ golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
|||
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
|
||||
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
|
||||
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
|
||||
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200329025819-fd4102a86c65/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
||||
|
|
@ -667,6 +770,8 @@ golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
|
|||
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
|
||||
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
|
||||
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
|
||||
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
|
||||
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
|
||||
golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM=
|
||||
golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY=
|
||||
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM=
|
||||
|
|
@ -679,6 +784,8 @@ google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9x
|
|||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
|
||||
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
||||
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
|
|
@ -690,6 +797,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.6.1 h1:R094WgE8K4JirYjBaOpz/AvTyUu/3wbmAoskKN/pxTI=
|
||||
honnef.co/go/tools v0.6.1/go.mod h1:3puzxxljPCe8RGJX7BIy1plGbxEOZni5mR2aXe3/uk4=
|
||||
honnef.co/go/tools v0.7.0 h1:w6WUp1VbkqPEgLz4rkBzH/CSU6HkoqNLp6GstyTx3lU=
|
||||
honnef.co/go/tools v0.7.0/go.mod h1:pm29oPxeP3P82ISxZDgIYeOaf9ta6Pi0EWvCFoLG2vc=
|
||||
mvdan.cc/gofumpt v0.9.1 h1:p5YT2NfFWsYyTieYgwcQ8aKV3xRvFH4uuN/zB2gBbMQ=
|
||||
mvdan.cc/gofumpt v0.9.1/go.mod h1:3xYtNemnKiXaTh6R4VtlqDATFwBbdXI8lJvH/4qk7mw=
|
||||
mvdan.cc/gofumpt v0.9.2 h1:zsEMWL8SVKGHNztrx6uZrXdp7AX8r421Vvp23sz7ik4=
|
||||
|
|
|
|||
6
.github/workflows/go-lint.yml
vendored
6
.github/workflows/go-lint.yml
vendored
|
|
@ -58,7 +58,7 @@ jobs:
|
|||
lint-go:
|
||||
needs: detect-changes
|
||||
if: needs.detect-changes.outputs.changed == 'true'
|
||||
runs-on: ubuntu-x64-large-io
|
||||
runs-on: ubuntu-x64-xlarge
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
|
|
@ -68,9 +68,9 @@ jobs:
|
|||
with:
|
||||
cache-build: 'false'
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@b002b6ecfcabe6ac0e2c6cba1bcc779eb34ac51f # v9
|
||||
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
|
||||
with:
|
||||
version: v2.9.0
|
||||
version: v2.12.2
|
||||
args: |
|
||||
--verbose $(go list -m -f '{{.Dir}}' | xargs -I{} sh -c 'test ! -f {}/.nolint && echo {}/...')
|
||||
install-mode: binary
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
# $schema: https://golangci-lint.run/jsonschema/golangci.jsonschema.json
|
||||
version: '2'
|
||||
run:
|
||||
timeout: 15m
|
||||
concurrency: 10
|
||||
timeout: 30m
|
||||
concurrency: 0 # GOMAXPROCS
|
||||
allow-parallel-runners: true
|
||||
linters:
|
||||
default: none
|
||||
|
|
@ -258,6 +258,15 @@ linters:
|
|||
- linters:
|
||||
- staticcheck
|
||||
text: use fake service and real access control evaluator instead
|
||||
- linters:
|
||||
- staticcheck
|
||||
text: 'QF1012'
|
||||
- linters:
|
||||
- gosec
|
||||
text: G101 # extremely noisy and low confidence
|
||||
- linters:
|
||||
- gosec
|
||||
text: G118 # extremely noisy and low confidence
|
||||
- linters:
|
||||
- gosec
|
||||
text: G108
|
||||
|
|
@ -304,6 +313,10 @@ linters:
|
|||
- gosec
|
||||
path: (.+)_test\.go
|
||||
text: G601
|
||||
- linters:
|
||||
- gosec
|
||||
path: (.+)_test\.go
|
||||
text: G124
|
||||
paths:
|
||||
- devenv
|
||||
- scripts
|
||||
|
|
|
|||
|
|
@ -298,6 +298,7 @@ func TestJsonDataToMetaJSONData(t *testing.T) {
|
|||
JwtTokenAuth: &plugins.JWTTokenAuth{
|
||||
Url: "https://jwt.example.com/token",
|
||||
Scopes: []string{"read"},
|
||||
// #nosec G101 -- test fixture, not a real credential
|
||||
Params: map[string]string{
|
||||
"token_uri": "https://jwt.example.com/token",
|
||||
"client_email": "client@example.com",
|
||||
|
|
|
|||
|
|
@ -713,6 +713,7 @@ func TestGithubClient_CreateInstallationAccessToken(t *testing.T) {
|
|||
),
|
||||
installationID: "12345",
|
||||
repo: "test-repo",
|
||||
// #nosec G101 -- test fixture, not a real credential
|
||||
wantToken: conngh.InstallationToken{
|
||||
Token: "ghs_test_token_123456789",
|
||||
ExpiresAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
|
|
|
|||
|
|
@ -1688,7 +1688,7 @@ func TestConnection_GenerateRepositoryToken(t *testing.T) {
|
|||
mockFactory.EXPECT().New(mock.Anything, common.RawSecureValue("jwt-token")).Return(mockClient)
|
||||
mockClient.EXPECT().CreateInstallationAccessToken(mock.Anything, "456", "test-repo").
|
||||
Return(github.InstallationToken{
|
||||
Token: "ghs_repository_token_123",
|
||||
Token: "ghs_repository_token_123", // #nosec G101 -- test fixture, not a real credential
|
||||
ExpiresAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
}, nil)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ func validateExportJobOptions(opts *provisioning.ExportJobOptions) field.ErrorLi
|
|||
|
||||
// validateMigrateJobOptions validates migrate job options
|
||||
func validateMigrateJobOptions(opts *provisioning.MigrateJobOptions) field.ErrorList {
|
||||
list := field.ErrorList{}
|
||||
list := field.ErrorList{} //nolint:prealloc
|
||||
|
||||
// Empty Resources is valid: the worker falls back to migrating every
|
||||
// unmanaged resource (legacy behavior).
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ func IsInterfaceNil(i interface{}) bool {
|
|||
return true
|
||||
}
|
||||
switch iv.Kind() {
|
||||
case reflect.Ptr, reflect.Slice, reflect.Map, reflect.Func, reflect.Interface:
|
||||
case reflect.Pointer, reflect.Slice, reflect.Map, reflect.Func, reflect.Interface:
|
||||
return iv.IsNil()
|
||||
default:
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func GetRequester(ctx context.Context) (Requester, error) {
|
|||
}
|
||||
|
||||
func checkNilRequester(r Requester) bool {
|
||||
return r == nil || (reflect.ValueOf(r).Kind() == reflect.Ptr && reflect.ValueOf(r).IsNil())
|
||||
return r == nil || (reflect.ValueOf(r).Kind() == reflect.Pointer && reflect.ValueOf(r).IsNil())
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ func MetaAccessor(raw interface{}) (GrafanaMetaAccessor, error) {
|
|||
|
||||
// reflection to find title and other non object properties
|
||||
r := reflect.ValueOf(raw)
|
||||
if r.Kind() == reflect.Ptr || r.Kind() == reflect.Interface {
|
||||
if r.Kind() == reflect.Pointer || r.Kind() == reflect.Interface {
|
||||
r = r.Elem()
|
||||
}
|
||||
return &grafanaMetaAccessor{raw, obj, r}, nil
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
func Test_WithPathRewriters(t *testing.T) {
|
||||
mockHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, err := w.Write([]byte(r.URL.Path))
|
||||
_, err := w.Write([]byte(r.URL.Path)) // #nosec G705 -- test handler echoing controlled input
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
)
|
||||
|
||||
func TestInjectURLCredentials(t *testing.T) {
|
||||
// #nosec G101 -- test fixture, not a real credential
|
||||
expected := "https://username:password@example.org/somepath?query=param"
|
||||
input := "https://example.org/somepath?query=param"
|
||||
output, err := injectURLCredentials(input, "username", "password")
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ func createCliContextWithArgs(t *testing.T, args []string, flagPairs ...string)
|
|||
// Add flags from the key-value pairs
|
||||
for i := 0; i < len(flagPairs); i += 2 {
|
||||
key := flagPairs[i]
|
||||
value := flagPairs[i+1]
|
||||
value := flagPairs[i+1] // #nosec G602 -- loop step of 2 ensures i+1 is in range
|
||||
flagSet.String(key, "", "")
|
||||
err := flagSet.Set(key, value)
|
||||
require.NoError(t, err, "Failed to set flag %s=%s", key, value)
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ func (w *s3ClientWrapper) Upload(ctx context.Context, input *s3manager.UploadInp
|
|||
|
||||
func (w *s3ClientWrapper) PresignGetObject(bucket, key string, expiration time.Duration) (string, error) {
|
||||
req, _ := w.svc.GetObjectRequest(&s3.GetObjectInput{
|
||||
Bucket: aws.String(bucket),
|
||||
Key: aws.String(key),
|
||||
Bucket: new(bucket),
|
||||
Key: new(key),
|
||||
})
|
||||
return req.Presign(expiration)
|
||||
}
|
||||
|
|
@ -93,9 +93,9 @@ func (u *S3Uploader) Upload(ctx context.Context, imageDiskPath string) (string,
|
|||
remoteCredProvider(sess),
|
||||
})
|
||||
cfg := &aws.Config{
|
||||
Region: aws.String(u.opts.Region),
|
||||
Endpoint: aws.String(u.opts.Endpoint),
|
||||
S3ForcePathStyle: aws.Bool(u.opts.PathStyleAccess),
|
||||
Region: new(u.opts.Region),
|
||||
Endpoint: new(u.opts.Endpoint),
|
||||
S3ForcePathStyle: new(u.opts.PathStyleAccess),
|
||||
Credentials: creds,
|
||||
}
|
||||
|
||||
|
|
@ -125,13 +125,13 @@ func (u *S3Uploader) Upload(ctx context.Context, imageDiskPath string) (string,
|
|||
}
|
||||
|
||||
uploadInput := &s3manager.UploadInput{
|
||||
Bucket: aws.String(u.opts.Bucket),
|
||||
Key: aws.String(key),
|
||||
Bucket: new(u.opts.Bucket),
|
||||
Key: new(key),
|
||||
Body: file,
|
||||
ContentType: aws.String("image/png"),
|
||||
ContentType: new("image/png"),
|
||||
}
|
||||
if !u.opts.EnablePresignedURLs {
|
||||
uploadInput.ACL = aws.String(u.opts.ACL)
|
||||
uploadInput.ACL = new(u.opts.ACL)
|
||||
}
|
||||
|
||||
result, err := s3Client.Upload(ctx, uploadInput)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func TestApiKeyValidation(t *testing.T) {
|
||||
// #nosec G101 -- test fixture, not a real credential
|
||||
result := KeyGenResult{
|
||||
ClientSecret: "glsa_iNValIdinValiDinvalidinvalidinva_5b582697",
|
||||
HashedKey: "c59a6e547944ef768df51d1fc8b2a9810bc777a0bd2e5daa9ef8590f300c884e0ab9470c22c6f789414fdb6485b531166ded",
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ func TestConvertNumericWideToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(3.14)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(3.14)}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -56,8 +56,8 @@ func TestConvertNumericWideToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0)}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0)}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -80,9 +80,9 @@ func TestConvertNumericWideToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0)}),
|
||||
data.NewField("env", nil, []*string{nil, sp("prod")}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0)}),
|
||||
data.NewField("env", nil, []*string{nil, new("prod")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -105,8 +105,8 @@ func TestConvertNumericWideToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "mem"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(4.0)}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("a")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(4.0)}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("a")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -129,9 +129,9 @@ func TestConvertNumericWideToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "mem"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(4.0)}),
|
||||
data.NewField("env", nil, []*string{nil, sp("prod")}),
|
||||
data.NewField("host", nil, []*string{sp("a"), nil}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(4.0)}),
|
||||
data.NewField("env", nil, []*string{nil, new("prod")}),
|
||||
data.NewField("host", nil, []*string{new("a"), nil}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ func TestConvertNumericWideToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.23)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.23)}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -184,8 +184,8 @@ func TestConvertNumericWideToFullLongWithDisplayName(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(3.14)}),
|
||||
data.NewField(SQLDisplayFieldName, nil, []*string{sp("CPU Display")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(3.14)}),
|
||||
data.NewField(SQLDisplayFieldName, nil, []*string{new("CPU Display")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -212,9 +212,9 @@ func TestConvertNumericWideToFullLongWithDisplayName(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0)}),
|
||||
data.NewField(SQLDisplayFieldName, nil, []*string{sp("CPU A"), nil}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0)}),
|
||||
data.NewField(SQLDisplayFieldName, nil, []*string{new("CPU A"), nil}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ func TestConvertNumericMultiToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(3.14)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(3.14)}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -265,8 +265,8 @@ func TestConvertNumericMultiToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0)}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0)}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -293,9 +293,9 @@ func TestConvertNumericMultiToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0)}),
|
||||
data.NewField("env", nil, []*string{nil, sp("prod")}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0)}),
|
||||
data.NewField("env", nil, []*string{nil, new("prod")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -322,8 +322,8 @@ func TestConvertNumericMultiToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "mem"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(4.0)}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("a")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(4.0)}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("a")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -350,9 +350,9 @@ func TestConvertNumericMultiToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "mem"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(4.0)}),
|
||||
data.NewField("env", nil, []*string{nil, sp("prod")}),
|
||||
data.NewField("host", nil, []*string{sp("a"), nil}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(4.0)}),
|
||||
data.NewField("env", nil, []*string{nil, new("prod")}),
|
||||
data.NewField("host", nil, []*string{new("a"), nil}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: numericFullLongType}
|
||||
|
||||
|
|
@ -382,7 +382,7 @@ func TestConvertTimeSeriesWideToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField("time", nil, times),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0)}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu"}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
|
@ -407,9 +407,9 @@ func TestConvertTimeSeriesWideToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{times[0], times[0], times[1], times[1]}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(3.0), fp(2.0), fp(4.0)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(3.0), new(2.0), new(4.0)}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu", "cpu", "cpu"}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b"), sp("a"), sp("b")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b"), new("a"), new("b")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
||||
|
|
@ -433,9 +433,9 @@ func TestConvertTimeSeriesWideToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{times[0], times[0], times[1], times[1]}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(3.0), fp(2.0), fp(4.0)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(3.0), new(2.0), new(4.0)}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "mem", "cpu", "mem"}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("a"), sp("a"), sp("a")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("a"), new("a"), new("a")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
||||
|
|
@ -459,10 +459,10 @@ func TestConvertTimeSeriesWideToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{times[0], times[0], times[1], times[1]}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(3.0), fp(2.0), fp(4.0)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(3.0), new(2.0), new(4.0)}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu", "cpu", "cpu"}),
|
||||
data.NewField("env", nil, []*string{nil, sp("prod"), nil, sp("prod")}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b"), sp("a"), sp("b")}),
|
||||
data.NewField("env", nil, []*string{nil, new("prod"), nil, new("prod")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b"), new("a"), new("b")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
||||
|
|
@ -486,10 +486,10 @@ func TestConvertTimeSeriesWideToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{times[0], times[0], times[1], times[1]}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(3.0), fp(2.0), fp(4.0)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(3.0), new(2.0), new(4.0)}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "mem", "cpu", "mem"}),
|
||||
data.NewField("env", nil, []*string{nil, sp("prod"), nil, sp("prod")}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b"), sp("a"), sp("b")}),
|
||||
data.NewField("env", nil, []*string{nil, new("prod"), nil, new("prod")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b"), new("a"), new("b")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
||||
|
|
@ -501,7 +501,3 @@ func TestConvertTimeSeriesWideToFullLong(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
func sp(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ func TestConvertTimeSeriesMultiToFullLong(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField("time", nil, times),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0), fp(3.0)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0), new(3.0)}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu", "cpu"}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
|
@ -64,9 +64,9 @@ func TestConvertTimeSeriesMultiToFullLong(t *testing.T) {
|
|||
data.NewField("time", nil, []time.Time{
|
||||
time.Unix(0, 0), time.Unix(0, 0), time.Unix(10, 0), time.Unix(10, 0),
|
||||
}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(3.0), fp(2.0), fp(4.0)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(3.0), new(2.0), new(4.0)}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu", "cpu", "cpu"}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b"), sp("a"), sp("b")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b"), new("a"), new("b")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
||||
|
|
@ -101,9 +101,9 @@ func TestConvertTimeSeriesMultiToFullLong(t *testing.T) {
|
|||
data.NewField("time", nil, []time.Time{
|
||||
time.Unix(0, 0), time.Unix(0, 0), time.Unix(10, 0), time.Unix(10, 0),
|
||||
}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(3.0), fp(2.0), fp(4.0)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(3.0), new(2.0), new(4.0)}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "mem", "cpu", "mem"}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("a"), sp("a"), sp("a")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("a"), new("a"), new("a")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
||||
|
|
@ -138,10 +138,10 @@ func TestConvertTimeSeriesMultiToFullLong(t *testing.T) {
|
|||
data.NewField("time", nil, []time.Time{
|
||||
time.Unix(0, 0), time.Unix(0, 0), time.Unix(10, 0), time.Unix(10, 0),
|
||||
}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(3.0), fp(2.0), fp(4.0)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(3.0), new(2.0), new(4.0)}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu", "cpu", "cpu"}),
|
||||
data.NewField("env", nil, []*string{nil, sp("prod"), nil, sp("prod")}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b"), sp("a"), sp("b")}),
|
||||
data.NewField("env", nil, []*string{nil, new("prod"), nil, new("prod")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b"), new("a"), new("b")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
||||
|
|
@ -176,9 +176,9 @@ func TestConvertTimeSeriesMultiToFullLong(t *testing.T) {
|
|||
data.NewField("time", nil, []time.Time{
|
||||
time.Unix(0, 0), time.Unix(0, 0), time.Unix(10, 0), time.Unix(10, 0),
|
||||
}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(3.0), fp(2.0), fp(4.0)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(3.0), new(2.0), new(4.0)}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "mem", "cpu", "mem"}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b"), sp("a"), sp("b")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b"), new("a"), new("b")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
||||
|
|
@ -213,10 +213,10 @@ func TestConvertTimeSeriesMultiToFullLong(t *testing.T) {
|
|||
data.NewField("time", nil, []time.Time{
|
||||
time.Unix(0, 0), time.Unix(0, 0), time.Unix(10, 0), time.Unix(10, 0),
|
||||
}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(3.0), fp(2.0), fp(4.0)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(3.0), new(2.0), new(4.0)}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "mem", "cpu", "mem"}),
|
||||
data.NewField("env", nil, []*string{nil, sp("prod"), nil, sp("prod")}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b"), sp("a"), sp("b")}),
|
||||
data.NewField("env", nil, []*string{nil, new("prod"), nil, new("prod")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b"), new("a"), new("b")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
||||
|
|
@ -270,16 +270,16 @@ func TestConvertTimeSeriesMultiToFullLong(t *testing.T) {
|
|||
time.Unix(30, 0), // mem
|
||||
}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{
|
||||
fp(1.0), fp(9.0), fp(2.0), fp(3.0), fp(10.0), fp(4.0),
|
||||
new(1.0), new(9.0), new(2.0), new(3.0), new(10.0), new(4.0),
|
||||
}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{
|
||||
"cpu", "cpu", "cpu", "mem", "cpu", "mem",
|
||||
}),
|
||||
data.NewField("env", nil, []*string{
|
||||
nil, nil, nil, sp("prod"), nil, sp("prod"),
|
||||
nil, nil, nil, new("prod"), nil, new("prod"),
|
||||
}),
|
||||
data.NewField("host", nil, []*string{
|
||||
sp("a"), nil, sp("a"), sp("b"), nil, sp("b"),
|
||||
new("a"), nil, new("a"), new("b"), nil, new("b"),
|
||||
}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
|
@ -311,9 +311,9 @@ func TestConvertTimeSeriesMultiToFullLongWithDisplayName(t *testing.T) {
|
|||
|
||||
expected := data.NewFrame("",
|
||||
data.NewField("time", nil, times),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0)}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu"}),
|
||||
data.NewField(SQLDisplayFieldName, nil, []*string{sp("CPU Display"), sp("CPU Display")}),
|
||||
data.NewField(SQLDisplayFieldName, nil, []*string{new("CPU Display"), new("CPU Display")}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
||||
|
|
@ -351,14 +351,14 @@ func TestConvertTimeSeriesMultiToFullLongWithDisplayName(t *testing.T) {
|
|||
times[0], times[0], times[1], times[1],
|
||||
}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{
|
||||
fp(1.0), fp(3.0), fp(2.0), fp(4.0),
|
||||
new(1.0), new(3.0), new(2.0), new(4.0),
|
||||
}),
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu", "cpu", "cpu"}),
|
||||
data.NewField(SQLDisplayFieldName, nil, []*string{
|
||||
sp("CPU A"), nil, sp("CPU A"), nil,
|
||||
new("CPU A"), nil, new("CPU A"), nil,
|
||||
}),
|
||||
data.NewField("host", nil, []*string{
|
||||
sp("a"), sp("b"), sp("a"), sp("b"),
|
||||
new("a"), new("b"), new("a"), new("b"),
|
||||
}),
|
||||
)
|
||||
expected.Meta = &data.FrameMeta{Type: timeseriesFullLongType}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ func TestConvertDataFramesToResults(t *testing.T) {
|
|||
frames := []*data.Frame{
|
||||
data.NewFrame("test",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("test-value1", nil, []*float64{fp(2)}),
|
||||
data.NewField("test-value2", nil, []*float64{fp(2)})),
|
||||
data.NewField("test-value1", nil, []*float64{new(2.0)}),
|
||||
data.NewField("test-value2", nil, []*float64{new(2.0)})),
|
||||
}
|
||||
|
||||
for _, dtype := range supported {
|
||||
|
|
@ -61,10 +61,10 @@ func TestConvertDataFramesToResults(t *testing.T) {
|
|||
frames := []*data.Frame{
|
||||
data.NewFrame("test-frame1",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("test-value1", nil, []*float64{fp(2)})),
|
||||
data.NewField("test-value1", nil, []*float64{new(2.0)})),
|
||||
data.NewFrame("test-frame2",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("test-value2", nil, []*float64{fp(2)})),
|
||||
data.NewField("test-value2", nil, []*float64{new(2.0)})),
|
||||
}
|
||||
|
||||
for _, dtype := range supported {
|
||||
|
|
@ -87,9 +87,9 @@ func TestConvertDataFramesToResults(t *testing.T) {
|
|||
})
|
||||
})
|
||||
t.Run("should use fields DisplayNameFromDS when it is unique", func(t *testing.T) {
|
||||
f1 := data.NewField("test-value1", nil, []*float64{fp(2)})
|
||||
f1 := data.NewField("test-value1", nil, []*float64{new(2.0)})
|
||||
f1.Config = &data.FieldConfig{DisplayNameFromDS: "test-value1"}
|
||||
f2 := data.NewField("test-value2", nil, []*float64{fp(2)})
|
||||
f2 := data.NewField("test-value2", nil, []*float64{new(2.0)})
|
||||
f2.Config = &data.FieldConfig{DisplayNameFromDS: "test-value2"}
|
||||
frames := []*data.Frame{
|
||||
data.NewFrame("test-frame1",
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ func TestEstimateBinaryMemory(t *testing.T) {
|
|||
{
|
||||
name: "matching labels produce 1:1 unions",
|
||||
a: Results{Values: Values{
|
||||
makeSeries("a", data.Labels{"id": "1"}, tp{time.Unix(1, 0), float64Pointer(1)}),
|
||||
makeSeries("a", data.Labels{"id": "2"}, tp{time.Unix(1, 0), float64Pointer(2)}),
|
||||
makeSeries("a", data.Labels{"id": "1"}, tp{time.Unix(1, 0), new(1.)}),
|
||||
makeSeries("a", data.Labels{"id": "2"}, tp{time.Unix(1, 0), new(2.)}),
|
||||
}},
|
||||
b: Results{Values: Values{
|
||||
makeSeries("b", data.Labels{"id": "1"}, tp{time.Unix(1, 0), float64Pointer(10)}),
|
||||
makeSeries("b", data.Labels{"id": "2"}, tp{time.Unix(1, 0), float64Pointer(20)}),
|
||||
makeSeries("b", data.Labels{"id": "1"}, tp{time.Unix(1, 0), new(10.)}),
|
||||
makeSeries("b", data.Labels{"id": "2"}, tp{time.Unix(1, 0), new(20.)}),
|
||||
}},
|
||||
expectUnions: 2,
|
||||
expectNonZero: true,
|
||||
|
|
@ -53,12 +53,12 @@ func TestEstimateBinaryMemory(t *testing.T) {
|
|||
{
|
||||
name: "empty labels on one side produce cartesian product",
|
||||
a: Results{Values: Values{
|
||||
makeSeries("a", data.Labels{}, tp{time.Unix(1, 0), float64Pointer(1)}),
|
||||
makeSeries("a", data.Labels{}, tp{time.Unix(1, 0), float64Pointer(2)}),
|
||||
makeSeries("a", data.Labels{}, tp{time.Unix(1, 0), new(1.)}),
|
||||
makeSeries("a", data.Labels{}, tp{time.Unix(1, 0), new(2.)}),
|
||||
}},
|
||||
b: Results{Values: Values{
|
||||
makeSeries("b", data.Labels{"id": "1"}, tp{time.Unix(1, 0), float64Pointer(10)}),
|
||||
makeSeries("b", data.Labels{"id": "2"}, tp{time.Unix(1, 0), float64Pointer(20)}),
|
||||
makeSeries("b", data.Labels{"id": "1"}, tp{time.Unix(1, 0), new(10.)}),
|
||||
makeSeries("b", data.Labels{"id": "2"}, tp{time.Unix(1, 0), new(20.)}),
|
||||
}},
|
||||
expectUnions: 4,
|
||||
expectNonZero: true,
|
||||
|
|
@ -66,11 +66,11 @@ func TestEstimateBinaryMemory(t *testing.T) {
|
|||
{
|
||||
name: "subset labels produce fan-out",
|
||||
a: Results{Values: Values{
|
||||
makeSeries("a", data.Labels{"service": "web", "endpoint": "/api"}, tp{time.Unix(1, 0), float64Pointer(1)}),
|
||||
makeSeries("a", data.Labels{"service": "web", "endpoint": "/health"}, tp{time.Unix(1, 0), float64Pointer(2)}),
|
||||
makeSeries("a", data.Labels{"service": "web", "endpoint": "/api"}, tp{time.Unix(1, 0), new(1.)}),
|
||||
makeSeries("a", data.Labels{"service": "web", "endpoint": "/health"}, tp{time.Unix(1, 0), new(2.)}),
|
||||
}},
|
||||
b: Results{Values: Values{
|
||||
makeSeries("b", data.Labels{"service": "web"}, tp{time.Unix(1, 0), float64Pointer(10)}),
|
||||
makeSeries("b", data.Labels{"service": "web"}, tp{time.Unix(1, 0), new(10.)}),
|
||||
}},
|
||||
expectUnions: 2,
|
||||
expectNonZero: true,
|
||||
|
|
@ -78,10 +78,10 @@ func TestEstimateBinaryMemory(t *testing.T) {
|
|||
{
|
||||
name: "single non-matching values fall back to 1 union",
|
||||
a: Results{Values: Values{
|
||||
makeSeries("a", data.Labels{"id": "1"}, tp{time.Unix(1, 0), float64Pointer(1)}),
|
||||
makeSeries("a", data.Labels{"id": "1"}, tp{time.Unix(1, 0), new(1.)}),
|
||||
}},
|
||||
b: Results{Values: Values{
|
||||
makeSeries("b", data.Labels{"id": "2"}, tp{time.Unix(1, 0), float64Pointer(10)}),
|
||||
makeSeries("b", data.Labels{"id": "2"}, tp{time.Unix(1, 0), new(10.)}),
|
||||
}},
|
||||
expectUnions: 1,
|
||||
expectNonZero: true,
|
||||
|
|
@ -90,7 +90,7 @@ func TestEstimateBinaryMemory(t *testing.T) {
|
|||
name: "NoData on one side produces 1 union",
|
||||
a: Results{Values: Values{NewNoData()}},
|
||||
b: Results{Values: Values{
|
||||
makeSeries("b", data.Labels{"id": "1"}, tp{time.Unix(1, 0), float64Pointer(10)}),
|
||||
makeSeries("b", data.Labels{"id": "1"}, tp{time.Unix(1, 0), new(10.)}),
|
||||
}},
|
||||
expectUnions: 1,
|
||||
expectNonZero: true,
|
||||
|
|
@ -116,25 +116,25 @@ func TestEstimateBinaryMemory_per_pair_cost_reflects_actual_sizes(t *testing.T)
|
|||
// Two matching series with different lengths. The estimate should use each
|
||||
// pair's actual sizes, not a global max.
|
||||
shortSeries := makeSeries("a", data.Labels{"id": "1"},
|
||||
tp{time.Unix(1, 0), float64Pointer(1)},
|
||||
tp{time.Unix(1, 0), new(1.)},
|
||||
)
|
||||
longSeries := makeSeries("a", data.Labels{"id": "2"},
|
||||
tp{time.Unix(1, 0), float64Pointer(1)},
|
||||
tp{time.Unix(2, 0), float64Pointer(2)},
|
||||
tp{time.Unix(3, 0), float64Pointer(3)},
|
||||
tp{time.Unix(4, 0), float64Pointer(4)},
|
||||
tp{time.Unix(5, 0), float64Pointer(5)},
|
||||
tp{time.Unix(1, 0), new(1.)},
|
||||
tp{time.Unix(2, 0), new(2.)},
|
||||
tp{time.Unix(3, 0), new(3.)},
|
||||
tp{time.Unix(4, 0), new(4.)},
|
||||
tp{time.Unix(5, 0), new(5.)},
|
||||
)
|
||||
|
||||
a := Results{Values: Values{shortSeries, longSeries}}
|
||||
b := Results{Values: Values{
|
||||
makeSeries("b", data.Labels{"id": "1"}, tp{time.Unix(1, 0), float64Pointer(10)}),
|
||||
makeSeries("b", data.Labels{"id": "1"}, tp{time.Unix(1, 0), new(10.)}),
|
||||
makeSeries("b", data.Labels{"id": "2"},
|
||||
tp{time.Unix(1, 0), float64Pointer(10)},
|
||||
tp{time.Unix(2, 0), float64Pointer(20)},
|
||||
tp{time.Unix(3, 0), float64Pointer(30)},
|
||||
tp{time.Unix(4, 0), float64Pointer(40)},
|
||||
tp{time.Unix(5, 0), float64Pointer(50)},
|
||||
tp{time.Unix(1, 0), new(10.)},
|
||||
tp{time.Unix(2, 0), new(20.)},
|
||||
tp{time.Unix(3, 0), new(30.)},
|
||||
tp{time.Unix(4, 0), new(40.)},
|
||||
tp{time.Unix(5, 0), new(50.)},
|
||||
),
|
||||
}}
|
||||
|
||||
|
|
@ -156,14 +156,14 @@ func TestWalkBinary_memory_limit_blocks_cartesian_explosion(t *testing.T) {
|
|||
bValues := make(Values, 100)
|
||||
for i := range 100 {
|
||||
aValues[i] = makeSeries("a", data.Labels{},
|
||||
tp{time.Unix(1, 0), float64Pointer(1)},
|
||||
tp{time.Unix(2, 0), float64Pointer(2)},
|
||||
tp{time.Unix(3, 0), float64Pointer(3)},
|
||||
tp{time.Unix(1, 0), new(1.)},
|
||||
tp{time.Unix(2, 0), new(2.)},
|
||||
tp{time.Unix(3, 0), new(3.)},
|
||||
)
|
||||
bValues[i] = makeSeries("b", data.Labels{},
|
||||
tp{time.Unix(1, 0), float64Pointer(10)},
|
||||
tp{time.Unix(2, 0), float64Pointer(20)},
|
||||
tp{time.Unix(3, 0), float64Pointer(30)},
|
||||
tp{time.Unix(1, 0), new(10.)},
|
||||
tp{time.Unix(2, 0), new(20.)},
|
||||
tp{time.Unix(3, 0), new(30.)},
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -191,12 +191,12 @@ func TestWalkBinary_memory_limit_allows_matched_labels(t *testing.T) {
|
|||
for i := range 100 {
|
||||
label := data.Labels{"id": string(rune('A'+i%26)) + string(rune('0'+i/26))}
|
||||
aValues[i] = makeSeries("a", label,
|
||||
tp{time.Unix(1, 0), float64Pointer(float64(i))},
|
||||
tp{time.Unix(2, 0), float64Pointer(float64(i * 2))},
|
||||
tp{time.Unix(1, 0), new(float64(i))},
|
||||
tp{time.Unix(2, 0), new(float64(i * 2))},
|
||||
)
|
||||
bValues[i] = makeSeries("b", label,
|
||||
tp{time.Unix(1, 0), float64Pointer(1)},
|
||||
tp{time.Unix(2, 0), float64Pointer(2)},
|
||||
tp{time.Unix(1, 0), new(float64(1))},
|
||||
tp{time.Unix(2, 0), new(float64(2))},
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -223,12 +223,12 @@ func TestWalkBinary_memory_limit_zero_disables_check(t *testing.T) {
|
|||
// Even a cartesian product should proceed when limit is 0.
|
||||
vars := Vars{
|
||||
"A": Results{Values: Values{
|
||||
makeSeries("a", data.Labels{}, tp{time.Unix(1, 0), float64Pointer(1)}),
|
||||
makeSeries("a", data.Labels{}, tp{time.Unix(1, 0), float64Pointer(2)}),
|
||||
makeSeries("a", data.Labels{}, tp{time.Unix(1, 0), new(1.)}),
|
||||
makeSeries("a", data.Labels{}, tp{time.Unix(1, 0), new(2.)}),
|
||||
}},
|
||||
"B": Results{Values: Values{
|
||||
makeSeries("b", data.Labels{}, tp{time.Unix(1, 0), float64Pointer(10)}),
|
||||
makeSeries("b", data.Labels{}, tp{time.Unix(1, 0), float64Pointer(20)}),
|
||||
makeSeries("b", data.Labels{}, tp{time.Unix(1, 0), new(10.)}),
|
||||
makeSeries("b", data.Labels{}, tp{time.Unix(1, 0), new(20.)}),
|
||||
}},
|
||||
}
|
||||
|
||||
|
|
@ -244,10 +244,10 @@ func TestWalkBinary_memory_limit_not_applied_without_option(t *testing.T) {
|
|||
// Without WithMemoryLimit, even small cartesian products should work.
|
||||
vars := Vars{
|
||||
"A": Results{Values: Values{
|
||||
makeSeries("a", data.Labels{}, tp{time.Unix(1, 0), float64Pointer(1)}),
|
||||
makeSeries("a", data.Labels{}, tp{time.Unix(1, 0), new(1.)}),
|
||||
}},
|
||||
"B": Results{Values: Values{
|
||||
makeSeries("b", data.Labels{}, tp{time.Unix(1, 0), float64Pointer(10)}),
|
||||
makeSeries("b", data.Labels{}, tp{time.Unix(1, 0), new(10.)}),
|
||||
}},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ func TestNaN(t *testing.T) {
|
|||
vars: Vars{"A": resultValuesNoErr(makeNumber("", nil, NaN))},
|
||||
newErrIs: assert.NoError,
|
||||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(1))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(1.))),
|
||||
},
|
||||
{
|
||||
name: "binary: Scalar Op(Non-AND/OR) Series(with NaN value) is NaN)",
|
||||
|
|
@ -62,7 +62,7 @@ func TestNaN(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(2),
|
||||
time.Unix(5, 0), new(2.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), NaN,
|
||||
}),
|
||||
|
|
@ -72,7 +72,7 @@ func TestNaN(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(-1),
|
||||
time.Unix(5, 0), new(float64(-1)),
|
||||
}, tp{
|
||||
time.Unix(10, 0), NaN,
|
||||
}),
|
||||
|
|
@ -84,18 +84,18 @@ func TestNaN(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(2),
|
||||
time.Unix(5, 0), new(2.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), NaN,
|
||||
}),
|
||||
),
|
||||
"B": resultValuesNoErr(makeNumber("", nil, float64Pointer(0))),
|
||||
"B": resultValuesNoErr(makeNumber("", nil, new(0.))),
|
||||
},
|
||||
newErrIs: assert.NoError,
|
||||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(0),
|
||||
time.Unix(5, 0), new(0.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), NaN,
|
||||
}),
|
||||
|
|
@ -107,7 +107,7 @@ func TestNaN(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(2),
|
||||
time.Unix(5, 0), new(2.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), NaN,
|
||||
}),
|
||||
|
|
@ -190,7 +190,7 @@ func TestNullValues(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(1),
|
||||
time.Unix(5, 0), new(1.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), nil,
|
||||
}),
|
||||
|
|
@ -200,7 +200,7 @@ func TestNullValues(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(-1),
|
||||
time.Unix(5, 0), new(float64(-1)),
|
||||
}, tp{
|
||||
time.Unix(10, 0), nil,
|
||||
}),
|
||||
|
|
@ -212,7 +212,7 @@ func TestNullValues(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(1),
|
||||
time.Unix(5, 0), new(1.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), nil,
|
||||
}),
|
||||
|
|
@ -222,7 +222,7 @@ func TestNullValues(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(0),
|
||||
time.Unix(5, 0), new(0.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), nil,
|
||||
}),
|
||||
|
|
@ -234,7 +234,7 @@ func TestNullValues(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(1),
|
||||
time.Unix(5, 0), new(1.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), nil,
|
||||
}),
|
||||
|
|
@ -244,7 +244,7 @@ func TestNullValues(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(0),
|
||||
time.Unix(5, 0), new(0.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), nil,
|
||||
}),
|
||||
|
|
@ -275,7 +275,7 @@ func TestNullValues(t *testing.T) {
|
|||
expr: "$A * $B",
|
||||
vars: Vars{
|
||||
"A": resultValuesNoErr(makeNumber("", nil, nil)),
|
||||
"B": resultValuesNoErr(makeNumber("", nil, float64Pointer(1))),
|
||||
"B": resultValuesNoErr(makeNumber("", nil, new(1.))),
|
||||
},
|
||||
newErrIs: assert.NoError,
|
||||
execErrIs: assert.NoError,
|
||||
|
|
@ -285,10 +285,10 @@ func TestNullValues(t *testing.T) {
|
|||
name: "number and series: binary non-null number and series with a null: is null",
|
||||
expr: "$A * $B",
|
||||
vars: Vars{
|
||||
"A": resultValuesNoErr(makeNumber("", nil, float64Pointer(1))),
|
||||
"A": resultValuesNoErr(makeNumber("", nil, new(1.))),
|
||||
"B": resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(1),
|
||||
time.Unix(5, 0), new(1.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), nil,
|
||||
}),
|
||||
|
|
@ -298,7 +298,7 @@ func TestNullValues(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(1),
|
||||
time.Unix(5, 0), new(1.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), nil,
|
||||
}),
|
||||
|
|
@ -311,7 +311,7 @@ func TestNullValues(t *testing.T) {
|
|||
"A": resultValuesNoErr(makeNumber("", nil, nil)),
|
||||
"B": resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(1),
|
||||
time.Unix(5, 0), new(1.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), nil,
|
||||
}),
|
||||
|
|
@ -414,7 +414,7 @@ func TestNoData(t *testing.T) {
|
|||
"$A || $B",
|
||||
"$A && $B",
|
||||
}
|
||||
series := makeSeries("test", nil, tp{time.Unix(5, 0), float64Pointer(2)})
|
||||
series := makeSeries("test", nil, tp{time.Unix(5, 0), new(2.)})
|
||||
for _, expr := range bin_ops {
|
||||
t.Run(fmt.Sprintf("op: %s", expr), func(t *testing.T) {
|
||||
e, err := New(expr)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ func TestScalarExpr(t *testing.T) {
|
|||
newErrIs: assert.NoError,
|
||||
execErrIs: assert.NoError,
|
||||
resultIs: assert.Equal,
|
||||
Results: resultValuesNoErr(NewScalar("", float64Pointer(1.0))),
|
||||
Results: resultValuesNoErr(NewScalar("", new(1.0))),
|
||||
},
|
||||
{
|
||||
name: "unary: scalar",
|
||||
|
|
@ -34,7 +34,7 @@ func TestScalarExpr(t *testing.T) {
|
|||
newErrIs: assert.NoError,
|
||||
execErrIs: assert.NoError,
|
||||
resultIs: assert.Equal,
|
||||
Results: resultValuesNoErr(NewScalar("", float64Pointer(0.0))),
|
||||
Results: resultValuesNoErr(NewScalar("", new(0.0))),
|
||||
},
|
||||
{
|
||||
name: "binary: scalar Op scalar",
|
||||
|
|
@ -43,7 +43,7 @@ func TestScalarExpr(t *testing.T) {
|
|||
newErrIs: assert.NoError,
|
||||
execErrIs: assert.NoError,
|
||||
resultIs: assert.Equal,
|
||||
Results: resultValuesNoErr(NewScalar("", float64Pointer(2.0))),
|
||||
Results: resultValuesNoErr(NewScalar("", new(2.0))),
|
||||
},
|
||||
{
|
||||
name: "binary: scalar Op scalar - divide by zero",
|
||||
|
|
@ -52,25 +52,25 @@ func TestScalarExpr(t *testing.T) {
|
|||
newErrIs: assert.NoError,
|
||||
execErrIs: assert.NoError,
|
||||
resultIs: assert.Equal,
|
||||
Results: resultValuesNoErr(NewScalar("", float64Pointer(math.Inf(1)))),
|
||||
Results: resultValuesNoErr(NewScalar("", new(math.Inf(1)))),
|
||||
},
|
||||
{
|
||||
name: "binary: scalar Op number",
|
||||
expr: "1 + $A",
|
||||
vars: Vars{"A": resultValuesNoErr(makeNumber("temp", nil, float64Pointer(2.0)))},
|
||||
vars: Vars{"A": resultValuesNoErr(makeNumber("temp", nil, new(2.0)))},
|
||||
newErrIs: assert.NoError,
|
||||
execErrIs: assert.NoError,
|
||||
resultIs: assert.Equal,
|
||||
Results: resultValuesNoErr(makeNumber("", nil, float64Pointer(3.0))),
|
||||
Results: resultValuesNoErr(makeNumber("", nil, new(3.0))),
|
||||
},
|
||||
{
|
||||
name: "binary: number Op Scalar",
|
||||
expr: "$A - 3",
|
||||
vars: Vars{"A": resultValuesNoErr(makeNumber("temp", nil, float64Pointer(2.0)))},
|
||||
vars: Vars{"A": resultValuesNoErr(makeNumber("temp", nil, new(2.0)))},
|
||||
newErrIs: assert.NoError,
|
||||
execErrIs: assert.NoError,
|
||||
resultIs: assert.Equal,
|
||||
Results: resultValuesNoErr(makeNumber("", nil, float64Pointer(-1))),
|
||||
Results: resultValuesNoErr(makeNumber("", nil, new(-1.0))),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -101,20 +101,20 @@ func TestNumberExpr(t *testing.T) {
|
|||
{
|
||||
name: "binary: number Op Scalar",
|
||||
expr: "$A / $A",
|
||||
vars: Vars{"A": resultValuesNoErr(makeNumber("temp", nil, float64Pointer(2.0)))},
|
||||
vars: Vars{"A": resultValuesNoErr(makeNumber("temp", nil, new(2.0)))},
|
||||
newErrIs: assert.NoError,
|
||||
execErrIs: assert.NoError,
|
||||
resultIs: assert.Equal,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(1))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(1.0))),
|
||||
},
|
||||
{
|
||||
name: "unary: number",
|
||||
expr: "- $A",
|
||||
vars: Vars{"A": resultValuesNoErr(makeNumber("temp", nil, float64Pointer(2.0)))},
|
||||
vars: Vars{"A": resultValuesNoErr(makeNumber("temp", nil, new(2.0)))},
|
||||
newErrIs: assert.NoError,
|
||||
execErrIs: assert.NoError,
|
||||
resultIs: assert.Equal,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(-2.0))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(-2.0))),
|
||||
},
|
||||
{
|
||||
name: "binary: Scalar Op Number (Number will nil val) returns nil",
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ func TestSeriesExpr(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil, tp{ // Not sure about preservering names...
|
||||
time.Unix(5, 0), float64Pointer(1),
|
||||
time.Unix(5, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(1),
|
||||
time.Unix(10, 0), new(1.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
|
@ -41,9 +41,9 @@ func TestSeriesExpr(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil, tp{ // Not sure about preservering names...
|
||||
time.Unix(5, 0), float64Pointer(100),
|
||||
time.Unix(5, 0), new(100.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(99),
|
||||
time.Unix(10, 0), new(99.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
|
@ -55,9 +55,9 @@ func TestSeriesExpr(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil, tp{ // Not sure about preservering names...
|
||||
time.Unix(5, 0), float64Pointer(100),
|
||||
time.Unix(5, 0), new(100.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(99),
|
||||
time.Unix(10, 0), new(99.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
|
@ -69,9 +69,9 @@ func TestSeriesExpr(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil, tp{ // Not sure about preservering names...
|
||||
time.Unix(5, 0), float64Pointer(4),
|
||||
time.Unix(5, 0), new(4.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(2),
|
||||
time.Unix(10, 0), new(2.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
|
@ -83,9 +83,9 @@ func TestSeriesExpr(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", data.Labels{"id": "1"}, tp{
|
||||
time.Unix(5, 0), float64Pointer(9),
|
||||
time.Unix(5, 0), new(9.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(8),
|
||||
time.Unix(10, 0), new(8.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
|
@ -97,9 +97,9 @@ func TestSeriesExpr(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", data.Labels{"id": "1"}, tp{
|
||||
time.Unix(5, 0), float64Pointer(9),
|
||||
time.Unix(5, 0), new(9.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(8),
|
||||
time.Unix(10, 0), new(8.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
|
@ -111,14 +111,14 @@ func TestSeriesExpr(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", data.Labels{"sensor": "a", "turbine": "1"}, tp{
|
||||
time.Unix(5, 0), float64Pointer(6 * .5),
|
||||
time.Unix(5, 0), new(6 * .5),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(8 * .2),
|
||||
time.Unix(10, 0), new(8 * .2),
|
||||
}),
|
||||
makeSeries("", data.Labels{"sensor": "b", "turbine": "1"}, tp{
|
||||
time.Unix(5, 0), float64Pointer(10 * .5),
|
||||
time.Unix(5, 0), new(10 * .5),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(16 * .2),
|
||||
time.Unix(10, 0), new(16 * .2),
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
|
@ -130,16 +130,16 @@ func TestSeriesExpr(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", data.Labels{}, tp{
|
||||
time.Unix(5, 0), float64Pointer(1),
|
||||
time.Unix(5, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(2),
|
||||
time.Unix(10, 0), new(2.0),
|
||||
}),
|
||||
),
|
||||
"B": resultValuesNoErr(
|
||||
makeSeries("efficiency", data.Labels{}, tp{
|
||||
time.Unix(5, 0), float64Pointer(3),
|
||||
time.Unix(5, 0), new(3.0),
|
||||
}, tp{
|
||||
time.Unix(9, 0), float64Pointer(4),
|
||||
time.Unix(9, 0), new(4.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
|
@ -148,7 +148,7 @@ func TestSeriesExpr(t *testing.T) {
|
|||
execErrIs: assert.NoError,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil, tp{ // Not sure about preserving names...
|
||||
time.Unix(5, 0), float64Pointer(4),
|
||||
time.Unix(5, 0), new(4.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -32,22 +32,6 @@ func unixTimePointer(sec, nsec int64) *time.Time {
|
|||
return &t
|
||||
}
|
||||
|
||||
func float64Pointer(f float64) *float64 {
|
||||
return &f
|
||||
}
|
||||
|
||||
func strPointer(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
func int64Pointer(i int64) *int64 {
|
||||
return &i
|
||||
}
|
||||
|
||||
func boolPointer(b bool) *bool {
|
||||
return &b
|
||||
}
|
||||
|
||||
func resultValuesNoErr(v ...Value) Results {
|
||||
return Results{
|
||||
Values: v,
|
||||
|
|
@ -58,9 +42,9 @@ func resultValuesNoErr(v ...Value) Results {
|
|||
var aSeries = Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(2),
|
||||
time.Unix(5, 0), new(2.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(1),
|
||||
time.Unix(10, 0), new(1.),
|
||||
}),
|
||||
),
|
||||
}
|
||||
|
|
@ -68,34 +52,34 @@ var aSeries = Vars{
|
|||
var aSeriesbNumber = Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(2),
|
||||
time.Unix(5, 0), new(2.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(1),
|
||||
time.Unix(10, 0), new(1.),
|
||||
}),
|
||||
),
|
||||
"B": resultValuesNoErr(
|
||||
makeNumber("volt", data.Labels{"id": "1"}, float64Pointer(7)),
|
||||
makeNumber("volt", data.Labels{"id": "1"}, new(7.)),
|
||||
),
|
||||
}
|
||||
|
||||
var twoSeriesSets = Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", data.Labels{"sensor": "a", "turbine": "1"}, tp{
|
||||
time.Unix(5, 0), float64Pointer(6),
|
||||
time.Unix(5, 0), new(6.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(8),
|
||||
time.Unix(10, 0), new(8.),
|
||||
}),
|
||||
makeSeries("temp", data.Labels{"sensor": "b", "turbine": "1"}, tp{
|
||||
time.Unix(5, 0), float64Pointer(10),
|
||||
time.Unix(5, 0), new(10.),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(16),
|
||||
time.Unix(10, 0), new(16.),
|
||||
}),
|
||||
),
|
||||
"B": resultValuesNoErr(
|
||||
makeSeries("efficiency", data.Labels{"turbine": "1"}, tp{
|
||||
time.Unix(5, 0), float64Pointer(.5),
|
||||
time.Unix(5, 0), new(.5),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(.2),
|
||||
time.Unix(10, 0), new(.2),
|
||||
}),
|
||||
),
|
||||
}
|
||||
|
|
@ -103,4 +87,4 @@ var twoSeriesSets = Vars{
|
|||
// NaN is just to make the calls a little cleaner, the one
|
||||
// call is not for any sort of equality side effect in tests.
|
||||
// note: cmp.Equal must be used to test Equality for NaNs.
|
||||
var NaN = float64Pointer(math.NaN())
|
||||
var NaN = new(math.NaN())
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ func TestAbsFunc(t *testing.T) {
|
|||
name: "abs on number",
|
||||
expr: "abs($A)",
|
||||
vars: Vars{
|
||||
"A": resultValuesNoErr(makeNumber("", nil, float64Pointer(-7))),
|
||||
"A": resultValuesNoErr(makeNumber("", nil, new(-7.0))),
|
||||
},
|
||||
newErrIs: require.NoError,
|
||||
execErrIs: require.NoError,
|
||||
resultIs: require.Equal,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(7))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(7.0))),
|
||||
},
|
||||
{
|
||||
name: "abs on scalar",
|
||||
|
|
@ -37,7 +37,7 @@ func TestAbsFunc(t *testing.T) {
|
|||
newErrIs: require.NoError,
|
||||
execErrIs: require.NoError,
|
||||
resultIs: require.Equal,
|
||||
results: resultValuesNoErr(NewScalar("", float64Pointer(1.0))),
|
||||
results: resultValuesNoErr(NewScalar("", new(1.0))),
|
||||
},
|
||||
{
|
||||
name: "abs on series",
|
||||
|
|
@ -45,9 +45,9 @@ func TestAbsFunc(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(-2),
|
||||
time.Unix(5, 0), new(-2.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(-1),
|
||||
time.Unix(10, 0), new(-1.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
|
@ -56,9 +56,9 @@ func TestAbsFunc(t *testing.T) {
|
|||
resultIs: require.Equal,
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(2),
|
||||
time.Unix(5, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(1),
|
||||
time.Unix(10, 0), new(1.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
|
|
@ -93,9 +93,9 @@ func TestIsNumberFunc(t *testing.T) {
|
|||
name: "is_number on number type with real number value",
|
||||
expr: "is_number($A)",
|
||||
vars: Vars{
|
||||
"A": resultValuesNoErr(makeNumber("", nil, float64Pointer(6))),
|
||||
"A": resultValuesNoErr(makeNumber("", nil, new(6.0))),
|
||||
},
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(1))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(1.0))),
|
||||
},
|
||||
{
|
||||
name: "is_number on number type with null value",
|
||||
|
|
@ -103,7 +103,7 @@ func TestIsNumberFunc(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(makeNumber("", nil, nil)),
|
||||
},
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(0))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(0.0))),
|
||||
},
|
||||
{
|
||||
name: "is_number on on series",
|
||||
|
|
@ -111,20 +111,20 @@ func TestIsNumberFunc(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("", nil,
|
||||
tp{time.Unix(5, 0), float64Pointer(5)},
|
||||
tp{time.Unix(5, 0), new(5.0)},
|
||||
tp{time.Unix(10, 0), nil},
|
||||
tp{time.Unix(15, 0), float64Pointer(math.NaN())},
|
||||
tp{time.Unix(20, 0), float64Pointer(math.Inf(-1))},
|
||||
tp{time.Unix(25, 0), float64Pointer(math.Inf(0))}),
|
||||
tp{time.Unix(15, 0), new(math.NaN())},
|
||||
tp{time.Unix(20, 0), new(math.Inf(-1))},
|
||||
tp{time.Unix(25, 0), new(math.Inf(0))}),
|
||||
),
|
||||
},
|
||||
results: resultValuesNoErr(
|
||||
makeSeries("", nil,
|
||||
tp{time.Unix(5, 0), float64Pointer(1)},
|
||||
tp{time.Unix(10, 0), float64Pointer(0)},
|
||||
tp{time.Unix(15, 0), float64Pointer(0)},
|
||||
tp{time.Unix(20, 0), float64Pointer(0)},
|
||||
tp{time.Unix(25, 0), float64Pointer(0)}),
|
||||
tp{time.Unix(5, 0), new(1.0)},
|
||||
tp{time.Unix(10, 0), new(0.0)},
|
||||
tp{time.Unix(15, 0), new(0.0)},
|
||||
tp{time.Unix(20, 0), new(0.0)},
|
||||
tp{time.Unix(25, 0), new(0.0)}),
|
||||
),
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import (
|
|||
var seriesWithNil = Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(2),
|
||||
time.Unix(5, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), nil,
|
||||
}),
|
||||
|
|
@ -53,7 +53,7 @@ func TestSeriesReduce(t *testing.T) {
|
|||
vars: aSeries,
|
||||
errIs: require.NoError,
|
||||
resultsIs: require.Equal,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(3))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(3.0))),
|
||||
},
|
||||
{
|
||||
name: "sum series with a nil value",
|
||||
|
|
@ -71,7 +71,7 @@ func TestSeriesReduce(t *testing.T) {
|
|||
vars: seriesEmpty,
|
||||
errIs: require.NoError,
|
||||
resultsIs: require.Equal,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(0))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(0.0))),
|
||||
},
|
||||
{
|
||||
name: "mean series with a nil value",
|
||||
|
|
@ -116,15 +116,15 @@ func TestSeriesReduce(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(20),
|
||||
time.Unix(5, 0), new(20.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(10),
|
||||
time.Unix(10, 0), new(10.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
errIs: require.NoError,
|
||||
resultsIs: require.Equal,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(15))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(15.0))),
|
||||
},
|
||||
{
|
||||
name: "median series odd number of elements",
|
||||
|
|
@ -133,17 +133,17 @@ func TestSeriesReduce(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(20),
|
||||
time.Unix(5, 0), new(20.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(10),
|
||||
time.Unix(10, 0), new(10.0),
|
||||
}, tp{
|
||||
time.Unix(15, 0), float64Pointer(5),
|
||||
time.Unix(15, 0), new(5.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
errIs: require.NoError,
|
||||
resultsIs: require.Equal,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(10))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(10.0))),
|
||||
},
|
||||
{
|
||||
name: "median series with repeated values",
|
||||
|
|
@ -152,17 +152,17 @@ func TestSeriesReduce(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(5),
|
||||
time.Unix(5, 0), new(5.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(5),
|
||||
time.Unix(10, 0), new(5.0),
|
||||
}, tp{
|
||||
time.Unix(15, 0), float64Pointer(5),
|
||||
time.Unix(15, 0), new(5.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
errIs: require.NoError,
|
||||
resultsIs: require.Equal,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(5))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(5.0))),
|
||||
},
|
||||
{
|
||||
name: "median series with negative values",
|
||||
|
|
@ -171,19 +171,19 @@ func TestSeriesReduce(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(-1),
|
||||
time.Unix(5, 0), new(-1.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(-3),
|
||||
time.Unix(10, 0), new(-3.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(-4),
|
||||
time.Unix(10, 0), new(-4.0),
|
||||
}, tp{
|
||||
time.Unix(15, 0), float64Pointer(-2),
|
||||
time.Unix(15, 0), new(-2.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
errIs: require.NoError,
|
||||
resultsIs: require.Equal,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(-2.5))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(-2.5))),
|
||||
},
|
||||
{
|
||||
name: "min series with a nil value",
|
||||
|
|
@ -228,7 +228,7 @@ func TestSeriesReduce(t *testing.T) {
|
|||
vars: aSeries,
|
||||
errIs: require.NoError,
|
||||
resultsIs: require.Equal,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(1.5))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(1.5))),
|
||||
},
|
||||
{
|
||||
name: "count empty series",
|
||||
|
|
@ -237,7 +237,7 @@ func TestSeriesReduce(t *testing.T) {
|
|||
vars: seriesEmpty,
|
||||
errIs: require.NoError,
|
||||
resultsIs: require.Equal,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(0))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(0.0))),
|
||||
},
|
||||
{
|
||||
name: "mean series with labels",
|
||||
|
|
@ -246,15 +246,15 @@ func TestSeriesReduce(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", data.Labels{"host": "a"}, tp{
|
||||
time.Unix(5, 0), float64Pointer(2),
|
||||
time.Unix(5, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(1),
|
||||
time.Unix(10, 0), new(1.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
errIs: require.NoError,
|
||||
resultsIs: require.Equal,
|
||||
results: resultValuesNoErr(makeNumber("", data.Labels{"host": "a"}, float64Pointer(1.5))),
|
||||
results: resultValuesNoErr(makeNumber("", data.Labels{"host": "a"}, new(1.5))),
|
||||
},
|
||||
{
|
||||
name: "last empty series",
|
||||
|
|
@ -303,8 +303,8 @@ var seriesNonNumbers = Vars{
|
|||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", nil,
|
||||
tp{time.Unix(5, 0), NaN},
|
||||
tp{time.Unix(10, 0), float64Pointer(math.Inf(-1))},
|
||||
tp{time.Unix(15, 0), float64Pointer(math.Inf(1))},
|
||||
tp{time.Unix(10, 0), new(math.Inf(-1))},
|
||||
tp{time.Unix(15, 0), new(math.Inf(1))},
|
||||
tp{time.Unix(15, 0), nil}),
|
||||
),
|
||||
}
|
||||
|
|
@ -322,28 +322,28 @@ func TestSeriesReduceDropNN(t *testing.T) {
|
|||
red: "sum",
|
||||
varToReduce: "A",
|
||||
vars: aSeries,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(3))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(3.0))),
|
||||
},
|
||||
{
|
||||
name: "dropNN: sum series with a nil value",
|
||||
red: "sum",
|
||||
varToReduce: "A",
|
||||
vars: seriesWithNil,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(2))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(2.0))),
|
||||
},
|
||||
{
|
||||
name: "dropNN: sum empty series",
|
||||
red: "sum",
|
||||
varToReduce: "A",
|
||||
vars: seriesEmpty,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(0))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(0.0))),
|
||||
},
|
||||
{
|
||||
name: "dropNN: mean series with a nil value and real value",
|
||||
red: "mean",
|
||||
varToReduce: "A",
|
||||
vars: seriesWithNil,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(2))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(2.0))),
|
||||
},
|
||||
{
|
||||
name: "DropNN: mean empty series",
|
||||
|
|
@ -357,7 +357,7 @@ func TestSeriesReduceDropNN(t *testing.T) {
|
|||
red: "median",
|
||||
varToReduce: "A",
|
||||
vars: seriesWithNil,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(2))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(2.0))),
|
||||
},
|
||||
{
|
||||
name: "DropNN: median empty series",
|
||||
|
|
@ -385,14 +385,14 @@ func TestSeriesReduceDropNN(t *testing.T) {
|
|||
red: "count",
|
||||
varToReduce: "A",
|
||||
vars: seriesEmpty,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(0))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(0.0))),
|
||||
},
|
||||
{
|
||||
name: "DropNN: count series with nil and value should only count real numbers",
|
||||
red: "count",
|
||||
varToReduce: "A",
|
||||
vars: seriesWithNil,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(1))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(1.0))),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -430,42 +430,42 @@ func TestSeriesReduceReplaceNN(t *testing.T) {
|
|||
red: "sum",
|
||||
varToReduce: "A",
|
||||
vars: aSeries,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(3))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(3.0))),
|
||||
},
|
||||
{
|
||||
name: "replaceNN: sum series with a nil value",
|
||||
red: "sum",
|
||||
varToReduce: "A",
|
||||
vars: seriesWithNil,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(replaceWith+2))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(replaceWith+2))),
|
||||
},
|
||||
{
|
||||
name: "replaceNN: sum empty series",
|
||||
red: "sum",
|
||||
varToReduce: "A",
|
||||
vars: seriesEmpty,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(0))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(0.0))),
|
||||
},
|
||||
{
|
||||
name: "replaceNN: mean series with a nil value and real value",
|
||||
red: "mean",
|
||||
varToReduce: "A",
|
||||
vars: seriesWithNil,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer((2+replaceWith)/2e0))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new((2+replaceWith)/2e0))),
|
||||
},
|
||||
{
|
||||
name: "replaceNN: mean empty series",
|
||||
red: "mean",
|
||||
varToReduce: "A",
|
||||
vars: seriesEmpty,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(replaceWith))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(replaceWith))),
|
||||
},
|
||||
{
|
||||
name: "replaceNN: mean series that becomes empty after filtering non-number",
|
||||
red: "mean",
|
||||
varToReduce: "A",
|
||||
vars: seriesNonNumbers,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(replaceWith))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(replaceWith))),
|
||||
},
|
||||
{
|
||||
name: "replaceNN: median series with a nil value and real value",
|
||||
|
|
@ -474,16 +474,16 @@ func TestSeriesReduceReplaceNN(t *testing.T) {
|
|||
vars: Vars{
|
||||
"A": resultValuesNoErr(
|
||||
makeSeries("temp", nil, tp{
|
||||
time.Unix(5, 0), float64Pointer(2),
|
||||
time.Unix(5, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), nil,
|
||||
}, tp{
|
||||
time.Unix(15, 0), float64Pointer(5),
|
||||
time.Unix(15, 0), new(5.0),
|
||||
}),
|
||||
),
|
||||
},
|
||||
results: resultValuesNoErr(
|
||||
makeNumber("", nil, float64Pointer(
|
||||
makeNumber("", nil, new(
|
||||
sortedFloat64([]float64{2, 5, replaceWith})[1]),
|
||||
),
|
||||
),
|
||||
|
|
@ -493,28 +493,28 @@ func TestSeriesReduceReplaceNN(t *testing.T) {
|
|||
red: "median",
|
||||
varToReduce: "A",
|
||||
vars: seriesEmpty,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(replaceWith))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(replaceWith))),
|
||||
},
|
||||
{
|
||||
name: "replaceNN: median series that becomes empty after filtering non-number",
|
||||
red: "median",
|
||||
varToReduce: "A",
|
||||
vars: seriesNonNumbers,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(replaceWith))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(replaceWith))),
|
||||
},
|
||||
{
|
||||
name: "replaceNN: count empty series",
|
||||
red: "count",
|
||||
varToReduce: "A",
|
||||
vars: seriesEmpty,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(0))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(0.0))),
|
||||
},
|
||||
{
|
||||
name: "replaceNN: count series with nil and value should only count real numbers",
|
||||
red: "count",
|
||||
varToReduce: "A",
|
||||
vars: seriesWithNil,
|
||||
results: resultValuesNoErr(makeNumber("", nil, float64Pointer(2))),
|
||||
results: resultValuesNoErr(makeNumber("", nil, new(2.0))),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ func TestResampleSeries(t *testing.T) {
|
|||
To: time.Unix(4, 0),
|
||||
},
|
||||
seriesToResample: makeSeries("", nil, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(7, 0), float64Pointer(1),
|
||||
time.Unix(7, 0), new(1.0),
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
|
@ -46,9 +46,9 @@ func TestResampleSeries(t *testing.T) {
|
|||
To: time.Unix(0, 0),
|
||||
},
|
||||
seriesToResample: makeSeries("", nil, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(7, 0), float64Pointer(1),
|
||||
time.Unix(7, 0), new(1.0),
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
|
@ -61,22 +61,22 @@ func TestResampleSeries(t *testing.T) {
|
|||
To: time.Unix(16, 0),
|
||||
},
|
||||
seriesToResample: makeSeries("", nil, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(4, 0), float64Pointer(3),
|
||||
time.Unix(4, 0), new(3.0),
|
||||
}, tp{
|
||||
time.Unix(7, 0), float64Pointer(1),
|
||||
time.Unix(7, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(9, 0), float64Pointer(2),
|
||||
time.Unix(9, 0), new(2.0),
|
||||
}),
|
||||
series: makeSeries("", nil, tp{
|
||||
time.Unix(0, 0), nil,
|
||||
}, tp{
|
||||
time.Unix(5, 0), float64Pointer(2.5),
|
||||
time.Unix(5, 0), new(2.5),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(1.5),
|
||||
time.Unix(10, 0), new(1.5),
|
||||
}, tp{
|
||||
time.Unix(15, 0), float64Pointer(2),
|
||||
time.Unix(15, 0), new(2.0),
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
|
@ -89,20 +89,20 @@ func TestResampleSeries(t *testing.T) {
|
|||
To: time.Unix(16, 0),
|
||||
},
|
||||
seriesToResample: makeSeries("", nil, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(4, 0), float64Pointer(3),
|
||||
time.Unix(4, 0), new(3.0),
|
||||
}, tp{
|
||||
time.Unix(7, 0), float64Pointer(1),
|
||||
time.Unix(7, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(9, 0), float64Pointer(2),
|
||||
time.Unix(9, 0), new(2.0),
|
||||
}),
|
||||
series: makeSeries("", nil, tp{
|
||||
time.Unix(0, 0), nil,
|
||||
}, tp{
|
||||
time.Unix(5, 0), float64Pointer(3),
|
||||
time.Unix(5, 0), new(3.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(2),
|
||||
time.Unix(10, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(15, 0), nil,
|
||||
}),
|
||||
|
|
@ -117,20 +117,20 @@ func TestResampleSeries(t *testing.T) {
|
|||
To: time.Unix(16, 0),
|
||||
},
|
||||
seriesToResample: makeSeries("", nil, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(4, 0), float64Pointer(3),
|
||||
time.Unix(4, 0), new(3.0),
|
||||
}, tp{
|
||||
time.Unix(7, 0), float64Pointer(1),
|
||||
time.Unix(7, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(9, 0), float64Pointer(2),
|
||||
time.Unix(9, 0), new(2.0),
|
||||
}),
|
||||
series: makeSeries("", nil, tp{
|
||||
time.Unix(0, 0), nil,
|
||||
}, tp{
|
||||
time.Unix(5, 0), float64Pointer(2),
|
||||
time.Unix(5, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(1),
|
||||
time.Unix(10, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(15, 0), nil,
|
||||
}),
|
||||
|
|
@ -145,20 +145,20 @@ func TestResampleSeries(t *testing.T) {
|
|||
To: time.Unix(16, 0),
|
||||
},
|
||||
seriesToResample: makeSeries("", nil, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(4, 0), float64Pointer(3),
|
||||
time.Unix(4, 0), new(3.0),
|
||||
}, tp{
|
||||
time.Unix(7, 0), float64Pointer(1),
|
||||
time.Unix(7, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(9, 0), float64Pointer(2),
|
||||
time.Unix(9, 0), new(2.0),
|
||||
}),
|
||||
series: makeSeries("", nil, tp{
|
||||
time.Unix(0, 0), nil,
|
||||
}, tp{
|
||||
time.Unix(5, 0), float64Pointer(5),
|
||||
time.Unix(5, 0), new(5.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(3),
|
||||
time.Unix(10, 0), new(3.0),
|
||||
}, tp{
|
||||
time.Unix(15, 0), nil,
|
||||
}),
|
||||
|
|
@ -173,20 +173,20 @@ func TestResampleSeries(t *testing.T) {
|
|||
To: time.Unix(16, 0),
|
||||
},
|
||||
seriesToResample: makeSeries("", nil, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(4, 0), float64Pointer(3),
|
||||
time.Unix(4, 0), new(3.0),
|
||||
}, tp{
|
||||
time.Unix(7, 0), float64Pointer(1),
|
||||
time.Unix(7, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(9, 0), float64Pointer(2),
|
||||
time.Unix(9, 0), new(2.0),
|
||||
}),
|
||||
series: makeSeries("", nil, tp{
|
||||
time.Unix(0, 0), nil,
|
||||
}, tp{
|
||||
time.Unix(5, 0), float64Pointer(2.5),
|
||||
time.Unix(5, 0), new(2.5),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(1.5),
|
||||
time.Unix(10, 0), new(1.5),
|
||||
}, tp{
|
||||
time.Unix(15, 0), nil,
|
||||
}),
|
||||
|
|
@ -201,22 +201,22 @@ func TestResampleSeries(t *testing.T) {
|
|||
To: time.Unix(11, 0),
|
||||
},
|
||||
seriesToResample: makeSeries("", nil, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(7, 0), float64Pointer(1),
|
||||
time.Unix(7, 0), new(1.0),
|
||||
}),
|
||||
series: makeSeries("", nil, tp{
|
||||
time.Unix(0, 0), nil,
|
||||
}, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(4, 0), float64Pointer(2),
|
||||
time.Unix(4, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(6, 0), float64Pointer(2),
|
||||
time.Unix(6, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(8, 0), float64Pointer(1),
|
||||
time.Unix(8, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(1),
|
||||
time.Unix(10, 0), new(1.0),
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
|
@ -229,20 +229,20 @@ func TestResampleSeries(t *testing.T) {
|
|||
To: time.Unix(11, 0),
|
||||
},
|
||||
seriesToResample: makeSeries("", nil, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(7, 0), float64Pointer(1),
|
||||
time.Unix(7, 0), new(1.0),
|
||||
}),
|
||||
series: makeSeries("", nil, tp{
|
||||
time.Unix(0, 0), float64Pointer(2),
|
||||
time.Unix(0, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(4, 0), float64Pointer(1),
|
||||
time.Unix(4, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(6, 0), float64Pointer(1),
|
||||
time.Unix(6, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(8, 0), float64Pointer(1),
|
||||
time.Unix(8, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), nil,
|
||||
}),
|
||||
|
|
@ -257,26 +257,26 @@ func TestResampleSeries(t *testing.T) {
|
|||
To: time.Unix(11, 0),
|
||||
},
|
||||
seriesToResample: makeSeries("", nil, tp{
|
||||
time.Unix(0, 0), float64Pointer(0),
|
||||
time.Unix(0, 0), new(0.0),
|
||||
}, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(4, 0), float64Pointer(3),
|
||||
time.Unix(4, 0), new(3.0),
|
||||
}, tp{
|
||||
time.Unix(6, 0), float64Pointer(4),
|
||||
time.Unix(6, 0), new(4.0),
|
||||
}, tp{
|
||||
time.Unix(8, 0), float64Pointer(0),
|
||||
time.Unix(8, 0), new(0.0),
|
||||
}, tp{
|
||||
time.Unix(10, 0), float64Pointer(1),
|
||||
time.Unix(10, 0), new(1.0),
|
||||
}),
|
||||
series: makeSeries("", nil, tp{
|
||||
time.Unix(0, 0), float64Pointer(0),
|
||||
time.Unix(0, 0), new(0.0),
|
||||
}, tp{
|
||||
time.Unix(3, 0), float64Pointer(2),
|
||||
time.Unix(3, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(6, 0), float64Pointer(4),
|
||||
time.Unix(6, 0), new(4.0),
|
||||
}, tp{
|
||||
time.Unix(9, 0), float64Pointer(0),
|
||||
time.Unix(9, 0), new(0.0),
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
|
@ -289,9 +289,9 @@ func TestResampleSeries(t *testing.T) {
|
|||
To: time.Unix(11, 0),
|
||||
},
|
||||
seriesToResample: makeSeries("", nil, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(7, 0), float64Pointer(1),
|
||||
time.Unix(7, 0), new(1.0),
|
||||
}),
|
||||
series: Series{},
|
||||
expectedError: fmt.Sprintf("Resample series length to large, max allowed %d, wanted 11000000", MaxNewSeriesLength),
|
||||
|
|
|
|||
|
|
@ -22,38 +22,38 @@ func TestSeriesSort(t *testing.T) {
|
|||
name: "unordered series should sort by time ascending",
|
||||
descending: false,
|
||||
series: makeSeries("", nil, tp{
|
||||
time.Unix(3, 0), float64Pointer(3),
|
||||
time.Unix(3, 0), new(3.0),
|
||||
}, tp{
|
||||
time.Unix(1, 0), float64Pointer(1),
|
||||
time.Unix(1, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}),
|
||||
sortedSeriesIs: assert.Equal,
|
||||
sortedSeries: makeSeries("", nil, tp{
|
||||
time.Unix(1, 0), float64Pointer(1),
|
||||
time.Unix(1, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(3, 0), float64Pointer(3),
|
||||
time.Unix(3, 0), new(3.0),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "unordered series should sort by time descending",
|
||||
descending: true,
|
||||
series: makeSeries("", nil, tp{
|
||||
time.Unix(3, 0), float64Pointer(3),
|
||||
time.Unix(3, 0), new(3.0),
|
||||
}, tp{
|
||||
time.Unix(1, 0), float64Pointer(1),
|
||||
time.Unix(1, 0), new(1.0),
|
||||
}, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}),
|
||||
sortedSeriesIs: assert.Equal,
|
||||
sortedSeries: makeSeries("", nil, tp{
|
||||
time.Unix(3, 0), float64Pointer(3),
|
||||
time.Unix(3, 0), new(3.0),
|
||||
}, tp{
|
||||
time.Unix(2, 0), float64Pointer(2),
|
||||
time.Unix(2, 0), new(2.0),
|
||||
}, tp{
|
||||
time.Unix(1, 0), float64Pointer(1),
|
||||
time.Unix(1, 0), new(1.0),
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []time.Time{time.Unix(5, 0)}),
|
||||
data.NewField("value", nil, []*float64{float64Pointer(5)}),
|
||||
data.NewField("value", nil, []*float64{new(5.0)}),
|
||||
},
|
||||
},
|
||||
errIs: assert.NoError,
|
||||
|
|
@ -107,7 +107,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
Frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []time.Time{time.Unix(5, 0)}),
|
||||
data.NewField("value", nil, []*float64{float64Pointer(5)}),
|
||||
data.NewField("value", nil, []*float64{new(5.0)}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -116,7 +116,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
name: "[]*float, []time frame should convert",
|
||||
frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("value", nil, []*float64{float64Pointer(5)}),
|
||||
data.NewField("value", nil, []*float64{new(5.0)}),
|
||||
data.NewField("time", nil, []time.Time{time.Unix(5, 0)}),
|
||||
},
|
||||
},
|
||||
|
|
@ -126,7 +126,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
Frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []time.Time{time.Unix(5, 0)}),
|
||||
data.NewField("value", nil, []*float64{float64Pointer(5)}),
|
||||
data.NewField("value", nil, []*float64{new(5.0)}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -136,7 +136,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []*time.Time{unixTimePointer(5, 0)}),
|
||||
data.NewField("value", nil, []*int64{int64Pointer(5)}),
|
||||
data.NewField("value", nil, []*int64{new(int64(5))}),
|
||||
},
|
||||
},
|
||||
errIs: assert.NoError,
|
||||
|
|
@ -145,7 +145,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
Frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []time.Time{time.Unix(5, 0)}),
|
||||
data.NewField("value", nil, []*float64{float64Pointer(5)}),
|
||||
data.NewField("value", nil, []*float64{new(5.0)}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -164,7 +164,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
Frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []time.Time{time.Unix(5, 0)}),
|
||||
data.NewField("value", nil, []*float64{float64Pointer(5)}),
|
||||
data.NewField("value", nil, []*float64{new(5.0)}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -183,7 +183,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
Frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []time.Time{time.Unix(5, 0)}),
|
||||
data.NewField("value", nil, []*float64{float64Pointer(5)}),
|
||||
data.NewField("value", nil, []*float64{new(5.0)}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -193,7 +193,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []*time.Time{unixTimePointer(5, 0)}),
|
||||
data.NewField("value", nil, []*string{strPointer("5")}),
|
||||
data.NewField("value", nil, []*string{new("5")}),
|
||||
},
|
||||
},
|
||||
errIs: assert.NoError,
|
||||
|
|
@ -202,7 +202,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
Frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []time.Time{time.Unix(5, 0)}),
|
||||
data.NewField("value", nil, []*float64{float64Pointer(5)}),
|
||||
data.NewField("value", nil, []*float64{new(5.0)}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -221,7 +221,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
Frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []time.Time{time.Unix(5, 0)}),
|
||||
data.NewField("value", nil, []*float64{float64Pointer(1)}),
|
||||
data.NewField("value", nil, []*float64{new(1.0)}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -231,7 +231,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []*time.Time{unixTimePointer(5, 0)}),
|
||||
data.NewField("value", nil, []*bool{boolPointer(true)}),
|
||||
data.NewField("value", nil, []*bool{new(true)}),
|
||||
},
|
||||
},
|
||||
errIs: assert.NoError,
|
||||
|
|
@ -240,7 +240,7 @@ func TestSeriesFromFrame(t *testing.T) {
|
|||
Frame: &data.Frame{
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []time.Time{time.Unix(5, 0)}),
|
||||
data.NewField("value", nil, []*float64{float64Pointer(1)}),
|
||||
data.NewField("value", nil, []*float64{new(1.0)}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func TestMLNodeExecute(t *testing.T) {
|
|||
|
||||
cmdResponse := data.NewFrame("test",
|
||||
data.NewField("Time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("Value", nil, []*float64{fp(1)}),
|
||||
data.NewField("Value", nil, []*float64{new(1.0)}),
|
||||
)
|
||||
|
||||
cmd := &ml.FakeCommand{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import (
|
|||
func TestSQLService(t *testing.T) {
|
||||
inputFrame := data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("value", nil, []*float64{fp(2)}),
|
||||
data.NewField("value", nil, []*float64{new(2.0)}),
|
||||
)
|
||||
|
||||
resp := map[string]backend.DataResponse{
|
||||
|
|
@ -122,12 +122,12 @@ func TestSQLService(t *testing.T) {
|
|||
func TestSQLServiceErrors(t *testing.T) {
|
||||
tsMulti := data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("value", data.Labels{"testLabelKey": "testLabelValue"}, []*float64{fp(2)}),
|
||||
data.NewField("value", data.Labels{"testLabelKey": "testLabelValue"}, []*float64{new(2.0)}),
|
||||
).SetMeta(&data.FrameMeta{Type: data.FrameTypeTimeSeriesMulti})
|
||||
|
||||
tsMultiNoType := data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("value", data.Labels{"testLabelKey": "testLabelValue"}, []*float64{fp(2)}),
|
||||
data.NewField("value", data.Labels{"testLabelKey": "testLabelValue"}, []*float64{new(2.0)}),
|
||||
)
|
||||
|
||||
resp := map[string]backend.DataResponse{
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import (
|
|||
func TestService(t *testing.T) {
|
||||
dsDF := data.NewFrame("test",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("value", data.Labels{"test": "label"}, []*float64{fp(2)}),
|
||||
data.NewField("value", data.Labels{"test": "label"}, []*float64{new(2.0)}),
|
||||
)
|
||||
|
||||
resp := map[string]backend.DataResponse{
|
||||
|
|
@ -71,7 +71,7 @@ func TestService(t *testing.T) {
|
|||
|
||||
bDF := data.NewFrame("",
|
||||
data.NewField("Time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("B", data.Labels{"test": "label"}, []*float64{fp(4)}))
|
||||
data.NewField("B", data.Labels{"test": "label"}, []*float64{new(4.0)}))
|
||||
bDF.RefID = "B"
|
||||
bDF.SetMeta(&data.FrameMeta{
|
||||
Type: data.FrameTypeTimeSeriesMulti,
|
||||
|
|
@ -147,7 +147,7 @@ func TestDSQueryError(t *testing.T) {
|
|||
require.ErrorContains(t, res.Responses["A"].Error, "womp womp")
|
||||
require.ErrorAs(t, res.Responses["B"].Error, &utilErr)
|
||||
require.ErrorIs(t, utilErr, DependencyError)
|
||||
require.Equal(t, fp(42), res.Responses["C"].Frames[0].Fields[0].At(0))
|
||||
require.Equal(t, new(42.0), res.Responses["C"].Frames[0].Fields[0].At(0))
|
||||
}
|
||||
|
||||
func TestParseError(t *testing.T) {
|
||||
|
|
@ -235,10 +235,6 @@ func TestSQLExpressionCellLimitFromConfig(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func fp(f float64) *float64 {
|
||||
return &f
|
||||
}
|
||||
|
||||
type mockEndpoint struct {
|
||||
Responses map[string]backend.DataResponse
|
||||
}
|
||||
|
|
@ -296,7 +292,7 @@ func newMockQueryServiceWithMetricsRegistry(
|
|||
func TestTransformDataDegradedPipeline(t *testing.T) {
|
||||
dsDF := data.NewFrame("test",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("value", data.Labels{"test": "label"}, []*float64{fp(2)}),
|
||||
data.NewField("value", data.Labels{"test": "label"}, []*float64{new(2.0)}),
|
||||
)
|
||||
|
||||
t.Run("returns partial results for broken expressions", func(t *testing.T) {
|
||||
|
|
@ -409,7 +405,7 @@ func TestTransformDataDegradedHiddenBrokenNode(t *testing.T) {
|
|||
setupOpenFeatureFlag(t, featuremgmt.FlagSseExpressionErrorIsolation, true)
|
||||
dsDF := data.NewFrame("test",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("value", data.Labels{"test": "label"}, []*float64{fp(2)}),
|
||||
data.NewField("value", data.Labels{"test": "label"}, []*float64{new(2.0)}),
|
||||
)
|
||||
|
||||
me := &mockEndpoint{
|
||||
|
|
|
|||
|
|
@ -81,46 +81,46 @@ func TestQueryFramesInOut(t *testing.T) {
|
|||
Name: "a",
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []time.Time{time.Date(2025, 1, 2, 3, 4, 5, 0, time.UTC), time.Date(2025, 1, 2, 3, 4, 5, 0, time.UTC)}),
|
||||
data.NewField("time_nullable", nil, []*time.Time{p(time.Date(2025, 1, 2, 3, 4, 5, 0, time.UTC)), nil}),
|
||||
data.NewField("time_nullable", nil, []*time.Time{new(time.Date(2025, 1, 2, 3, 4, 5, 0, time.UTC)), nil}),
|
||||
|
||||
data.NewField("string", nil, []string{"cat", "dog"}),
|
||||
data.NewField("null_nullable", nil, []*string{p("cat"), nil}),
|
||||
data.NewField("null_nullable", nil, []*string{new("cat"), nil}),
|
||||
|
||||
data.NewField("bool", nil, []bool{true, false}),
|
||||
data.NewField("bool_nullable", nil, []*bool{p(true), nil}),
|
||||
data.NewField("bool_nullable", nil, []*bool{new(true), nil}),
|
||||
|
||||
// Floats
|
||||
data.NewField("float32", nil, []float32{1, 3}),
|
||||
data.NewField("float32_nullable", nil, []*float32{p(float32(2.0)), nil}),
|
||||
data.NewField("float32_nullable", nil, []*float32{new(float32(2.0)), nil}),
|
||||
|
||||
data.NewField("float64", nil, []float64{1, 3}),
|
||||
data.NewField("float64_nullable", nil, []*float64{p(float64(2.0)), nil}),
|
||||
data.NewField("float64_nullable", nil, []*float64{new(float64(2.0)), nil}),
|
||||
|
||||
// Ints
|
||||
data.NewField("int8", nil, []int8{1, 3}),
|
||||
data.NewField("int8_nullable", nil, []*int8{p(int8(2)), nil}),
|
||||
data.NewField("int8_nullable", nil, []*int8{new(int8(2)), nil}),
|
||||
|
||||
data.NewField("int16", nil, []int16{1, 3}),
|
||||
data.NewField("int16_nullable", nil, []*int16{p(int16(2)), nil}),
|
||||
data.NewField("int16_nullable", nil, []*int16{new(int16(2)), nil}),
|
||||
|
||||
data.NewField("int32", nil, []int32{1, 3}),
|
||||
data.NewField("int32_nullable", nil, []*int32{p(int32(2)), nil}),
|
||||
data.NewField("int32_nullable", nil, []*int32{new(int32(2)), nil}),
|
||||
|
||||
data.NewField("int64", nil, []int64{1, 3}),
|
||||
data.NewField("int64_nullable", nil, []*int64{p(int64(2)), nil}),
|
||||
data.NewField("int64_nullable", nil, []*int64{new(int64(2)), nil}),
|
||||
|
||||
// Unsigned Ints
|
||||
data.NewField("uint8", nil, []uint8{1, 3}),
|
||||
data.NewField("uint8_nullable", nil, []*uint8{p(uint8(2)), nil}),
|
||||
data.NewField("uint8_nullable", nil, []*uint8{new(uint8(2)), nil}),
|
||||
|
||||
data.NewField("uint16", nil, []uint16{1, 3}),
|
||||
data.NewField("uint16_nullable", nil, []*uint16{p(uint16(2)), nil}),
|
||||
data.NewField("uint16_nullable", nil, []*uint16{new(uint16(2)), nil}),
|
||||
|
||||
data.NewField("uint32", nil, []uint32{1, 3}),
|
||||
data.NewField("uint32_nullable", nil, []*uint32{p(uint32(2)), nil}),
|
||||
data.NewField("uint32_nullable", nil, []*uint32{new(uint32(2)), nil}),
|
||||
|
||||
data.NewField("uint64", nil, []uint64{1, 3}),
|
||||
data.NewField("uint64_nullable", nil, []*uint64{p(uint64(2)), nil}),
|
||||
data.NewField("uint64_nullable", nil, []*uint64{new(uint64(2)), nil}),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -130,46 +130,46 @@ func TestQueryFramesInOut(t *testing.T) {
|
|||
Name: "b",
|
||||
Fields: []*data.Field{
|
||||
data.NewField("time", nil, []time.Time{time.Date(2025, 1, 2, 3, 4, 5, 0, time.UTC), time.Date(2025, 1, 2, 3, 4, 5, 0, time.UTC)}),
|
||||
data.NewField("time_nullable", nil, []*time.Time{p(time.Date(2025, 1, 2, 3, 4, 5, 0, time.UTC)), nil}),
|
||||
data.NewField("time_nullable", nil, []*time.Time{new(time.Date(2025, 1, 2, 3, 4, 5, 0, time.UTC)), nil}),
|
||||
|
||||
data.NewField("string", nil, []string{"cat", "dog"}),
|
||||
data.NewField("null_nullable", nil, []*string{p("cat"), nil}),
|
||||
data.NewField("null_nullable", nil, []*string{new("cat"), nil}),
|
||||
|
||||
data.NewField("bool", nil, []bool{true, false}),
|
||||
data.NewField("bool_nullable", nil, []*bool{p(true), nil}),
|
||||
data.NewField("bool_nullable", nil, []*bool{new(true), nil}),
|
||||
|
||||
// Floats
|
||||
data.NewField("float32", nil, []*float32{p(float32(1)), p(float32(3))}),
|
||||
data.NewField("float32_nullable", nil, []*float32{p(float32(2.0)), nil}),
|
||||
data.NewField("float32", nil, []*float32{new(float32(1)), new(float32(3))}),
|
||||
data.NewField("float32_nullable", nil, []*float32{new(float32(2.0)), nil}),
|
||||
|
||||
data.NewField("float64", nil, []*float64{p(float64(1)), p(float64(3))}),
|
||||
data.NewField("float64_nullable", nil, []*float64{p(float64(2.0)), nil}),
|
||||
data.NewField("float64", nil, []*float64{new(float64(1)), new(float64(3))}),
|
||||
data.NewField("float64_nullable", nil, []*float64{new(float64(2.0)), nil}),
|
||||
|
||||
// Ints
|
||||
data.NewField("int8", nil, []int8{1, 3}),
|
||||
data.NewField("int8_nullable", nil, []*int8{p(int8(2)), nil}),
|
||||
data.NewField("int8_nullable", nil, []*int8{new(int8(2)), nil}),
|
||||
|
||||
data.NewField("int16", nil, []int16{1, 3}),
|
||||
data.NewField("int16_nullable", nil, []*int16{p(int16(2)), nil}),
|
||||
data.NewField("int16_nullable", nil, []*int16{new(int16(2)), nil}),
|
||||
|
||||
data.NewField("int32", nil, []int32{1, 3}),
|
||||
data.NewField("int32_nullable", nil, []*int32{p(int32(2)), nil}),
|
||||
data.NewField("int32_nullable", nil, []*int32{new(int32(2)), nil}),
|
||||
|
||||
data.NewField("int64", nil, []int64{1, 3}),
|
||||
data.NewField("int64_nullable", nil, []*int64{p(int64(2)), nil}),
|
||||
data.NewField("int64_nullable", nil, []*int64{new(int64(2)), nil}),
|
||||
|
||||
// Unsigned Ints
|
||||
data.NewField("uint8", nil, []uint8{1, 3}),
|
||||
data.NewField("uint8_nullable", nil, []*uint8{p(uint8(2)), nil}),
|
||||
data.NewField("uint8_nullable", nil, []*uint8{new(uint8(2)), nil}),
|
||||
|
||||
data.NewField("uint16", nil, []uint16{1, 3}),
|
||||
data.NewField("uint16_nullable", nil, []*uint16{p(uint16(2)), nil}),
|
||||
data.NewField("uint16_nullable", nil, []*uint16{new(uint16(2)), nil}),
|
||||
|
||||
data.NewField("uint32", nil, []uint32{1, 3}),
|
||||
data.NewField("uint32_nullable", nil, []*uint32{p(uint32(2)), nil}),
|
||||
data.NewField("uint32_nullable", nil, []*uint32{new(uint32(2)), nil}),
|
||||
|
||||
data.NewField("uint64", nil, []uint64{1, 3}),
|
||||
data.NewField("uint64_nullable", nil, []*uint64{p(uint64(2)), nil}),
|
||||
data.NewField("uint64_nullable", nil, []*uint64{new(uint64(2)), nil}),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ func TestQueryFramesNumericSelect(t *testing.T) {
|
|||
RefID: "a",
|
||||
Name: "a",
|
||||
Fields: []*data.Field{
|
||||
data.NewField("decimal", nil, []*float64{p(2.35)}),
|
||||
data.NewField("decimal", nil, []*float64{new(2.35)}),
|
||||
data.NewField("tinySigned", nil, []int8{-128}),
|
||||
data.NewField("smallSigned", nil, []int16{-32768}),
|
||||
data.NewField("mediumSigned", nil, []int32{-8388608}),
|
||||
|
|
@ -230,7 +230,7 @@ func TestQueryFramesDateTimeSelect(t *testing.T) {
|
|||
Name: "a",
|
||||
Fields: []*data.Field{
|
||||
data.NewField("ts", nil, []*time.Time{
|
||||
p(time.Date(2025, 2, 3, 3, 0, 0, 0, time.UTC)),
|
||||
new(time.Date(2025, 2, 3, 3, 0, 0, 0, time.UTC)),
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
|
@ -253,7 +253,7 @@ func TestNaNBecomesNull(t *testing.T) {
|
|||
Name: "a",
|
||||
Fields: []*data.Field{
|
||||
data.NewField("d", nil, []float64{2.35, math.NaN()}),
|
||||
data.NewField("e", nil, []*float64{p(3.1), p(math.NaN())}),
|
||||
data.NewField("e", nil, []*float64{new(3.1), new(math.NaN())}),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -261,8 +261,8 @@ func TestNaNBecomesNull(t *testing.T) {
|
|||
RefID: "b",
|
||||
Name: "b",
|
||||
Fields: []*data.Field{
|
||||
data.NewField("d", nil, []*float64{p(2.35), nil}),
|
||||
data.NewField("e", nil, []*float64{p(3.1), nil}),
|
||||
data.NewField("d", nil, []*float64{new(2.35), nil}),
|
||||
data.NewField("e", nil, []*float64{new(3.1), nil}),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -399,11 +399,6 @@ func TestQueryFrames_Limits(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// p is a utility for pointers from constants
|
||||
func p[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
||||
type testTracer struct {
|
||||
trace.Tracer
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
func TestExtractNumberSetFromSQLForAlerting(t *testing.T) {
|
||||
t.Run("SingleRowNoLabels", func(t *testing.T) {
|
||||
input := data.NewFrame("",
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(3.14)}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(3.14)}),
|
||||
)
|
||||
|
||||
numbers, err := extractNumberSetFromSQLForAlerting(input)
|
||||
|
|
@ -20,30 +20,30 @@ func TestExtractNumberSetFromSQLForAlerting(t *testing.T) {
|
|||
require.Len(t, numbers, 1)
|
||||
|
||||
got := numbers[0]
|
||||
require.Equal(t, fp(3.14), got.GetFloat64Value())
|
||||
require.Equal(t, new(3.14), got.GetFloat64Value())
|
||||
require.Equal(t, data.Labels{}, got.GetLabels())
|
||||
})
|
||||
|
||||
t.Run("TwoRowsWithLabelsAndDisplay", func(t *testing.T) {
|
||||
input := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0)}),
|
||||
data.NewField(SQLDisplayFieldName, nil, []*string{sp("CPU A"), sp("CPU B")}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0)}),
|
||||
data.NewField(SQLDisplayFieldName, nil, []*string{new("CPU A"), new("CPU B")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b")}),
|
||||
)
|
||||
|
||||
numbers, err := extractNumberSetFromSQLForAlerting(input)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, numbers, 2)
|
||||
|
||||
require.Equal(t, fp(1.0), numbers[0].GetFloat64Value())
|
||||
require.Equal(t, new(1.0), numbers[0].GetFloat64Value())
|
||||
require.Equal(t, data.Labels{
|
||||
SQLMetricFieldName: "cpu",
|
||||
SQLDisplayFieldName: "CPU A",
|
||||
"host": "a",
|
||||
}, numbers[0].GetLabels())
|
||||
|
||||
require.Equal(t, fp(2.0), numbers[1].GetFloat64Value())
|
||||
require.Equal(t, new(2.0), numbers[1].GetFloat64Value())
|
||||
require.Equal(t, data.Labels{
|
||||
SQLMetricFieldName: "cpu",
|
||||
SQLDisplayFieldName: "CPU B",
|
||||
|
|
@ -54,22 +54,22 @@ func TestExtractNumberSetFromSQLForAlerting(t *testing.T) {
|
|||
t.Run("TwoFieldsWithSparseLabels", func(t *testing.T) {
|
||||
input := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0)}),
|
||||
data.NewField("env", nil, []*string{nil, sp("prod")}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0)}),
|
||||
data.NewField("env", nil, []*string{nil, new("prod")}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b")}),
|
||||
)
|
||||
|
||||
numbers, err := extractNumberSetFromSQLForAlerting(input)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, numbers, 2)
|
||||
|
||||
require.Equal(t, fp(1.0), numbers[0].GetFloat64Value())
|
||||
require.Equal(t, new(1.0), numbers[0].GetFloat64Value())
|
||||
require.Equal(t, data.Labels{
|
||||
SQLMetricFieldName: "cpu",
|
||||
"host": "a",
|
||||
}, numbers[0].GetLabels())
|
||||
|
||||
require.Equal(t, fp(2.0), numbers[1].GetFloat64Value())
|
||||
require.Equal(t, new(2.0), numbers[1].GetFloat64Value())
|
||||
require.Equal(t, data.Labels{
|
||||
SQLMetricFieldName: "cpu",
|
||||
"host": "b",
|
||||
|
|
@ -82,8 +82,8 @@ func TestExtractNumberSetFromSQLForAlerting_Duplicates(t *testing.T) {
|
|||
t.Run("AllDuplicates_ReturnsError", func(t *testing.T) {
|
||||
input := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0)}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("a")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0)}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("a")}),
|
||||
)
|
||||
|
||||
numbers, err := extractNumberSetFromSQLForAlerting(input)
|
||||
|
|
@ -97,8 +97,8 @@ func TestExtractNumberSetFromSQLForAlerting_Duplicates(t *testing.T) {
|
|||
t.Run("SomeDuplicates_ReturnsError", func(t *testing.T) {
|
||||
input := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu", "cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0), fp(3.0)}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("a"), sp("b")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0), new(3.0)}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("a"), new("b")}),
|
||||
)
|
||||
|
||||
numbers, err := extractNumberSetFromSQLForAlerting(input)
|
||||
|
|
@ -112,8 +112,8 @@ func TestExtractNumberSetFromSQLForAlerting_Duplicates(t *testing.T) {
|
|||
t.Run("NoDuplicates_Succeeds", func(t *testing.T) {
|
||||
input := data.NewFrame("",
|
||||
data.NewField(SQLMetricFieldName, nil, []string{"cpu", "cpu"}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{fp(1.0), fp(2.0)}),
|
||||
data.NewField("host", nil, []*string{sp("a"), sp("b")}),
|
||||
data.NewField(SQLValueFieldName, nil, []*float64{new(1.0), new(2.0)}),
|
||||
data.NewField("host", nil, []*string{new("a"), new("b")}),
|
||||
)
|
||||
|
||||
numbers, err := extractNumberSetFromSQLForAlerting(input)
|
||||
|
|
@ -138,7 +138,7 @@ func TestExtractNumberSetFromSQLForAlerting_Duplicates(t *testing.T) {
|
|||
|
||||
for i := range totalRows {
|
||||
labels[i] = "cpu"
|
||||
values[i] = fp(float64(i + 1))
|
||||
values[i] = new(float64(i + 1))
|
||||
h := fmt.Sprintf("host%d", i%15) // 15 distinct combos, each duplicated
|
||||
hosts[i] = &h
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ func TestHandleSqlInput(t *testing.T) {
|
|||
frames: data.Frames{
|
||||
data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("value", nil, []*float64{fp(2)}),
|
||||
data.NewField("value", nil, []*float64{new(2.0)}),
|
||||
),
|
||||
},
|
||||
expectFrame: true,
|
||||
|
|
@ -206,7 +206,7 @@ func TestHandleSqlInput(t *testing.T) {
|
|||
frames: data.Frames{
|
||||
data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("value", data.Labels{"foo": "bar"}, []*float64{fp(2)}),
|
||||
data.NewField("value", data.Labels{"foo": "bar"}, []*float64{new(2.0)}),
|
||||
),
|
||||
},
|
||||
expectErr: "labels in the response that can not be mapped to a table",
|
||||
|
|
@ -216,11 +216,11 @@ func TestHandleSqlInput(t *testing.T) {
|
|||
frames: data.Frames{
|
||||
data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("value", nil, []*float64{fp(2)}),
|
||||
data.NewField("value", nil, []*float64{new(2.0)}),
|
||||
),
|
||||
data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("value", nil, []*float64{fp(2)}),
|
||||
data.NewField("value", nil, []*float64{new(2.0)}),
|
||||
),
|
||||
},
|
||||
expectErr: "more than one dataframe that can not be automatically mapped to a single table",
|
||||
|
|
@ -230,7 +230,7 @@ func TestHandleSqlInput(t *testing.T) {
|
|||
frames: data.Frames{
|
||||
data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{time.Unix(1, 0)}),
|
||||
data.NewField("value", data.Labels{"host": "a"}, []*float64{fp(2)}),
|
||||
data.NewField("value", data.Labels{"host": "a"}, []*float64{new(2.0)}),
|
||||
).SetMeta(&data.FrameMeta{Type: data.FrameTypeTimeSeriesMulti}),
|
||||
},
|
||||
expectFrame: true,
|
||||
|
|
@ -241,7 +241,7 @@ func TestHandleSqlInput(t *testing.T) {
|
|||
frames: data.Frames{
|
||||
data.NewFrame("",
|
||||
data.NewField("time", nil, []string{"1"}), // string is not valid for time field
|
||||
data.NewField("value", data.Labels{"host": "a"}, []*float64{fp(2)}),
|
||||
data.NewField("value", data.Labels{"host": "a"}, []*float64{new(2.0)}),
|
||||
).SetMeta(&data.FrameMeta{Type: data.FrameTypeTimeSeriesMulti}),
|
||||
},
|
||||
expectErr: "missing time field",
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ import (
|
|||
_ "k8s.io/apiserver/pkg/util/compatibility"
|
||||
_ "k8s.io/client-go/dynamic/fake"
|
||||
_ "k8s.io/component-base/featuregate/testing"
|
||||
_ "k8s.io/utils/ptr"
|
||||
_ "pgregory.net/rapid"
|
||||
_ "sigs.k8s.io/randfill"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ type queryListFolders struct {
|
|||
}
|
||||
|
||||
func interfaceName(myvar interface{}) string {
|
||||
if t := reflect.TypeOf(myvar); t.Kind() == reflect.Ptr {
|
||||
if t := reflect.TypeOf(myvar); t.Kind() == reflect.Pointer {
|
||||
return "*" + t.Elem().Name()
|
||||
} else {
|
||||
return t.Name()
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ func (w *FileLogWriter) deleteOldLog() {
|
|||
|
||||
if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*w.Maxdays) &&
|
||||
strings.HasPrefix(filepath.Base(path), filepath.Base(w.Filename)) {
|
||||
returnErr = os.Remove(path)
|
||||
returnErr = os.Remove(path) // #nosec G122 -- log rotation on operator-controlled directory
|
||||
return
|
||||
}
|
||||
return
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ func logfmt(buf *bytes.Buffer, ctx []interface{}, color int) {
|
|||
func formatShared(value interface{}) (result interface{}) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
if v := reflect.ValueOf(value); v.Kind() == reflect.Ptr && v.IsNil() {
|
||||
if v := reflect.ValueOf(value); v.Kind() == reflect.Pointer && v.IsNil() {
|
||||
result = "nil"
|
||||
} else {
|
||||
panic(err)
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ func TestGathererPrefixWrapper_Gather(t *testing.T) {
|
|||
|
||||
t.Run("metrics with grafana and go prefix are not modified", func(t *testing.T) {
|
||||
originalMF := []*dto.MetricFamily{
|
||||
{Name: strptr("grafana_metric1")},
|
||||
{Name: strptr("metric2")},
|
||||
{Name: strptr("go_metric1")},
|
||||
{Name: new("grafana_metric1")},
|
||||
{Name: new("metric2")},
|
||||
{Name: new("go_metric1")},
|
||||
}
|
||||
|
||||
orig.GatherFunc = func() ([]*dto.MetricFamily, error) {
|
||||
|
|
@ -23,9 +23,9 @@ func TestGathererPrefixWrapper_Gather(t *testing.T) {
|
|||
}
|
||||
|
||||
expectedMF := []*dto.MetricFamily{
|
||||
{Name: strptr("grafana_metric1")},
|
||||
{Name: strptr("grafana_metric2")},
|
||||
{Name: strptr("go_metric1")},
|
||||
{Name: new("grafana_metric1")},
|
||||
{Name: new("grafana_metric2")},
|
||||
{Name: new("go_metric1")},
|
||||
}
|
||||
|
||||
mf, err := g.Gather()
|
||||
|
|
@ -35,8 +35,8 @@ func TestGathererPrefixWrapper_Gather(t *testing.T) {
|
|||
|
||||
t.Run("duplicate metrics result in an error", func(t *testing.T) {
|
||||
originalMF := []*dto.MetricFamily{
|
||||
{Name: strptr("grafana_metric1")},
|
||||
{Name: strptr("metric1")},
|
||||
{Name: new("grafana_metric1")},
|
||||
{Name: new("metric1")},
|
||||
}
|
||||
|
||||
orig.GatherFunc = func() ([]*dto.MetricFamily, error) {
|
||||
|
|
@ -56,23 +56,23 @@ func TestMultiRegistry_Gather(t *testing.T) {
|
|||
t.Run("should merge and sort metrics", func(t *testing.T) {
|
||||
one.GatherFunc = func() ([]*dto.MetricFamily, error) {
|
||||
return []*dto.MetricFamily{
|
||||
{Name: strptr("b")},
|
||||
{Name: strptr("a")},
|
||||
{Name: new("b")},
|
||||
{Name: new("a")},
|
||||
}, nil
|
||||
}
|
||||
|
||||
two.GatherFunc = func() ([]*dto.MetricFamily, error) {
|
||||
return []*dto.MetricFamily{
|
||||
{Name: strptr("d")},
|
||||
{Name: strptr("c")},
|
||||
{Name: new("d")},
|
||||
{Name: new("c")},
|
||||
}, nil
|
||||
}
|
||||
|
||||
expectedMF := []*dto.MetricFamily{
|
||||
{Name: strptr("a")},
|
||||
{Name: strptr("b")},
|
||||
{Name: strptr("c")},
|
||||
{Name: strptr("d")},
|
||||
{Name: new("a")},
|
||||
{Name: new("b")},
|
||||
{Name: new("c")},
|
||||
{Name: new("d")},
|
||||
}
|
||||
|
||||
mf, err := g.Gather()
|
||||
|
|
@ -83,16 +83,16 @@ func TestMultiRegistry_Gather(t *testing.T) {
|
|||
t.Run("duplicate metrics result in an error", func(t *testing.T) {
|
||||
one.GatherFunc = func() ([]*dto.MetricFamily, error) {
|
||||
return []*dto.MetricFamily{
|
||||
{Name: strptr("b")},
|
||||
{Name: strptr("a")},
|
||||
{Name: new("b")},
|
||||
{Name: new("a")},
|
||||
}, nil
|
||||
}
|
||||
|
||||
two.GatherFunc = func() ([]*dto.MetricFamily, error) {
|
||||
return []*dto.MetricFamily{
|
||||
{Name: strptr("d")},
|
||||
{Name: strptr("c")},
|
||||
{Name: strptr("a")},
|
||||
{Name: new("d")},
|
||||
{Name: new("c")},
|
||||
{Name: new("a")},
|
||||
}, nil
|
||||
}
|
||||
_, err := g.Gather()
|
||||
|
|
@ -102,29 +102,29 @@ func TestMultiRegistry_Gather(t *testing.T) {
|
|||
t.Run("duplicate go_ or process_ prefixed metrics do not result in an error", func(t *testing.T) {
|
||||
one.GatherFunc = func() ([]*dto.MetricFamily, error) {
|
||||
return []*dto.MetricFamily{
|
||||
{Name: strptr("b")},
|
||||
{Name: strptr("a")},
|
||||
{Name: strptr("go_a")},
|
||||
{Name: strptr("process_a")},
|
||||
{Name: new("b")},
|
||||
{Name: new("a")},
|
||||
{Name: new("go_a")},
|
||||
{Name: new("process_a")},
|
||||
}, nil
|
||||
}
|
||||
|
||||
two.GatherFunc = func() ([]*dto.MetricFamily, error) {
|
||||
return []*dto.MetricFamily{
|
||||
{Name: strptr("d")},
|
||||
{Name: strptr("c")},
|
||||
{Name: strptr("go_a")},
|
||||
{Name: strptr("process_a")},
|
||||
{Name: new("d")},
|
||||
{Name: new("c")},
|
||||
{Name: new("go_a")},
|
||||
{Name: new("process_a")},
|
||||
}, nil
|
||||
}
|
||||
|
||||
expectedMF := []*dto.MetricFamily{
|
||||
{Name: strptr("a")},
|
||||
{Name: strptr("b")},
|
||||
{Name: strptr("c")},
|
||||
{Name: strptr("d")},
|
||||
{Name: strptr("go_a")},
|
||||
{Name: strptr("process_a")},
|
||||
{Name: new("a")},
|
||||
{Name: new("b")},
|
||||
{Name: new("c")},
|
||||
{Name: new("d")},
|
||||
{Name: new("go_a")},
|
||||
{Name: new("process_a")},
|
||||
}
|
||||
|
||||
mf, err := g.Gather()
|
||||
|
|
@ -135,20 +135,20 @@ func TestMultiRegistry_Gather(t *testing.T) {
|
|||
t.Run("denied metrics are not included", func(t *testing.T) {
|
||||
one.GatherFunc = func() ([]*dto.MetricFamily, error) {
|
||||
return []*dto.MetricFamily{
|
||||
{Name: strptr("grafana_apiserver_request_slo_duration_seconds_bucket")},
|
||||
{Name: new("grafana_apiserver_request_slo_duration_seconds_bucket")},
|
||||
}, nil
|
||||
}
|
||||
|
||||
two.GatherFunc = func() ([]*dto.MetricFamily, error) {
|
||||
return []*dto.MetricFamily{
|
||||
{Name: strptr("b")},
|
||||
{Name: strptr("a")},
|
||||
{Name: new("b")},
|
||||
{Name: new("a")},
|
||||
}, nil
|
||||
}
|
||||
|
||||
expectedMF := []*dto.MetricFamily{
|
||||
{Name: strptr("a")},
|
||||
{Name: strptr("b")},
|
||||
{Name: new("a")},
|
||||
{Name: new("b")},
|
||||
}
|
||||
|
||||
mf, err := g.Gather()
|
||||
|
|
@ -164,7 +164,3 @@ type mockGatherer struct {
|
|||
func (m *mockGatherer) Gather() ([]*dto.MetricFamily, error) {
|
||||
return m.GatherFunc()
|
||||
}
|
||||
|
||||
func strptr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ func WriteCookie(w http.ResponseWriter, name string, value string, maxAge int, g
|
|||
}
|
||||
|
||||
options := getCookieOptions()
|
||||
// #nosec G124 -- HttpOnly/Secure/SameSite are configurable via options
|
||||
cookie := http.Cookie{
|
||||
Name: name,
|
||||
MaxAge: maxAge,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ func SubPathRedirect(cfg *setting.Cfg) web.Middleware {
|
|||
// Direct to url with subpath if the request is missing the subpath and is not an API request.
|
||||
if !strings.HasPrefix(req.RequestURI, cfg.AppSubURL) && !strings.HasPrefix(req.RequestURI, "/api") {
|
||||
newURL := fmt.Sprintf("%s%s", cfg.AppURL, strings.TrimPrefix(req.RequestURI, "/"))
|
||||
http.Redirect(rw, req, newURL, http.StatusMovedPermanently)
|
||||
http.Redirect(rw, req, newURL, http.StatusMovedPermanently) // #nosec G710 -- newURL built from operator-configured AppURL + the inbound path
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -571,7 +571,7 @@ func TestConvertHttpSearchRequestToResourceSearchRequest(t *testing.T) {
|
|||
Resource: "folders",
|
||||
Namespace: "test-namespace",
|
||||
}
|
||||
defaultFields := []string{"title", "folder", "tags", "description", "manager.kind", "manager.id", resource.SEARCH_FIELD_OWNER_REFERENCES}
|
||||
defaultFields := []string{"title", "folder", "tags", "description", "manager.kind", "manager.id", resource.SEARCH_FIELD_OWNER_REFERENCES} //nolint:prealloc
|
||||
|
||||
tests := map[string]struct {
|
||||
queryString string
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||
"github.com/grafana/grafana/pkg/services/ngalert/notifier"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
)
|
||||
|
||||
func TestValidateCreateReceiverIntegrationTestRequestBody(t *testing.T) {
|
||||
|
|
@ -27,7 +26,7 @@ func TestValidateCreateReceiverIntegrationTestRequestBody(t *testing.T) {
|
|||
receiverUID: "",
|
||||
body: v1beta1.CreateReceiverIntegrationTestRequestBody{
|
||||
Integration: v1beta1.CreateReceiverIntegrationTestRequestIntegration{
|
||||
Uid: utils.Pointer("integration-uid"),
|
||||
Uid: new("integration-uid"),
|
||||
Type: "slack",
|
||||
Settings: map[string]any{},
|
||||
},
|
||||
|
|
@ -63,7 +62,7 @@ func TestValidateCreateReceiverIntegrationTestRequestBody(t *testing.T) {
|
|||
receiverUID: "receiver-uid",
|
||||
body: v1beta1.CreateReceiverIntegrationTestRequestBody{
|
||||
Integration: v1beta1.CreateReceiverIntegrationTestRequestIntegration{
|
||||
Uid: utils.Pointer(""),
|
||||
Uid: new(""),
|
||||
Type: "slack",
|
||||
Settings: map[string]any{},
|
||||
SecureFields: map[string]bool{"token": true},
|
||||
|
|
@ -98,7 +97,7 @@ func TestValidateCreateReceiverIntegrationTestRequestBody(t *testing.T) {
|
|||
receiverUID: "receiver-uid",
|
||||
body: v1beta1.CreateReceiverIntegrationTestRequestBody{
|
||||
Integration: v1beta1.CreateReceiverIntegrationTestRequestIntegration{
|
||||
Uid: utils.Pointer("integration-uid"),
|
||||
Uid: new("integration-uid"),
|
||||
Type: "slack",
|
||||
Settings: map[string]any{"url": "https://slack.com/webhook"},
|
||||
SecureFields: map[string]bool{"token": true},
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ func TestAddPostStartHooks(t *testing.T) {
|
|||
func TestRedirection(t *testing.T) {
|
||||
mockHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, err := w.Write([]byte(r.URL.Path))
|
||||
_, err := w.Write([]byte(r.URL.Path)) // #nosec G705 -- test handler echoing controlled input
|
||||
require.NoError(t, err)
|
||||
})
|
||||
handler := filters.WithPathRewriters(mockHandler, builder.PathRewriters)
|
||||
|
|
|
|||
|
|
@ -656,7 +656,7 @@ func TestIntegrationUserAuthToken(t *testing.T) {
|
|||
var uat userAuthToken
|
||||
err = uat.fromUserToken(&ut)
|
||||
require.Nil(t, err)
|
||||
uatBytes, err := json.Marshal(uat)
|
||||
uatBytes, err := json.Marshal(uat) // #nosec G117 -- test fixture marshaling internal struct
|
||||
require.Nil(t, err)
|
||||
uatJSON, err := simplejson.NewJson(uatBytes)
|
||||
require.Nil(t, err)
|
||||
|
|
@ -681,7 +681,7 @@ func TestIntegrationUserAuthToken(t *testing.T) {
|
|||
UnhashedToken: "e",
|
||||
ExternalSessionId: 7,
|
||||
}
|
||||
uatBytes, err := json.Marshal(uat)
|
||||
uatBytes, err := json.Marshal(uat) // #nosec G117 -- test fixture marshaling internal struct
|
||||
require.Nil(t, err)
|
||||
uatJSON, err := simplejson.NewJson(uatBytes)
|
||||
require.Nil(t, err)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func TestGComSSOService_LogoutHook(t *testing.T) {
|
||||
// #nosec G101 -- test fixture, not a real credential
|
||||
cfg := &setting.Cfg{
|
||||
GrafanaComURL: "http://example.com",
|
||||
GrafanaComSSOAPIToken: "sso-api-token",
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ func HandleLoginResponse(r *http.Request, w http.ResponseWriter, cfg *setting.Cf
|
|||
// HandleLoginRedirect is a utility function to perform common operations after a successful login and redirects
|
||||
func HandleLoginRedirect(r *http.Request, w http.ResponseWriter, cfg *setting.Cfg, identity *Identity, validator RedirectValidator, features featuremgmt.FeatureToggles) {
|
||||
redirectURL := handleLogin(r, w, cfg, identity, validator, features, "redirectTo")
|
||||
http.Redirect(w, r, redirectURL, http.StatusFound)
|
||||
http.Redirect(w, r, redirectURL, http.StatusFound) // #nosec G710 -- redirectURL validated by RedirectValidator in handleLogin
|
||||
}
|
||||
|
||||
// HandleLoginRedirectResponse is a utility function to perform common operations after a successful login and return a response.RedirectResponse
|
||||
|
|
|
|||
|
|
@ -86,11 +86,11 @@ func TestOrgSync_SyncOrgRolesHook(t *testing.T) {
|
|||
Name: "test",
|
||||
Email: "test",
|
||||
OrgRoles: map[int64]identity.RoleType{1: org.RoleAdmin, 2: org.RoleEditor},
|
||||
IsGrafanaAdmin: ptrBool(false),
|
||||
IsGrafanaAdmin: new(false),
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncOrgRoles: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: ptrString("test"),
|
||||
Email: new("test"),
|
||||
Login: nil,
|
||||
},
|
||||
},
|
||||
|
|
@ -104,11 +104,11 @@ func TestOrgSync_SyncOrgRolesHook(t *testing.T) {
|
|||
Email: "test",
|
||||
OrgRoles: map[int64]identity.RoleType{1: org.RoleAdmin, 2: org.RoleEditor},
|
||||
OrgID: 1, // set using org
|
||||
IsGrafanaAdmin: ptrBool(false),
|
||||
IsGrafanaAdmin: new(false),
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncOrgRoles: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: ptrString("test"),
|
||||
Email: new("test"),
|
||||
Login: nil,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -33,14 +33,6 @@ import (
|
|||
"github.com/grafana/grafana/pkg/storage/unified/resourcepb"
|
||||
)
|
||||
|
||||
func ptrString(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
func ptrBool(b bool) *bool {
|
||||
return &b
|
||||
}
|
||||
|
||||
var (
|
||||
provider = oftesting.NewTestProvider()
|
||||
defaultFeatureFlags = map[string]memprovider.InMemoryFlag{
|
||||
|
|
@ -245,7 +237,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Email: "test",
|
||||
ClientParams: authn.ClientParams{
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: ptrString("test"),
|
||||
Email: new("test"),
|
||||
Login: nil,
|
||||
},
|
||||
},
|
||||
|
|
@ -258,7 +250,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Email: "test",
|
||||
ClientParams: authn.ClientParams{
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: ptrString("test"),
|
||||
Email: new("test"),
|
||||
Login: nil,
|
||||
},
|
||||
},
|
||||
|
|
@ -279,7 +271,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: ptrString("test"),
|
||||
Email: new("test"),
|
||||
Login: nil,
|
||||
},
|
||||
},
|
||||
|
|
@ -294,11 +286,11 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Login: "test",
|
||||
Name: "test",
|
||||
Email: "test",
|
||||
IsGrafanaAdmin: ptrBool(false),
|
||||
IsGrafanaAdmin: new(false),
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: ptrString("test"),
|
||||
Email: new("test"),
|
||||
Login: nil,
|
||||
},
|
||||
},
|
||||
|
|
@ -320,7 +312,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
SyncUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: nil,
|
||||
Login: ptrString("test"),
|
||||
Login: new("test"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -334,11 +326,11 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Login: "test",
|
||||
Name: "test",
|
||||
Email: "test",
|
||||
IsGrafanaAdmin: ptrBool(false),
|
||||
IsGrafanaAdmin: new(false),
|
||||
ClientParams: authn.ClientParams{
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: nil,
|
||||
Login: ptrString("test"),
|
||||
Login: new("test"),
|
||||
},
|
||||
SyncUser: true,
|
||||
},
|
||||
|
|
@ -378,7 +370,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Login: "test",
|
||||
Name: "test",
|
||||
Email: "test",
|
||||
IsGrafanaAdmin: ptrBool(false),
|
||||
IsGrafanaAdmin: new(false),
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
|
|
@ -424,7 +416,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
id: &authn.Identity{
|
||||
Login: "test_create",
|
||||
Name: "test_create",
|
||||
IsGrafanaAdmin: ptrBool(true),
|
||||
IsGrafanaAdmin: new(true),
|
||||
Email: "test_create",
|
||||
AuthenticatedBy: "oauth",
|
||||
AuthID: "2032",
|
||||
|
|
@ -433,7 +425,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
AllowSignUp: true,
|
||||
EnableUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: ptrString("test_create"),
|
||||
Email: new("test_create"),
|
||||
Login: nil,
|
||||
},
|
||||
},
|
||||
|
|
@ -449,13 +441,13 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Email: "test_create",
|
||||
AuthenticatedBy: "oauth",
|
||||
AuthID: "2032",
|
||||
IsGrafanaAdmin: ptrBool(true),
|
||||
IsGrafanaAdmin: new(true),
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
AllowSignUp: true,
|
||||
EnableUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: ptrString("test_create"),
|
||||
Email: new("test_create"),
|
||||
Login: nil,
|
||||
},
|
||||
},
|
||||
|
|
@ -474,13 +466,13 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Name: "test_mod",
|
||||
Email: "test_mod",
|
||||
IsDisabled: false,
|
||||
IsGrafanaAdmin: ptrBool(true),
|
||||
IsGrafanaAdmin: new(true),
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
EnableUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: nil,
|
||||
Login: ptrString("test"),
|
||||
Login: new("test"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -494,13 +486,13 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Name: "test_mod",
|
||||
Email: "test_mod",
|
||||
IsDisabled: false,
|
||||
IsGrafanaAdmin: ptrBool(true),
|
||||
IsGrafanaAdmin: new(true),
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
EnableUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: nil,
|
||||
Login: ptrString("test"),
|
||||
Login: new("test"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -519,13 +511,13 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Email: "test_mod@test.com",
|
||||
EmailVerified: true,
|
||||
IsDisabled: false,
|
||||
IsGrafanaAdmin: ptrBool(true),
|
||||
IsGrafanaAdmin: new(true),
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
EnableUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: nil,
|
||||
Login: ptrString("test"),
|
||||
Login: new("test"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -540,13 +532,13 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Email: "test_mod@test.com",
|
||||
IsDisabled: false,
|
||||
EmailVerified: false,
|
||||
IsGrafanaAdmin: ptrBool(true),
|
||||
IsGrafanaAdmin: new(true),
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
EnableUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: nil,
|
||||
Login: ptrString("test"),
|
||||
Login: new("test"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -631,7 +623,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Email: "user1@test.com",
|
||||
Name: "User One",
|
||||
ExternalUID: "matching-uid",
|
||||
IsGrafanaAdmin: ptrBool(false),
|
||||
IsGrafanaAdmin: new(false),
|
||||
ClientParams: authn.ClientParams{SyncUser: true},
|
||||
},
|
||||
},
|
||||
|
|
@ -645,7 +637,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
// Call the original mockUpdateFn for assertions
|
||||
err := mockUpdateFn(t, &user.UpdateUserCommand{
|
||||
UserID: scimUserNotAdminInitial.ID,
|
||||
IsGrafanaAdmin: ptrBool(true),
|
||||
IsGrafanaAdmin: new(true),
|
||||
}, true, scimUserNotAdminInitial.Email)(ctx, cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -671,7 +663,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Login: "saml.login. متفاوت", // SAML sends different login
|
||||
Email: "saml.email. متفاوت@example.com", // SAML sends different email
|
||||
Name: "SAML Name متفاوت", // SAML sends different name
|
||||
IsGrafanaAdmin: ptrBool(true), // Key change: SAML says user IS admin
|
||||
IsGrafanaAdmin: new(true), // Key change: SAML says user IS admin
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
// LookUpParams not strictly needed if AuthID + AuthenticatedBy + ExternalUID is enough
|
||||
|
|
@ -686,7 +678,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Login: "saml.login. متفاوت", // Reflects actual behavior: SAML input value persists
|
||||
Email: "saml.email. متفاوت@example.com", // Reflects actual behavior: SAML input value persists
|
||||
Name: "SAML Name متفاوت", // Reflects actual behavior: SAML input value persists
|
||||
IsGrafanaAdmin: ptrBool(true), // This SHOULD be updated
|
||||
IsGrafanaAdmin: new(true), // This SHOULD be updated
|
||||
EmailVerified: false, // Reflects actual behavior: becomes false
|
||||
AuthID: "id_from_saml_assertion",
|
||||
AuthenticatedBy: "saml",
|
||||
|
|
@ -706,7 +698,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
// Call the original mockUpdateFn for assertions
|
||||
err := mockUpdateFn(t, &user.UpdateUserCommand{
|
||||
UserID: scimUserIsAdminInitial.ID,
|
||||
IsGrafanaAdmin: ptrBool(false),
|
||||
IsGrafanaAdmin: new(false),
|
||||
}, true, scimUserIsAdminInitial.Email)(ctx, cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -729,7 +721,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
AuthID: "id_from_saml_assertion",
|
||||
AuthenticatedBy: "saml",
|
||||
ExternalUID: "external_id_demote",
|
||||
IsGrafanaAdmin: ptrBool(false), // Key change: SAML says user is NOT admin
|
||||
IsGrafanaAdmin: new(false), // Key change: SAML says user is NOT admin
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
},
|
||||
|
|
@ -743,7 +735,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Login: scimUserIsAdminInitial.Login,
|
||||
Email: scimUserIsAdminInitial.Email,
|
||||
Name: scimUserIsAdminInitial.Name,
|
||||
IsGrafanaAdmin: ptrBool(false), // Updated
|
||||
IsGrafanaAdmin: new(false), // Updated
|
||||
EmailVerified: scimUserIsAdminInitial.EmailVerified,
|
||||
AuthID: "id_from_saml_assertion",
|
||||
AuthenticatedBy: "saml",
|
||||
|
|
@ -764,7 +756,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
// In this case, IsGrafanaAdmin from SAML (false) matches DB (false), so it *will* be in the command.
|
||||
err := mockUpdateFn(t, &user.UpdateUserCommand{
|
||||
UserID: scimUserNotAdminInitial.ID,
|
||||
IsGrafanaAdmin: ptrBool(false), // SAML says false, DB is false
|
||||
IsGrafanaAdmin: new(false), // SAML says false, DB is false
|
||||
}, true, scimUserNotAdminInitial.Email)(ctx, cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -790,7 +782,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Login: "saml.login.new", // SAML sends different login
|
||||
Email: "saml.email.new@example.com", // SAML sends different email
|
||||
Name: "SAML Name New", // SAML sends different name
|
||||
IsGrafanaAdmin: ptrBool(false), // SAML says not admin (same as DB)
|
||||
IsGrafanaAdmin: new(false), // SAML says not admin (same as DB)
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
},
|
||||
|
|
@ -804,7 +796,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Login: "saml.login.new", // Reflects actual behavior: SAML input value persists
|
||||
Email: "saml.email.new@example.com", // Reflects actual behavior: SAML input value persists
|
||||
Name: "SAML Name New", // Reflects actual behavior: SAML input value persists
|
||||
IsGrafanaAdmin: ptrBool(false), // Unchanged, matches DB
|
||||
IsGrafanaAdmin: new(false), // Unchanged, matches DB
|
||||
EmailVerified: false, // Reflects actual behavior: becomes false
|
||||
AuthID: "id_from_saml_assertion",
|
||||
AuthenticatedBy: "saml",
|
||||
|
|
@ -825,7 +817,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
// Email changes, IsGrafanaAdmin changes.
|
||||
expectedCmd := &user.UpdateUserCommand{
|
||||
UserID: nonScimUserInitial.ID,
|
||||
IsGrafanaAdmin: ptrBool(true),
|
||||
IsGrafanaAdmin: new(true),
|
||||
Email: "nonscim.new.email@example.com",
|
||||
Login: "", // Login not changing, so should be empty in cmd
|
||||
Name: "", // Name not changing, so should be empty in cmd
|
||||
|
|
@ -874,11 +866,11 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Login: nonScimUserInitial.Login, // Use initial login for lookup
|
||||
Email: "nonscim.new.email@example.com", // SAML sends new email
|
||||
Name: nonScimUserInitial.Name, // Name is same
|
||||
IsGrafanaAdmin: ptrBool(true), // SAML promotes to admin
|
||||
IsGrafanaAdmin: new(true), // SAML promotes to admin
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Login: ptrString(nonScimUserInitial.Login), // Lookup by existing login
|
||||
Login: new(nonScimUserInitial.Login), // Lookup by existing login
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -891,13 +883,13 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Login: nonScimUserInitial.Login, // Login updated if it was in UpdateUserCommand
|
||||
Email: "nonscim.new.email@example.com", // Email updated
|
||||
Name: nonScimUserInitial.Name, // Name updated if it was in UpdateUserCommand
|
||||
IsGrafanaAdmin: ptrBool(true), // IsAdmin updated
|
||||
IsGrafanaAdmin: new(true), // IsAdmin updated
|
||||
EmailVerified: false, // Email changed, so should be unverified
|
||||
AuthenticatedBy: "saml",
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Login: ptrString(nonScimUserInitial.Login),
|
||||
Login: new(nonScimUserInitial.Login),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -918,7 +910,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: ptrString("test"),
|
||||
Email: new("test"),
|
||||
Login: nil,
|
||||
},
|
||||
},
|
||||
|
|
@ -933,11 +925,11 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Login: "test",
|
||||
Name: "test",
|
||||
Email: "test",
|
||||
IsGrafanaAdmin: ptrBool(false),
|
||||
IsGrafanaAdmin: new(false),
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: ptrString("test"),
|
||||
Email: new("test"),
|
||||
Login: nil,
|
||||
},
|
||||
},
|
||||
|
|
@ -958,7 +950,7 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: ptrString("test"),
|
||||
Email: new("test"),
|
||||
Login: nil,
|
||||
},
|
||||
},
|
||||
|
|
@ -972,11 +964,11 @@ func TestUserSync_SyncUserHook(t *testing.T) {
|
|||
Login: "test",
|
||||
Name: "test",
|
||||
Email: "test",
|
||||
IsGrafanaAdmin: ptrBool(false),
|
||||
IsGrafanaAdmin: new(false),
|
||||
ClientParams: authn.ClientParams{
|
||||
SyncUser: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: ptrString("test"),
|
||||
Email: new("test"),
|
||||
Login: nil,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func TestAPIKey_Authenticate(t *testing.T) {
|
|||
ID: 1,
|
||||
OrgID: 1,
|
||||
Key: hash,
|
||||
ServiceAccountId: intPtr(1),
|
||||
ServiceAccountId: new(int64(1)),
|
||||
},
|
||||
expectedIdentity: &authn.Identity{
|
||||
ID: "1",
|
||||
|
|
@ -78,7 +78,7 @@ func TestAPIKey_Authenticate(t *testing.T) {
|
|||
req: &authn.Request{HTTPRequest: &http.Request{Header: map[string][]string{"Authorization": {"Bearer " + secret}}}},
|
||||
expectedKey: &apikey.APIKey{
|
||||
Key: hash,
|
||||
Expires: intPtr(0),
|
||||
Expires: new(int64),
|
||||
},
|
||||
expectedErr: errAPIKeyExpired,
|
||||
},
|
||||
|
|
@ -98,7 +98,7 @@ func TestAPIKey_Authenticate(t *testing.T) {
|
|||
ID: 1,
|
||||
OrgID: 2,
|
||||
Key: hash,
|
||||
ServiceAccountId: intPtr(1),
|
||||
ServiceAccountId: new(int64(1)),
|
||||
},
|
||||
expectedErr: errAPIKeyOrgMismatch,
|
||||
},
|
||||
|
|
@ -179,10 +179,6 @@ func TestAPIKey_Test(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func intPtr(n int64) *int64 {
|
||||
return &n
|
||||
}
|
||||
|
||||
func genApiKey() (string, string) {
|
||||
res, _ := satokengen.New("test")
|
||||
return res.ClientSecret, res.HashedKey
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ func TestGrafana_AuthenticateProxy(t *testing.T) {
|
|||
FetchSyncedUser: true,
|
||||
SyncOrgRoles: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: strPtr("email@email.com"),
|
||||
Login: strPtr("test"),
|
||||
Email: new("email@email.com"),
|
||||
Login: new("test"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -78,8 +78,8 @@ func TestGrafana_AuthenticateProxy(t *testing.T) {
|
|||
AllowSignUp: true,
|
||||
SyncOrgRoles: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: strPtr("test@test.com"),
|
||||
Login: strPtr("test@test.com"),
|
||||
Email: new("test@test.com"),
|
||||
Login: new("test@test.com"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ func TestLDAP_AuthenticateProxy(t *testing.T) {
|
|||
SyncOrgRoles: true,
|
||||
SyncPermissions: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: strPtr("test@test.com"),
|
||||
Login: strPtr("test"),
|
||||
Email: new("test@test.com"),
|
||||
Login: new("test"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -165,8 +165,8 @@ func TestLDAP_AuthenticatePassword(t *testing.T) {
|
|||
SyncOrgRoles: true,
|
||||
SyncPermissions: true,
|
||||
LookUpParams: login.UserLookupParams{
|
||||
Email: strPtr("test@test.com"),
|
||||
Login: strPtr("test"),
|
||||
Email: new("test@test.com"),
|
||||
Login: new("test"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -235,7 +235,3 @@ func setupLDAPTestCase(tt *ldapTestCase) *LDAP {
|
|||
|
||||
return c
|
||||
}
|
||||
|
||||
func strPtr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ func TestOAuth_Authenticate(t *testing.T) {
|
|||
AllowSignUp: true,
|
||||
FetchSyncedUser: true,
|
||||
SyncOrgRoles: true,
|
||||
LookUpParams: login.UserLookupParams{Email: strPtr("some@email.com")},
|
||||
LookUpParams: login.UserLookupParams{Email: new("some@email.com")},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ func TestService_checkPermission(t *testing.T) {
|
|||
},
|
||||
folders: []store.Folder{
|
||||
{UID: "parent"},
|
||||
{UID: "child", ParentUID: strPtr("parent")},
|
||||
{UID: "child", ParentUID: new("parent")},
|
||||
},
|
||||
check: checkRequest{
|
||||
Action: "dashboards:read",
|
||||
|
|
@ -461,7 +461,7 @@ func TestService_checkPermission_folderCacheMissRecovery(t *testing.T) {
|
|||
|
||||
// Populate store with folders
|
||||
folderStore := &fakeStore{
|
||||
folders: []store.Folder{{UID: "root"}, {UID: "sub", ParentUID: strPtr("root")}},
|
||||
folders: []store.Folder{{UID: "root"}, {UID: "sub", ParentUID: new("root")}},
|
||||
disableNsCheck: true,
|
||||
}
|
||||
s.folderStore = folderStore
|
||||
|
|
@ -499,7 +499,7 @@ func TestService_listPermission_skipCache(t *testing.T) {
|
|||
|
||||
// Populate store with folders
|
||||
folderStore := &fakeStore{
|
||||
folders: []store.Folder{{UID: "root"}, {UID: "sub", ParentUID: strPtr("root")}},
|
||||
folders: []store.Folder{{UID: "root"}, {UID: "sub", ParentUID: new("root")}},
|
||||
disableNsCheck: true,
|
||||
}
|
||||
s.folderStore = folderStore
|
||||
|
|
@ -887,11 +887,11 @@ func TestService_listPermission(t *testing.T) {
|
|||
},
|
||||
folders: []store.Folder{
|
||||
{UID: "some_folder_parent"},
|
||||
{UID: "some_folder_child", ParentUID: strPtr("some_folder_parent")},
|
||||
{UID: "some_folder_subchild1", ParentUID: strPtr("some_folder_child")},
|
||||
{UID: "some_folder_subchild2", ParentUID: strPtr("some_folder_child")},
|
||||
{UID: "some_folder_subsubchild", ParentUID: strPtr("some_folder_subchild2")},
|
||||
{UID: "some_folder_1", ParentUID: strPtr("some_other_folder")},
|
||||
{UID: "some_folder_child", ParentUID: new("some_folder_parent")},
|
||||
{UID: "some_folder_subchild1", ParentUID: new("some_folder_child")},
|
||||
{UID: "some_folder_subchild2", ParentUID: new("some_folder_child")},
|
||||
{UID: "some_folder_subsubchild", ParentUID: new("some_folder_subchild2")},
|
||||
{UID: "some_folder_1", ParentUID: new("some_other_folder")},
|
||||
},
|
||||
list: listRequest{
|
||||
Action: "dashboards:read",
|
||||
|
|
@ -921,7 +921,7 @@ func TestService_listPermission(t *testing.T) {
|
|||
},
|
||||
folders: []store.Folder{
|
||||
{UID: "some_folder_parent"},
|
||||
{UID: "some_folder_child", ParentUID: strPtr("some_folder_parent")},
|
||||
{UID: "some_folder_child", ParentUID: new("some_folder_parent")},
|
||||
},
|
||||
list: listRequest{
|
||||
Action: "dashboards:read",
|
||||
|
|
@ -952,9 +952,9 @@ func TestService_listPermission(t *testing.T) {
|
|||
},
|
||||
folders: []store.Folder{
|
||||
{UID: "some_folder_parent"},
|
||||
{UID: "some_folder_child", ParentUID: strPtr("some_folder_parent")},
|
||||
{UID: "some_folder_subchild", ParentUID: strPtr("some_folder_child")},
|
||||
{UID: "some_folder_child2", ParentUID: strPtr("some_folder_parent")},
|
||||
{UID: "some_folder_child", ParentUID: new("some_folder_parent")},
|
||||
{UID: "some_folder_subchild", ParentUID: new("some_folder_child")},
|
||||
{UID: "some_folder_child2", ParentUID: new("some_folder_parent")},
|
||||
},
|
||||
list: listRequest{
|
||||
Action: "dashboards:read",
|
||||
|
|
@ -991,7 +991,7 @@ func TestService_listPermission(t *testing.T) {
|
|||
},
|
||||
folders: []store.Folder{
|
||||
{UID: "some_folder_parent"},
|
||||
{UID: "some_folder_child", ParentUID: strPtr("some_folder_parent")},
|
||||
{UID: "some_folder_child", ParentUID: new("some_folder_parent")},
|
||||
},
|
||||
list: listRequest{
|
||||
Action: "folders:read",
|
||||
|
|
@ -2107,10 +2107,6 @@ func setupService() *Service {
|
|||
}
|
||||
}
|
||||
|
||||
func strPtr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
type fakeStore struct {
|
||||
store.Store
|
||||
// The namespace has to be set in the handlers for the correct organization to be picked up.
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ import (
|
|||
func Test_Tree(t *testing.T) {
|
||||
tree := newFolderTree([]store.Folder{
|
||||
{UID: "1"},
|
||||
{UID: "11", ParentUID: strPtr("1")},
|
||||
{UID: "12", ParentUID: strPtr("1")},
|
||||
{UID: "111", ParentUID: strPtr("11")},
|
||||
{UID: "1111", ParentUID: strPtr("111")},
|
||||
{UID: "121", ParentUID: strPtr("12")},
|
||||
{UID: "11", ParentUID: new("1")},
|
||||
{UID: "12", ParentUID: new("1")},
|
||||
{UID: "111", ParentUID: new("11")},
|
||||
{UID: "1111", ParentUID: new("111")},
|
||||
{UID: "121", ParentUID: new("12")},
|
||||
// not ordered insert to make sure patching works correctly
|
||||
{UID: "22", ParentUID: strPtr("2")},
|
||||
{UID: "222", ParentUID: strPtr("22")},
|
||||
{UID: "21", ParentUID: strPtr("2")},
|
||||
{UID: "22", ParentUID: new("2")},
|
||||
{UID: "222", ParentUID: new("22")},
|
||||
{UID: "21", ParentUID: new("2")},
|
||||
{UID: "2"},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -146,8 +146,8 @@ func WithManager(spec ...any) *FeatureManager {
|
|||
key := fmt.Sprintf("%v", spec[idx])
|
||||
val := true
|
||||
idx++
|
||||
if idx < count && reflect.TypeOf(spec[idx]).Kind() == reflect.Bool {
|
||||
val = spec[idx].(bool)
|
||||
if idx < count && reflect.TypeOf(spec[idx]).Kind() == reflect.Bool { // #nosec G602 -- bounds checked by `idx < count`
|
||||
val = spec[idx].(bool) // #nosec G602 -- bounds checked by `idx < count`
|
||||
idx++
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ func (s *Service) getAvailableNonRootFolders(ctx context.Context, q *folder.GetC
|
|||
}
|
||||
|
||||
func (s *Service) deduplicateAvailableFolders(ctx context.Context, folders []*folder.Folder, rootFolders []*folder.FolderReference) []*folder.FolderReference {
|
||||
foldersRef := make([]*folder.FolderReference, len(folders))
|
||||
foldersRef := make([]*folder.FolderReference, len(folders), len(folders)+len(rootFolders))
|
||||
for i, f := range folders {
|
||||
foldersRef[i] = f.ToFolderReference()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@ func (p *IndexProvider) HandleRequest(writer http.ResponseWriter, request *http.
|
|||
if p.config.AppSubURL != "" {
|
||||
cookiePath = data.AppSubUrl
|
||||
}
|
||||
// #nosec G124 -- HttpOnly/Secure/SameSite are explicitly set above
|
||||
http.SetCookie(writer, &http.Cookie{
|
||||
Name: "login_error",
|
||||
Value: "",
|
||||
|
|
|
|||
|
|
@ -16,19 +16,18 @@ import (
|
|||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
)
|
||||
|
||||
var orgID = rand.Int63()
|
||||
|
||||
func TestFilterByAccess(t *testing.T) {
|
||||
global := testSilence("global", nil)
|
||||
ruleSilence1 := testSilence("rule-1", utils.Pointer("rule-1-uid"))
|
||||
ruleSilence1 := testSilence("rule-1", new("rule-1-uid"))
|
||||
folder1 := "rule-1-folder-uid"
|
||||
folder1Scope := folder.ScopeFoldersProvider.GetResourceScopeUID(folder1)
|
||||
ruleSilence2 := testSilence("rule-2", utils.Pointer("rule-2-uid"))
|
||||
ruleSilence2 := testSilence("rule-2", new("rule-2-uid"))
|
||||
folder2 := "rule-2-folder-uid"
|
||||
notFoundRule := testSilence("unknown-rule", utils.Pointer("unknown-rule-uid"))
|
||||
notFoundRule := testSilence("unknown-rule", new("unknown-rule-uid"))
|
||||
|
||||
silences := []*models.Silence{
|
||||
global,
|
||||
|
|
@ -123,12 +122,12 @@ func TestFilterByAccess(t *testing.T) {
|
|||
|
||||
func TestAuthorizeReadSilence(t *testing.T) {
|
||||
global := testSilence("global", nil)
|
||||
ruleSilence1 := testSilence("rule-1", utils.Pointer("rule-1-uid"))
|
||||
ruleSilence1 := testSilence("rule-1", new("rule-1-uid"))
|
||||
folder1 := "rule-1-folder-uid"
|
||||
folder1Scope := folder.ScopeFoldersProvider.GetResourceScopeUID(folder1)
|
||||
ruleSilence2 := testSilence("rule-2", utils.Pointer("rule-2-uid"))
|
||||
ruleSilence2 := testSilence("rule-2", new("rule-2-uid"))
|
||||
folder2 := "rule-2-folder-uid"
|
||||
notFoundRule := testSilence("unknown-rule", utils.Pointer("unknown-rule-uid"))
|
||||
notFoundRule := testSilence("unknown-rule", new("unknown-rule-uid"))
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
|
@ -226,13 +225,13 @@ func TestAuthorizeReadSilence(t *testing.T) {
|
|||
|
||||
func TestAuthorizeCreateSilence(t *testing.T) {
|
||||
global := testSilence("global", nil)
|
||||
ruleSilence1 := testSilence("rule-1", utils.Pointer("rule-1-uid"))
|
||||
ruleSilence1 := testSilence("rule-1", new("rule-1-uid"))
|
||||
folder1 := "rule-1-folder-uid"
|
||||
folder1Scope := folder.ScopeFoldersProvider.GetResourceScopeUID(folder1)
|
||||
ruleSilence2 := testSilence("rule-2", utils.Pointer("rule-2-uid"))
|
||||
ruleSilence2 := testSilence("rule-2", new("rule-2-uid"))
|
||||
folder2 := "rule-2-folder-uid"
|
||||
folder2Scope := folder.ScopeFoldersProvider.GetResourceScopeUID(folder2)
|
||||
notFoundRule := testSilence("unknown-rule", utils.Pointer("unknown-rule-uid"))
|
||||
notFoundRule := testSilence("unknown-rule", new("unknown-rule-uid"))
|
||||
|
||||
silences := []*models.Silence{
|
||||
global,
|
||||
|
|
@ -403,13 +402,13 @@ func TestAuthorizeCreateSilence(t *testing.T) {
|
|||
|
||||
func TestAuthorizeUpdateSilence(t *testing.T) {
|
||||
global := testSilence("global", nil)
|
||||
ruleSilence1 := testSilence("rule-1", utils.Pointer("rule-1-uid"))
|
||||
ruleSilence1 := testSilence("rule-1", new("rule-1-uid"))
|
||||
folder1 := "rule-1-folder-uid"
|
||||
folder1Scope := folder.ScopeFoldersProvider.GetResourceScopeUID(folder1)
|
||||
ruleSilence2 := testSilence("rule-2", utils.Pointer("rule-2-uid"))
|
||||
ruleSilence2 := testSilence("rule-2", new("rule-2-uid"))
|
||||
folder2 := "rule-2-folder-uid"
|
||||
folder2Scope := folder.ScopeFoldersProvider.GetResourceScopeUID(folder2)
|
||||
notFoundRule := testSilence("unknown-rule", utils.Pointer("unknown-rule-uid"))
|
||||
notFoundRule := testSilence("unknown-rule", new("unknown-rule-uid"))
|
||||
|
||||
silences := []*models.Silence{
|
||||
global,
|
||||
|
|
@ -580,13 +579,13 @@ func TestAuthorizeUpdateSilence(t *testing.T) {
|
|||
|
||||
func TestSilenceAccess(t *testing.T) {
|
||||
global := testSilence("global", nil)
|
||||
ruleSilence1 := testSilence("rule-1", utils.Pointer("rule-1-uid"))
|
||||
ruleSilence1 := testSilence("rule-1", new("rule-1-uid"))
|
||||
folder1 := "rule-1-folder-uid"
|
||||
folder1Scope := folder.ScopeFoldersProvider.GetResourceScopeUID(folder1)
|
||||
ruleSilence2 := testSilence("rule-2", utils.Pointer("rule-2-uid"))
|
||||
ruleSilence2 := testSilence("rule-2", new("rule-2-uid"))
|
||||
folder2 := "rule-2-folder-uid"
|
||||
folder2Scope := folder.ScopeFoldersProvider.GetResourceScopeUID(folder2)
|
||||
notFoundRule := testSilence("unknown-rule", utils.Pointer("unknown-rule-uid"))
|
||||
notFoundRule := testSilence("unknown-rule", new("unknown-rule-uid"))
|
||||
|
||||
silences := []*models.Silence{
|
||||
global,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ func TestLokiConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
cases := []testCase{
|
||||
// #nosec G101 -- test fixture, not a real credential
|
||||
{
|
||||
name: "remote url only",
|
||||
in: setting.UnifiedAlertingLokiSettings{
|
||||
|
|
@ -26,6 +27,7 @@ func TestLokiConfig(t *testing.T) {
|
|||
expRead: "http://url.com",
|
||||
expWrite: "http://url.com",
|
||||
},
|
||||
// #nosec G101 -- test fixture, not a real credential
|
||||
{
|
||||
name: "separate urls",
|
||||
in: setting.UnifiedAlertingLokiSettings{
|
||||
|
|
@ -35,6 +37,7 @@ func TestLokiConfig(t *testing.T) {
|
|||
expRead: "http://read.url.com",
|
||||
expWrite: "http://write.url.com",
|
||||
},
|
||||
// #nosec G101 -- test fixture, not a real credential
|
||||
{
|
||||
name: "single fallback",
|
||||
in: setting.UnifiedAlertingLokiSettings{
|
||||
|
|
|
|||
|
|
@ -1100,7 +1100,7 @@ func TestGeneratorFillsAllFields(t *testing.T) {
|
|||
for j := 0; j < tpe.NumField(); j++ {
|
||||
field := tpe.Field(j)
|
||||
value := v.Field(j)
|
||||
if !value.IsValid() || value.Kind() == reflect.Ptr && value.IsNil() || value.IsZero() {
|
||||
if !value.IsValid() || value.Kind() == reflect.Pointer && value.IsNil() || value.IsZero() {
|
||||
continue
|
||||
}
|
||||
delete(fields, field.Name)
|
||||
|
|
@ -1143,7 +1143,7 @@ func TestGeneratorFillsAllRecordingRuleFields(t *testing.T) {
|
|||
for j := 0; j < tpe.NumField(); j++ {
|
||||
field := tpe.Field(j)
|
||||
value := v.Field(j)
|
||||
if !value.IsValid() || value.Kind() == reflect.Ptr && value.IsNil() || value.IsZero() {
|
||||
if !value.IsValid() || value.Kind() == reflect.Pointer && value.IsNil() || value.IsZero() {
|
||||
continue
|
||||
}
|
||||
delete(fields, field.Name)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func (r IntegrationDiffReport) getMap(v reflect.Value) (reflect.Value, bool) {
|
|||
if v.Kind() == reflect.Map {
|
||||
return v, true
|
||||
}
|
||||
if v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface {
|
||||
if v.Kind() == reflect.Pointer || v.Kind() == reflect.Interface {
|
||||
return r.getMap(v.Elem())
|
||||
}
|
||||
return reflect.Value{}, false
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
"github.com/grafana/grafana/pkg/services/org"
|
||||
secrets_fakes "github.com/grafana/grafana/pkg/services/secrets/fakes"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
)
|
||||
|
||||
func TestReceiverTestingService_TestNewReceiverIntegration(t *testing.T) {
|
||||
|
|
@ -114,7 +113,7 @@ func TestReceiverTestingService_TestNewReceiverIntegration(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "error if integration UID is not empty",
|
||||
integration: utils.Pointer(models.IntegrationGen()()),
|
||||
integration: new(models.IntegrationGen()()),
|
||||
user: userAuthorizedToCreate,
|
||||
expectedErr: models.ErrReceiverTestingInvalidIntegrationBase,
|
||||
},
|
||||
|
|
@ -272,13 +271,13 @@ func TestReceiverTestingService_PatchIntegrationAndTest(t *testing.T) {
|
|||
{
|
||||
name: "error if integration does not exist in receiver",
|
||||
receiverUID: receiverUID,
|
||||
integration: utils.Pointer(models.IntegrationGen(models.IntegrationMuts.WithUID("other-integration"))()),
|
||||
integration: new(models.IntegrationGen(models.IntegrationMuts.WithUID("other-integration"))()),
|
||||
expectedErr: models.ErrReceiverTestingIntegrationNotFound,
|
||||
},
|
||||
{
|
||||
name: "error if user changes protected field (url) without permission",
|
||||
receiverUID: receiverUID,
|
||||
integration: utils.Pointer(models.IntegrationGen(
|
||||
integration: new(models.IntegrationGen(
|
||||
models.IntegrationMuts.WithUID(integrationUID),
|
||||
models.IntegrationMuts.WithValidConfig("webhook"),
|
||||
models.IntegrationMuts.AddSetting("url", "http://different-url.com"),
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ import (
|
|||
"github.com/grafana/grafana/pkg/util/testutil"
|
||||
)
|
||||
|
||||
func ptrTo[T any](v T) *T { return &v }
|
||||
|
||||
func TestIntegrationSendingToExternalAlertmanager(t *testing.T) {
|
||||
testutil.SkipIntegrationTestInShortMode(t)
|
||||
|
||||
|
|
@ -67,7 +65,7 @@ func TestIntegrationSendingToExternalAlertmanager(t *testing.T) {
|
|||
&fake_ds.FakeDataSourceService{DataSources: []*datasources.DataSource{&ds1}}, fake_secrets.NewFakeSecretsService(), featuremgmt.WithFeatures(), false, metrics.NewSenderMetrics(prometheus.NewPedanticRegistry()))
|
||||
|
||||
mockedGetAdminConfigurations.Return([]*models.AdminConfiguration{
|
||||
{OrgID: ruleKey.OrgID, SendAlertsTo: ptrTo(models.AllAlertmanagers)},
|
||||
{OrgID: ruleKey.OrgID, SendAlertsTo: new(models.AllAlertmanagers)},
|
||||
}, nil)
|
||||
// Make sure we sync the configuration at least once before the evaluation happens to guarantee the sender is running
|
||||
// when the first alert triggers.
|
||||
|
|
@ -137,7 +135,7 @@ func TestIntegrationSendingToExternalAlertmanager_WithMultipleOrgs(t *testing.T)
|
|||
fakeDs, fake_secrets.NewFakeSecretsService(), featuremgmt.WithFeatures(), false, metrics.NewSenderMetrics(prometheus.NewPedanticRegistry()))
|
||||
|
||||
mockedGetAdminConfigurations.Return([]*models.AdminConfiguration{
|
||||
{OrgID: ruleKey1.OrgID, SendAlertsTo: ptrTo(models.AllAlertmanagers)},
|
||||
{OrgID: ruleKey1.OrgID, SendAlertsTo: new(models.AllAlertmanagers)},
|
||||
}, nil)
|
||||
|
||||
// Make sure we sync the configuration at least once before the evaluation happens to guarantee the sender is running
|
||||
|
|
@ -162,7 +160,7 @@ func TestIntegrationSendingToExternalAlertmanager_WithMultipleOrgs(t *testing.T)
|
|||
fakeDs.DataSources = append(fakeDs.DataSources, &ds2)
|
||||
|
||||
mockedGetAdminConfigurations.Return([]*models.AdminConfiguration{
|
||||
{OrgID: ruleKey1.OrgID, SendAlertsTo: ptrTo(models.AllAlertmanagers)},
|
||||
{OrgID: ruleKey1.OrgID, SendAlertsTo: new(models.AllAlertmanagers)},
|
||||
{OrgID: ruleKey2.OrgID},
|
||||
}, nil)
|
||||
|
||||
|
|
@ -208,7 +206,7 @@ func TestIntegrationSendingToExternalAlertmanager_WithMultipleOrgs(t *testing.T)
|
|||
fakeDs.DataSources = append(fakeDs.DataSources, &ds3)
|
||||
|
||||
mockedGetAdminConfigurations.Return([]*models.AdminConfiguration{
|
||||
{OrgID: ruleKey1.OrgID, SendAlertsTo: ptrTo(models.AllAlertmanagers)},
|
||||
{OrgID: ruleKey1.OrgID, SendAlertsTo: new(models.AllAlertmanagers)},
|
||||
{OrgID: ruleKey2.OrgID},
|
||||
}, nil)
|
||||
|
||||
|
|
@ -228,7 +226,7 @@ func TestIntegrationSendingToExternalAlertmanager_WithMultipleOrgs(t *testing.T)
|
|||
// 3. Now, let's provide a configuration that fails for OrgID = 1.
|
||||
fakeDs.DataSources[0].URL = "123://invalid.org"
|
||||
mockedGetAdminConfigurations.Return([]*models.AdminConfiguration{
|
||||
{OrgID: ruleKey1.OrgID, SendAlertsTo: ptrTo(models.AllAlertmanagers)},
|
||||
{OrgID: ruleKey1.OrgID, SendAlertsTo: new(models.AllAlertmanagers)},
|
||||
{OrgID: ruleKey2.OrgID},
|
||||
}, nil)
|
||||
|
||||
|
|
@ -245,7 +243,7 @@ func TestIntegrationSendingToExternalAlertmanager_WithMultipleOrgs(t *testing.T)
|
|||
// If we fix it - it should be applied.
|
||||
fakeDs.DataSources[0].URL = "notarealalertmanager:3030"
|
||||
mockedGetAdminConfigurations.Return([]*models.AdminConfiguration{
|
||||
{OrgID: ruleKey1.OrgID, SendAlertsTo: ptrTo(models.AllAlertmanagers)},
|
||||
{OrgID: ruleKey1.OrgID, SendAlertsTo: new(models.AllAlertmanagers)},
|
||||
{OrgID: ruleKey2.OrgID},
|
||||
}, nil)
|
||||
|
||||
|
|
@ -296,7 +294,7 @@ func TestChangingAlertmanagersChoice(t *testing.T) {
|
|||
10*time.Minute, &fake_ds.FakeDataSourceService{DataSources: []*datasources.DataSource{&ds}}, fake_secrets.NewFakeSecretsService(), featuremgmt.WithFeatures(), false, metrics.NewSenderMetrics(prometheus.NewPedanticRegistry()))
|
||||
|
||||
mockedGetAdminConfigurations.Return([]*models.AdminConfiguration{
|
||||
{OrgID: ruleKey.OrgID, SendAlertsTo: ptrTo(models.AllAlertmanagers)},
|
||||
{OrgID: ruleKey.OrgID, SendAlertsTo: new(models.AllAlertmanagers)},
|
||||
}, nil)
|
||||
// Make sure we sync the configuration at least once before the evaluation happens to guarantee the sender is running
|
||||
// when the first alert triggers.
|
||||
|
|
@ -322,7 +320,7 @@ func TestChangingAlertmanagersChoice(t *testing.T) {
|
|||
|
||||
// Now, let's change the Alertmanagers choice to send only to the external Alertmanager.
|
||||
mockedGetAdminConfigurations.Return([]*models.AdminConfiguration{
|
||||
{OrgID: ruleKey.OrgID, SendAlertsTo: ptrTo(models.ExternalAlertmanagers)},
|
||||
{OrgID: ruleKey.OrgID, SendAlertsTo: new(models.ExternalAlertmanagers)},
|
||||
}, nil)
|
||||
// Again, make sure we sync and verify the externalAlertmanagers.
|
||||
require.NoError(t, alertsRouter.SyncAndApplyConfigFromDatabase(context.Background()))
|
||||
|
|
@ -334,7 +332,7 @@ func TestChangingAlertmanagersChoice(t *testing.T) {
|
|||
|
||||
// Finally, let's change the Alertmanagers choice to send only to the internal Alertmanager.
|
||||
mockedGetAdminConfigurations.Return([]*models.AdminConfiguration{
|
||||
{OrgID: ruleKey.OrgID, SendAlertsTo: ptrTo(models.InternalAlertmanager)},
|
||||
{OrgID: ruleKey.OrgID, SendAlertsTo: new(models.InternalAlertmanager)},
|
||||
}, nil)
|
||||
|
||||
// Again, make sure we sync and verify the externalAlertmanagers.
|
||||
|
|
@ -400,7 +398,7 @@ func TestAlertmanagersChoiceWithDisableExternalFeatureToggle(t *testing.T) {
|
|||
// Test that we only send to the internal Alertmanager even though the configuration specifies AllAlertmanagers.
|
||||
|
||||
mockedGetAdminConfigurations.Return([]*models.AdminConfiguration{
|
||||
{OrgID: ruleKey.OrgID, SendAlertsTo: ptrTo(models.AllAlertmanagers)},
|
||||
{OrgID: ruleKey.OrgID, SendAlertsTo: new(models.AllAlertmanagers)},
|
||||
}, nil)
|
||||
|
||||
require.NoError(t, alertsRouter.SyncAndApplyConfigFromDatabase(context.Background()))
|
||||
|
|
@ -419,7 +417,7 @@ func TestAlertmanagersChoiceWithDisableExternalFeatureToggle(t *testing.T) {
|
|||
// Test that we still only send to the internal alertmanager even though the configuration specifies ExternalAlertmanagers.
|
||||
|
||||
mockedGetAdminConfigurations.Return([]*models.AdminConfiguration{
|
||||
{OrgID: ruleKey.OrgID, SendAlertsTo: ptrTo(models.ExternalAlertmanagers)},
|
||||
{OrgID: ruleKey.OrgID, SendAlertsTo: new(models.ExternalAlertmanagers)},
|
||||
}, nil)
|
||||
|
||||
require.NoError(t, alertsRouter.SyncAndApplyConfigFromDatabase(context.Background()))
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ func TestApiCreatePublicDashboard(t *testing.T) {
|
|||
|
||||
//check the result if it's a 200
|
||||
if response.Code == http.StatusOK {
|
||||
val, err := json.Marshal(test.publicDashboard)
|
||||
val, err := json.Marshal(test.publicDashboard) // #nosec G117 -- test marshal of dashboard fixture
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, string(val), response.Body.String())
|
||||
}
|
||||
|
|
@ -599,7 +599,7 @@ func TestAPIUpdatePublicDashboard(t *testing.T) {
|
|||
|
||||
// check response when expected response is 200
|
||||
if test.ExpectedHttpResponse == http.StatusOK {
|
||||
val, err := json.Marshal(test.ExpectedResponse)
|
||||
val, err := json.Marshal(test.ExpectedResponse) // #nosec G117 -- test marshal of response fixture
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, string(val), response.Body.String())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
|
@ -125,7 +124,7 @@ func TestAPIQueryPublicDashboard(t *testing.T) {
|
|||
Name: "anyDataFrame",
|
||||
Fields: []*data.Field{
|
||||
data.NewField("anyGroupName", nil, []*string{
|
||||
aws.String("group_a"), aws.String("group_b"), aws.String("group_c"),
|
||||
new("group_a"), new("group_b"), new("group_c"),
|
||||
}),
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ func TestPreventOnCallAccessSeed(t *testing.T) {
|
|||
BuiltinRole, Action, Scope, Origin string
|
||||
}
|
||||
|
||||
want := []SeedAssignment{
|
||||
want := []SeedAssignment{ //nolint:prealloc
|
||||
{BuiltinRole: "Admin", Action: "plugins.app:access", Scope: "plugins:id:grafana-oncall-app", Origin: "grafana-oncall-app"},
|
||||
{BuiltinRole: "Editor", Action: "plugins.app:access", Scope: "plugins:id:grafana-oncall-app", Origin: "grafana-oncall-app"},
|
||||
{BuiltinRole: "Viewer", Action: "plugins.app:access", Scope: "plugins:id:grafana-oncall-app", Origin: "grafana-oncall-app"},
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ func (sess *DBSession) WithReturningID(driverName string, query string, args []a
|
|||
|
||||
func getTypeName(bean any) (res string) {
|
||||
t := reflect.TypeOf(bean)
|
||||
for t.Kind() == reflect.Ptr {
|
||||
for t.Kind() == reflect.Pointer {
|
||||
t = t.Elem()
|
||||
}
|
||||
return t.Name()
|
||||
|
|
|
|||
|
|
@ -97,17 +97,17 @@ func sqLite3TestDB() (*TestDB, error) {
|
|||
|
||||
ret.Cleanup = func() {
|
||||
// remove db file if it exists
|
||||
err := os.Remove(sqliteDb)
|
||||
err := os.Remove(sqliteDb) // #nosec G703 -- path returned by os.CreateTemp, not user input
|
||||
if err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||
fmt.Printf("Error removing sqlite db file %s: %v\n", sqliteDb, err)
|
||||
}
|
||||
|
||||
// remove wal & shm files if they exist
|
||||
err = os.Remove(sqliteDb + "-wal")
|
||||
err = os.Remove(sqliteDb + "-wal") // #nosec G703 -- path returned by os.CreateTemp, not user input
|
||||
if err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||
fmt.Printf("Error removing sqlite wal file %s: %v\n", sqliteDb+"-wal", err)
|
||||
}
|
||||
err = os.Remove(sqliteDb + "-shm")
|
||||
err = os.Remove(sqliteDb + "-shm") // #nosec G703 -- path returned by os.CreateTemp, not user input
|
||||
if err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||
fmt.Printf("Error removing sqlite shm file %s: %v\n", sqliteDb+"-shm", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func TestGdevReadSummaries(t *testing.T) {
|
|||
|
||||
if !bytes.Equal(out, golden) {
|
||||
failed = append(failed, uid)
|
||||
err = os.WriteFile(gpath, out, 0600)
|
||||
err = os.WriteFile(gpath, out, 0600) // #nosec G122 -- test golden-file regeneration on operator-controlled paths
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,37 +26,37 @@ func TestMaxDeptFolderSettings(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "returns default when value is not a valid integer",
|
||||
iniValue: strp("notanint"),
|
||||
iniValue: new("notanint"),
|
||||
expected: DefaultMaxNestedFolderDepth,
|
||||
},
|
||||
{
|
||||
name: "returns default when value is zero",
|
||||
iniValue: strp("0"),
|
||||
iniValue: new("0"),
|
||||
expected: DefaultMaxNestedFolderDepth,
|
||||
},
|
||||
{
|
||||
name: "returns default when value is negative",
|
||||
iniValue: strp("-1"),
|
||||
iniValue: new("-1"),
|
||||
expected: DefaultMaxNestedFolderDepth,
|
||||
},
|
||||
{
|
||||
name: "returns configured value when within range (3)",
|
||||
iniValue: strp("3"),
|
||||
iniValue: new("3"),
|
||||
expected: 3,
|
||||
},
|
||||
{
|
||||
name: "returns configured value when within range (6)",
|
||||
iniValue: strp("6"),
|
||||
iniValue: new("6"),
|
||||
expected: 6,
|
||||
},
|
||||
{
|
||||
name: "returns configured value when equals max",
|
||||
iniValue: strp("7"),
|
||||
iniValue: new("7"),
|
||||
expected: maxNestedFolderDepth,
|
||||
},
|
||||
{
|
||||
name: "clamps to max when value exceeds max",
|
||||
iniValue: strp("100"),
|
||||
iniValue: new("100"),
|
||||
expected: maxNestedFolderDepth,
|
||||
},
|
||||
}
|
||||
|
|
@ -80,5 +80,3 @@ func TestMaxDeptFolderSettings(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func strp(s string) *string { return &s }
|
||||
|
|
|
|||
|
|
@ -3186,7 +3186,7 @@ func testDataStoreBatchGet(t *testing.T, ctx context.Context, ds *dataStore) {
|
|||
|
||||
t.Run("batch get with some non-existent keys", func(t *testing.T) {
|
||||
// Create 3 existing keys
|
||||
existingKeys := make([]DataKey, 3)
|
||||
existingKeys := make([]DataKey, 3) //nolint:prealloc
|
||||
for i := 0; i < 3; i++ {
|
||||
rv := node.Generate().Int64()
|
||||
existingKeys[i] = DataKey{
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ func TestKvStorageBackend_WatchWriteEvents(t *testing.T) {
|
|||
require.Equal(t, rvs[j], writtenEvent.ResourceVersion)
|
||||
|
||||
if j > 0 {
|
||||
require.Equal(t, rvs[j-1], writtenEvent.PreviousRV)
|
||||
require.Equal(t, rvs[j-1], writtenEvent.PreviousRV) // #nosec G602 -- bounds checked by `j > 0`
|
||||
}
|
||||
case <-ctx.Done():
|
||||
require.FailNow(t, "timed out waiting for events")
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ func (s *DashboardDocumentBuilder) BuildDocument(ctx context.Context, key *resou
|
|||
}
|
||||
|
||||
func DashboardFields() []string {
|
||||
baseFields := []string{
|
||||
baseFields := []string{ //nolint:prealloc
|
||||
DASHBOARD_SCHEMA_VERSION,
|
||||
DASHBOARD_LINK_COUNT,
|
||||
DASHBOARD_PANEL_TYPES,
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func doSnapshotTests(t *testing.T, builder resource.DocumentBuilder, kind string
|
|||
// nolint:gosec
|
||||
expect, _ := os.ReadFile(outpath)
|
||||
if !assert.JSONEq(t, string(expect), string(out)) {
|
||||
err = os.WriteFile(outpath, out, 0600)
|
||||
err = os.WriteFile(outpath, out, 0600) // #nosec G703 -- test golden-file regeneration on controlled path
|
||||
require.NoError(t, err)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ func (s *StandardDocumentBuilders) GetDocumentBuilders() ([]resource.DocumentBui
|
|||
return nil, err
|
||||
}
|
||||
|
||||
result := []resource.DocumentBuilderInfo{
|
||||
result := []resource.DocumentBuilderInfo{ //nolint:prealloc
|
||||
{
|
||||
Builder: resource.StandardDocumentBuilder(resource.AppManifests()),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@ import (
|
|||
"github.com/grafana/grafana/pkg/util/testutil"
|
||||
)
|
||||
|
||||
func ptrTo[T any](v T) *T { return &v }
|
||||
|
||||
func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing.T) {
|
||||
testutil.SkipIntegrationTestInShortMode(t)
|
||||
|
||||
|
|
@ -93,7 +91,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
|||
// An invalid alertmanager choice should return an error.
|
||||
{
|
||||
ac := apimodels.PostableNGalertConfig{
|
||||
AlertmanagersChoice: ptrTo(apimodels.AlertmanagersChoice("invalid")),
|
||||
AlertmanagersChoice: new(apimodels.AlertmanagersChoice("invalid")),
|
||||
}
|
||||
buf := bytes.Buffer{}
|
||||
enc := json.NewEncoder(&buf)
|
||||
|
|
@ -114,7 +112,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
|||
// but never specify any. This should return an error.
|
||||
{
|
||||
ac := apimodels.PostableNGalertConfig{
|
||||
AlertmanagersChoice: ptrTo(apimodels.AlertmanagersChoice(ngmodels.ExternalAlertmanagers.String())),
|
||||
AlertmanagersChoice: new(apimodels.AlertmanagersChoice(ngmodels.ExternalAlertmanagers.String())),
|
||||
}
|
||||
buf := bytes.Buffer{}
|
||||
enc := json.NewEncoder(&buf)
|
||||
|
|
@ -189,7 +187,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
|||
// and make it so that only the external Alertmanagers handle the alerts.
|
||||
{
|
||||
ac := apimodels.PostableNGalertConfig{
|
||||
AlertmanagersChoice: ptrTo(apimodels.AlertmanagersChoice(ngmodels.ExternalAlertmanagers.String())),
|
||||
AlertmanagersChoice: new(apimodels.AlertmanagersChoice(ngmodels.ExternalAlertmanagers.String())),
|
||||
}
|
||||
buf := bytes.Buffer{}
|
||||
enc := json.NewEncoder(&buf)
|
||||
|
|
@ -318,7 +316,7 @@ func TestIntegrationAdminConfiguration_SendingToExternalAlertmanagers(t *testing
|
|||
// Sending an empty value for AlertmanagersChoice should default to AllAlertmanagers.
|
||||
{
|
||||
ac := apimodels.PostableNGalertConfig{
|
||||
AlertmanagersChoice: ptrTo(apimodels.AlertmanagersChoice("")),
|
||||
AlertmanagersChoice: new(apimodels.AlertmanagersChoice("")),
|
||||
}
|
||||
buf := bytes.Buffer{}
|
||||
enc := json.NewEncoder(&buf)
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ providers:
|
|||
input, err := os.ReadFile(filepath.Join("./home.json"))
|
||||
require.NoError(t, err)
|
||||
provDashboardFile := filepath.Join(provDashboardsDir, "home.json")
|
||||
err = os.WriteFile(provDashboardFile, input, 0644)
|
||||
err = os.WriteFile(provDashboardFile, input, 0644) // #nosec G703 -- test writes to caller-provided temp dir
|
||||
require.NoError(t, err)
|
||||
grafanaListedAddr, _ := testinfra.StartGrafanaEnv(t, dir, path)
|
||||
|
||||
|
|
@ -712,10 +712,6 @@ func createFolder(t *testing.T, grafanaListedAddr string, title string) *dtos.Fo
|
|||
return f
|
||||
}
|
||||
|
||||
func intPtr(n int) *int {
|
||||
return &n
|
||||
}
|
||||
|
||||
func TestIntegrationPreserveSchemaVersion(t *testing.T) {
|
||||
dir, path := testinfra.CreateGrafDir(t, testinfra.GrafanaOpts{
|
||||
DisableAnonymous: true,
|
||||
|
|
@ -723,7 +719,7 @@ func TestIntegrationPreserveSchemaVersion(t *testing.T) {
|
|||
|
||||
grafanaListedAddr, _ := testinfra.StartGrafanaEnv(t, dir, path)
|
||||
|
||||
schemaVersions := []*int{intPtr(1), intPtr(36), intPtr(40), nil}
|
||||
schemaVersions := []*int{new(1), new(36), new(40), nil}
|
||||
for _, schemaVersion := range schemaVersions {
|
||||
var title string
|
||||
if schemaVersion == nil {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import (
|
|||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/tests/apis"
|
||||
"github.com/grafana/grafana/pkg/tests/testinfra"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
"github.com/grafana/grafana/pkg/util/testutil"
|
||||
)
|
||||
|
||||
|
|
@ -519,7 +518,7 @@ func TestIntegrationTesting(t *testing.T) {
|
|||
Body: v1beta1.CreateReceiverIntegrationTestRequestBody{
|
||||
Alert: alert,
|
||||
Integration: v1beta1.CreateReceiverIntegrationTestRequestIntegration{
|
||||
Uid: utils.Pointer("test-uid"),
|
||||
Uid: new("test-uid"),
|
||||
Type: "webhook",
|
||||
Settings: map[string]interface{}{
|
||||
"url": server.URL + "/some-other",
|
||||
|
|
|
|||
|
|
@ -2099,7 +2099,7 @@ providers:
|
|||
input, err := os.ReadFile(filepath.Join("testdata/dashboard.json"))
|
||||
require.NoError(t, err)
|
||||
provDashboardFile := filepath.Join(provDashboardsDir, "dashboard.json")
|
||||
err = os.WriteFile(provDashboardFile, input, 0o644)
|
||||
err = os.WriteFile(provDashboardFile, input, 0o644) // #nosec G703 -- test writes to caller-provided temp dir
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@ func TestIntegrationProvisioning_ConnectionValidation(t *testing.T) {
|
|||
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
installation := github.InstallationToken{
|
||||
Token: github.Ptr("someToken"),
|
||||
Token: new("someToken"),
|
||||
ExpiresAt: &github.Timestamp{Time: time.Now().Add(time.Hour * 2)},
|
||||
}
|
||||
_, _ = w.Write(ghmock.MustMarshal(installation))
|
||||
|
|
@ -1096,10 +1096,10 @@ func TestIntegrationConnectionController_UnhealthyWithValidationErrors(t *testin
|
|||
ID: &appID,
|
||||
Slug: &appSlug,
|
||||
Permissions: &github.InstallationPermissions{
|
||||
Contents: github.Ptr("write"),
|
||||
Metadata: github.Ptr("read"),
|
||||
PullRequests: github.Ptr("write"),
|
||||
RepositoryHooks: github.Ptr("write"),
|
||||
Contents: new("write"),
|
||||
Metadata: new("read"),
|
||||
PullRequests: new("write"),
|
||||
RepositoryHooks: new("write"),
|
||||
},
|
||||
}))
|
||||
}),
|
||||
|
|
@ -1211,10 +1211,10 @@ func TestIntegrationConnectionController_UnhealthyWithValidationErrors(t *testin
|
|||
ID: &appID,
|
||||
Slug: &appSlug,
|
||||
Permissions: &github.InstallationPermissions{
|
||||
Contents: github.Ptr("write"),
|
||||
Metadata: github.Ptr("read"),
|
||||
PullRequests: github.Ptr("write"),
|
||||
RepositoryHooks: github.Ptr("write"),
|
||||
Contents: new("write"),
|
||||
Metadata: new("read"),
|
||||
PullRequests: new("write"),
|
||||
RepositoryHooks: new("write"),
|
||||
},
|
||||
}))
|
||||
}),
|
||||
|
|
@ -1331,10 +1331,10 @@ func TestIntegrationConnectionController_FieldErrorsCleared(t *testing.T) {
|
|||
ID: &appID,
|
||||
Slug: &appSlug,
|
||||
Permissions: &github.InstallationPermissions{
|
||||
Contents: github.Ptr("write"),
|
||||
Metadata: github.Ptr("read"),
|
||||
PullRequests: github.Ptr("write"),
|
||||
RepositoryHooks: github.Ptr("write"),
|
||||
Contents: new("write"),
|
||||
Metadata: new("read"),
|
||||
PullRequests: new("write"),
|
||||
RepositoryHooks: new("write"),
|
||||
},
|
||||
},
|
||||
),
|
||||
|
|
@ -1392,10 +1392,10 @@ func TestIntegrationConnectionController_FieldErrorsCleared(t *testing.T) {
|
|||
ID: &appID,
|
||||
Slug: &appSlug,
|
||||
Permissions: &github.InstallationPermissions{
|
||||
Contents: github.Ptr("write"),
|
||||
Metadata: github.Ptr("read"),
|
||||
PullRequests: github.Ptr("write"),
|
||||
RepositoryHooks: github.Ptr("write"),
|
||||
Contents: new("write"),
|
||||
Metadata: new("read"),
|
||||
PullRequests: new("write"),
|
||||
RepositoryHooks: new("write"),
|
||||
},
|
||||
},
|
||||
),
|
||||
|
|
@ -1403,10 +1403,10 @@ func TestIntegrationConnectionController_FieldErrorsCleared(t *testing.T) {
|
|||
ghmock.GetAppInstallationsByInstallationId, github.Installation{
|
||||
ID: &validInstallationID,
|
||||
Permissions: &github.InstallationPermissions{
|
||||
Contents: github.Ptr("write"),
|
||||
Metadata: github.Ptr("read"),
|
||||
PullRequests: github.Ptr("write"),
|
||||
RepositoryHooks: github.Ptr("write"),
|
||||
Contents: new("write"),
|
||||
Metadata: new("read"),
|
||||
PullRequests: new("write"),
|
||||
RepositoryHooks: new("write"),
|
||||
},
|
||||
},
|
||||
),
|
||||
|
|
@ -1879,10 +1879,10 @@ func verifyToken(t *testing.T, appID, token string) (bool, error) {
|
|||
// createInstallationWithPermissions creates a GitHub installation with specific permissions
|
||||
func createAppWithPermissions(id int64, permissions map[string]string) *github.App {
|
||||
app := &github.App{
|
||||
ID: github.Ptr(id),
|
||||
Slug: github.Ptr("test-app"),
|
||||
ID: new(id),
|
||||
Slug: new("test-app"),
|
||||
Owner: &github.User{
|
||||
Login: github.Ptr("test-owner"),
|
||||
Login: new("test-owner"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -1891,16 +1891,16 @@ func createAppWithPermissions(id int64, permissions map[string]string) *github.A
|
|||
installationPerms := &github.InstallationPermissions{}
|
||||
|
||||
if contents, ok := permissions["contents"]; ok {
|
||||
installationPerms.Contents = github.Ptr(contents)
|
||||
installationPerms.Contents = new(contents)
|
||||
}
|
||||
if metadata, ok := permissions["metadata"]; ok {
|
||||
installationPerms.Metadata = github.Ptr(metadata)
|
||||
installationPerms.Metadata = new(metadata)
|
||||
}
|
||||
if prs, ok := permissions["pull_requests"]; ok {
|
||||
installationPerms.PullRequests = github.Ptr(prs)
|
||||
installationPerms.PullRequests = new(prs)
|
||||
}
|
||||
if hooks, ok := permissions["webhooks"]; ok {
|
||||
installationPerms.RepositoryHooks = github.Ptr(hooks)
|
||||
installationPerms.RepositoryHooks = new(hooks)
|
||||
}
|
||||
|
||||
app.Permissions = installationPerms
|
||||
|
|
@ -1912,12 +1912,12 @@ func createAppWithPermissions(id int64, permissions map[string]string) *github.A
|
|||
// createInstallationWithPermissions creates a GitHub installation with specific permissions
|
||||
func createAppInstallationWithPermissions(id int64, permissions map[string]string) *github.Installation {
|
||||
installation := &github.Installation{
|
||||
ID: github.Ptr(id),
|
||||
ID: new(id),
|
||||
Permissions: &github.InstallationPermissions{
|
||||
Contents: github.Ptr("write"),
|
||||
Metadata: github.Ptr("read"),
|
||||
PullRequests: github.Ptr("write"),
|
||||
RepositoryHooks: github.Ptr("write"),
|
||||
Contents: new("write"),
|
||||
Metadata: new("read"),
|
||||
PullRequests: new("write"),
|
||||
RepositoryHooks: new("write"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -1926,16 +1926,16 @@ func createAppInstallationWithPermissions(id int64, permissions map[string]strin
|
|||
installationPerms := &github.InstallationPermissions{}
|
||||
|
||||
if contents, ok := permissions["contents"]; ok {
|
||||
installationPerms.Contents = github.Ptr(contents)
|
||||
installationPerms.Contents = new(contents)
|
||||
}
|
||||
if metadata, ok := permissions["metadata"]; ok {
|
||||
installationPerms.Metadata = github.Ptr(metadata)
|
||||
installationPerms.Metadata = new(metadata)
|
||||
}
|
||||
if prs, ok := permissions["pull_requests"]; ok {
|
||||
installationPerms.PullRequests = github.Ptr(prs)
|
||||
installationPerms.PullRequests = new(prs)
|
||||
}
|
||||
if hooks, ok := permissions["webhooks"]; ok {
|
||||
installationPerms.RepositoryHooks = github.Ptr(hooks)
|
||||
installationPerms.RepositoryHooks = new(hooks)
|
||||
}
|
||||
|
||||
installation.Permissions = installationPerms
|
||||
|
|
@ -2040,12 +2040,12 @@ func TestIntegrationProvisioning_GithubAppPermissionValidation(t *testing.T) {
|
|||
|
||||
app := createAppWithPermissions(123456, tc.permissions)
|
||||
installation := &github.Installation{
|
||||
ID: github.Ptr(int64(454545)),
|
||||
ID: new(int64(454545)),
|
||||
Permissions: &github.InstallationPermissions{
|
||||
Contents: github.Ptr("write"),
|
||||
Metadata: github.Ptr("read"),
|
||||
PullRequests: github.Ptr("write"),
|
||||
RepositoryHooks: github.Ptr("write"),
|
||||
Contents: new("write"),
|
||||
Metadata: new("read"),
|
||||
PullRequests: new("write"),
|
||||
RepositoryHooks: new("write"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -2252,16 +2252,16 @@ func TestIntegrationProvisioning_GithubAppInstallationPermissionValidation(t *te
|
|||
connectionFactory := helper.GetEnv().GithubConnectionFactory.(*githubConnection.Factory)
|
||||
|
||||
app := &github.App{
|
||||
ID: github.Ptr(int64(123456)),
|
||||
Slug: github.Ptr("test-app"),
|
||||
ID: new(int64(123456)),
|
||||
Slug: new("test-app"),
|
||||
Owner: &github.User{
|
||||
Login: github.Ptr("test-owner"),
|
||||
Login: new("test-owner"),
|
||||
},
|
||||
Permissions: &github.InstallationPermissions{
|
||||
Contents: github.Ptr("write"),
|
||||
Metadata: github.Ptr("read"),
|
||||
PullRequests: github.Ptr("write"),
|
||||
RepositoryHooks: github.Ptr("write"),
|
||||
Contents: new("write"),
|
||||
Metadata: new("read"),
|
||||
PullRequests: new("write"),
|
||||
RepositoryHooks: new("write"),
|
||||
},
|
||||
}
|
||||
installation := createAppInstallationWithPermissions(454545, tc.permissions)
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ func TestIntegrationProvisioning_ConnectionTestEndpointWithPermissions(t *testin
|
|||
"webhooks": "read", // needs write
|
||||
})
|
||||
installation := &github.Installation{
|
||||
ID: github.Ptr(int64(454545)),
|
||||
ID: new(int64(454545)),
|
||||
}
|
||||
|
||||
connectionFactory.Client = ghmock.NewMockedHTTPClient(
|
||||
|
|
@ -483,12 +483,12 @@ func TestIntegrationProvisioning_ConnectionTestEndpointWithPermissions(t *testin
|
|||
"webhooks": "write",
|
||||
})
|
||||
installation := &github.Installation{
|
||||
ID: github.Ptr(int64(454545)),
|
||||
ID: new(int64(454545)),
|
||||
Permissions: &github.InstallationPermissions{
|
||||
Contents: github.Ptr("write"),
|
||||
Metadata: github.Ptr("read"),
|
||||
PullRequests: github.Ptr("write"),
|
||||
RepositoryHooks: github.Ptr("write"),
|
||||
Contents: new("write"),
|
||||
Metadata: new("read"),
|
||||
PullRequests: new("write"),
|
||||
RepositoryHooks: new("write"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -765,10 +765,10 @@ func TestIntegrationProvisioning_GitRepositoryWritePermissions(t *testing.T) {
|
|||
|
||||
func createAppWithPermissions(id int64, permissions map[string]string) *github.App {
|
||||
app := &github.App{
|
||||
ID: github.Ptr(id),
|
||||
Slug: github.Ptr("test-app"),
|
||||
ID: new(id),
|
||||
Slug: new("test-app"),
|
||||
Owner: &github.User{
|
||||
Login: github.Ptr("test-owner"),
|
||||
Login: new("test-owner"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -776,16 +776,16 @@ func createAppWithPermissions(id int64, permissions map[string]string) *github.A
|
|||
installationPerms := &github.InstallationPermissions{}
|
||||
|
||||
if contents, ok := permissions["contents"]; ok {
|
||||
installationPerms.Contents = github.Ptr(contents)
|
||||
installationPerms.Contents = new(contents)
|
||||
}
|
||||
if metadata, ok := permissions["metadata"]; ok {
|
||||
installationPerms.Metadata = github.Ptr(metadata)
|
||||
installationPerms.Metadata = new(metadata)
|
||||
}
|
||||
if prs, ok := permissions["pull_requests"]; ok {
|
||||
installationPerms.PullRequests = github.Ptr(prs)
|
||||
installationPerms.PullRequests = new(prs)
|
||||
}
|
||||
if hooks, ok := permissions["webhooks"]; ok {
|
||||
installationPerms.RepositoryHooks = github.Ptr(hooks)
|
||||
installationPerms.RepositoryHooks = new(hooks)
|
||||
}
|
||||
|
||||
app.Permissions = installationPerms
|
||||
|
|
@ -796,12 +796,12 @@ func createAppWithPermissions(id int64, permissions map[string]string) *github.A
|
|||
|
||||
func createAppInstallationWithPermissions(id int64, permissions map[string]string) *github.Installation {
|
||||
installation := &github.Installation{
|
||||
ID: github.Ptr(id),
|
||||
ID: new(id),
|
||||
Permissions: &github.InstallationPermissions{
|
||||
Contents: github.Ptr("write"),
|
||||
Metadata: github.Ptr("read"),
|
||||
PullRequests: github.Ptr("write"),
|
||||
RepositoryHooks: github.Ptr("write"),
|
||||
Contents: new("write"),
|
||||
Metadata: new("read"),
|
||||
PullRequests: new("write"),
|
||||
RepositoryHooks: new("write"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -809,16 +809,16 @@ func createAppInstallationWithPermissions(id int64, permissions map[string]strin
|
|||
installationPerms := &github.InstallationPermissions{}
|
||||
|
||||
if contents, ok := permissions["contents"]; ok {
|
||||
installationPerms.Contents = github.Ptr(contents)
|
||||
installationPerms.Contents = new(contents)
|
||||
}
|
||||
if metadata, ok := permissions["metadata"]; ok {
|
||||
installationPerms.Metadata = github.Ptr(metadata)
|
||||
installationPerms.Metadata = new(metadata)
|
||||
}
|
||||
if prs, ok := permissions["pull_requests"]; ok {
|
||||
installationPerms.PullRequests = github.Ptr(prs)
|
||||
installationPerms.PullRequests = new(prs)
|
||||
}
|
||||
if hooks, ok := permissions["webhooks"]; ok {
|
||||
installationPerms.RepositoryHooks = github.Ptr(hooks)
|
||||
installationPerms.RepositoryHooks = new(hooks)
|
||||
}
|
||||
|
||||
installation.Permissions = installationPerms
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ func loginUser(t *testing.T, addr, username, password string) *http.Cookie {
|
|||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
data, err := json.Marshal(&body{username, password})
|
||||
data, err := json.Marshal(&body{username, password}) // #nosec G117 -- test login request marshal
|
||||
require.NoError(t, err)
|
||||
|
||||
request, err := http.NewRequest(http.MethodPost, fmt.Sprintf("http://%s/login", addr), bytes.NewReader(data))
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ func (e *AzureLogAnalyticsDatasource) ResourceRequest(rw http.ResponseWriter, re
|
|||
// Add necessary query params
|
||||
queryParams.Add("select", "categories,solutions,tables,workspaces")
|
||||
req.URL.RawQuery = queryParams.Encode()
|
||||
resp, err := cli.Do(req)
|
||||
resp, err := cli.Do(req) // #nosec G704 -- datasource client targets operator-configured URL
|
||||
if err != nil {
|
||||
statusCode := http.StatusInternalServerError
|
||||
if resp != nil {
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@ import (
|
|||
"github.com/grafana/grafana/pkg/tsdb/azuremonitor/types"
|
||||
)
|
||||
|
||||
func makeQueryPointer(q AzureLogAnalyticsQuery) *AzureLogAnalyticsQuery {
|
||||
return &q
|
||||
}
|
||||
|
||||
func TestBuildLogAnalyticsQuery(t *testing.T) {
|
||||
fromStart := time.Date(2018, 3, 15, 13, 0, 0, 0, time.UTC).In(time.Local)
|
||||
timeRange := backend.TimeRange{From: fromStart, To: fromStart.Add(34 * time.Minute)}
|
||||
|
|
@ -119,7 +115,7 @@ func TestBuildLogAnalyticsQuery(t *testing.T) {
|
|||
TimeRange: timeRange,
|
||||
QueryType: string(dataquery.AzureQueryTypeLogAnalytics),
|
||||
},
|
||||
azureLogAnalyticsQuery: makeQueryPointer(AzureLogAnalyticsQuery{
|
||||
azureLogAnalyticsQuery: new(AzureLogAnalyticsQuery{
|
||||
RefID: "A",
|
||||
ResultFormat: dataquery.ResultFormatTimeSeries,
|
||||
URL: "v1/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/cloud-datasources/providers/Microsoft.OperationalInsights/workspaces/AppInsightsTestDataWorkspace/query",
|
||||
|
|
@ -156,7 +152,7 @@ func TestBuildLogAnalyticsQuery(t *testing.T) {
|
|||
RefID: "A",
|
||||
QueryType: string(dataquery.AzureQueryTypeLogAnalytics),
|
||||
},
|
||||
azureLogAnalyticsQuery: makeQueryPointer(AzureLogAnalyticsQuery{
|
||||
azureLogAnalyticsQuery: new(AzureLogAnalyticsQuery{
|
||||
RefID: "A",
|
||||
ResultFormat: dataquery.ResultFormatTimeSeries,
|
||||
URL: "v1/workspaces/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/query",
|
||||
|
|
@ -191,7 +187,7 @@ func TestBuildLogAnalyticsQuery(t *testing.T) {
|
|||
RefID: "A",
|
||||
QueryType: string(dataquery.AzureQueryTypeLogAnalytics),
|
||||
},
|
||||
azureLogAnalyticsQuery: makeQueryPointer(AzureLogAnalyticsQuery{
|
||||
azureLogAnalyticsQuery: new(AzureLogAnalyticsQuery{
|
||||
RefID: "A",
|
||||
ResultFormat: dataquery.ResultFormatTimeSeries,
|
||||
URL: "v1/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/cloud-datasources/providers/Microsoft.OperationalInsights/workspaces/AppInsightsTestDataWorkspace/query",
|
||||
|
|
@ -227,7 +223,7 @@ func TestBuildLogAnalyticsQuery(t *testing.T) {
|
|||
RefID: "A",
|
||||
QueryType: string(dataquery.AzureQueryTypeLogAnalytics),
|
||||
},
|
||||
azureLogAnalyticsQuery: makeQueryPointer(AzureLogAnalyticsQuery{
|
||||
azureLogAnalyticsQuery: new(AzureLogAnalyticsQuery{
|
||||
RefID: "A",
|
||||
ResultFormat: dataquery.ResultFormatTimeSeries,
|
||||
URL: "v1/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/cloud-datasources/providers/Microsoft.OperationalInsights/workspaces/AppInsightsTestDataWorkspace/query",
|
||||
|
|
@ -265,7 +261,7 @@ func TestBuildLogAnalyticsQuery(t *testing.T) {
|
|||
TimeRange: timeRange,
|
||||
QueryType: string(dataquery.AzureQueryTypeLogAnalytics),
|
||||
},
|
||||
azureLogAnalyticsQuery: makeQueryPointer(AzureLogAnalyticsQuery{
|
||||
azureLogAnalyticsQuery: new(AzureLogAnalyticsQuery{
|
||||
RefID: "A",
|
||||
ResultFormat: dataquery.ResultFormatTimeSeries,
|
||||
URL: "v1/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/cloud-datasources/providers/Microsoft.OperationalInsights/workspaces/AppInsightsTestDataWorkspace/query",
|
||||
|
|
@ -305,7 +301,7 @@ func TestBuildLogAnalyticsQuery(t *testing.T) {
|
|||
TimeRange: timeRange,
|
||||
QueryType: string(dataquery.AzureQueryTypeLogAnalytics),
|
||||
},
|
||||
azureLogAnalyticsQuery: makeQueryPointer(AzureLogAnalyticsQuery{
|
||||
azureLogAnalyticsQuery: new(AzureLogAnalyticsQuery{
|
||||
RefID: "A",
|
||||
ResultFormat: dataquery.ResultFormatTimeSeries,
|
||||
URL: "v1/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/cloud-datasources/providers/Microsoft.OperationalInsights/workspaces/AppInsightsTestDataWorkspace/query",
|
||||
|
|
@ -349,7 +345,7 @@ func TestBuildLogAnalyticsQuery(t *testing.T) {
|
|||
TimeRange: timeRange,
|
||||
QueryType: string(dataquery.AzureQueryTypeLogAnalytics),
|
||||
},
|
||||
azureLogAnalyticsQuery: makeQueryPointer(AzureLogAnalyticsQuery{
|
||||
azureLogAnalyticsQuery: new(AzureLogAnalyticsQuery{
|
||||
RefID: "A",
|
||||
ResultFormat: dataquery.ResultFormatTimeSeries,
|
||||
URL: "v1/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/cloud-datasources/providers/Microsoft.OperationalInsights/workspaces/TestDataWorkspace/search",
|
||||
|
|
@ -485,7 +481,7 @@ func TestBuildLogAnalyticsQuery(t *testing.T) {
|
|||
TimeRange: timeRange,
|
||||
QueryType: string(dataquery.AzureQueryTypeLogAnalytics),
|
||||
},
|
||||
azureLogAnalyticsQuery: makeQueryPointer(AzureLogAnalyticsQuery{
|
||||
azureLogAnalyticsQuery: new(AzureLogAnalyticsQuery{
|
||||
RefID: "A",
|
||||
ResultFormat: dataquery.ResultFormatTimeSeries,
|
||||
URL: "v1/apps/AppInsightsTestDataWorkspace/query",
|
||||
|
|
@ -524,7 +520,7 @@ func TestBuildLogAnalyticsQuery(t *testing.T) {
|
|||
TimeRange: timeRange,
|
||||
QueryType: string(dataquery.AzureQueryTypeLogAnalytics),
|
||||
},
|
||||
azureLogAnalyticsQuery: makeQueryPointer(AzureLogAnalyticsQuery{
|
||||
azureLogAnalyticsQuery: new(AzureLogAnalyticsQuery{
|
||||
RefID: "A",
|
||||
ResultFormat: dataquery.ResultFormatTimeSeries,
|
||||
URL: "v1/apps/AppInsightsTestDataWorkspace/query",
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ import (
|
|||
"github.com/grafana/grafana/pkg/tsdb/azuremonitor/types"
|
||||
)
|
||||
|
||||
func Pointer[T any](v T) *T { return &v }
|
||||
|
||||
func TestAzureMonitorBuildQueries(t *testing.T) {
|
||||
datasource := &AzureMonitorDatasource{}
|
||||
dsInfo := types.DatasourceInfo{
|
||||
|
|
@ -111,27 +109,27 @@ func TestAzureMonitorBuildQueries(t *testing.T) {
|
|||
name: "legacy query without resourceURI and has dimensionFilter*s* property with one dimension",
|
||||
azureMonitorVariedProperties: map[string]any{
|
||||
"timeGrain": "PT1M",
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: strPtr("blob"), Operator: strPtr("eq"), Filter: &wildcardFilter}},
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: new("blob"), Operator: new("eq"), Filter: &wildcardFilter}},
|
||||
"top": "30",
|
||||
},
|
||||
queryInterval: duration,
|
||||
expectedInterval: "PT1M",
|
||||
azureMonitorQueryTarget: "aggregation=Average&api-version=2021-05-01&interval=PT1M&metricnames=Percentage+CPU&metricnamespace=Microsoft.Compute%2FvirtualMachines×pan=2018-03-15T13%3A00%3A00Z%2F2018-03-15T13%3A34%3A00Z&top=30",
|
||||
expectedParamFilter: "blob eq '*'",
|
||||
expectedPortalURL: Pointer("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
expectedPortalURL: new("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
},
|
||||
{
|
||||
name: "legacy query without resourceURI and has dimensionFilter*s* property with two dimensions",
|
||||
azureMonitorVariedProperties: map[string]any{
|
||||
"timeGrain": "PT1M",
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: strPtr("blob"), Operator: strPtr("eq"), Filter: &wildcardFilter}, {Dimension: strPtr("tier"), Operator: strPtr("eq"), Filter: &wildcardFilter}},
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: new("blob"), Operator: new("eq"), Filter: &wildcardFilter}, {Dimension: new("tier"), Operator: new("eq"), Filter: &wildcardFilter}},
|
||||
"top": "30",
|
||||
},
|
||||
queryInterval: duration,
|
||||
expectedInterval: "PT1M",
|
||||
azureMonitorQueryTarget: "aggregation=Average&api-version=2021-05-01&interval=PT1M&metricnames=Percentage+CPU&metricnamespace=Microsoft.Compute%2FvirtualMachines×pan=2018-03-15T13%3A00%3A00Z%2F2018-03-15T13%3A34%3A00Z&top=30",
|
||||
expectedParamFilter: "blob eq '*' and tier eq '*'",
|
||||
expectedPortalURL: Pointer("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
expectedPortalURL: new("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
},
|
||||
{
|
||||
name: "legacy query without resourceURI and has a dimension filter without specifying a top",
|
||||
|
|
@ -149,66 +147,66 @@ func TestAzureMonitorBuildQueries(t *testing.T) {
|
|||
name: "has dimensionFilter*s* property with not equals operator",
|
||||
azureMonitorVariedProperties: map[string]any{
|
||||
"timeGrain": "PT1M",
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: strPtr("blob"), Operator: strPtr("ne"), Filter: &wildcardFilter, Filters: []string{"test"}}},
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: new("blob"), Operator: new("ne"), Filter: &wildcardFilter, Filters: []string{"test"}}},
|
||||
"top": "30",
|
||||
},
|
||||
queryInterval: duration,
|
||||
expectedInterval: "PT1M",
|
||||
azureMonitorQueryTarget: "aggregation=Average&api-version=2021-05-01&interval=PT1M&metricnames=Percentage+CPU&metricnamespace=Microsoft.Compute%2FvirtualMachines×pan=2018-03-15T13%3A00%3A00Z%2F2018-03-15T13%3A34%3A00Z&top=30",
|
||||
expectedParamFilter: "blob ne 'test'",
|
||||
expectedPortalURL: Pointer("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22filterCollection%22%3A%7B%22filters%22%3A%5B%7B%22key%22%3A%22blob%22%2C%22operator%22%3A1%2C%22values%22%3A%5B%22test%22%5D%7D%5D%7D%2C%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
expectedPortalURL: new("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22filterCollection%22%3A%7B%22filters%22%3A%5B%7B%22key%22%3A%22blob%22%2C%22operator%22%3A1%2C%22values%22%3A%5B%22test%22%5D%7D%5D%7D%2C%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
},
|
||||
{
|
||||
name: "has dimensionFilter*s* property with startsWith operator",
|
||||
azureMonitorVariedProperties: map[string]any{
|
||||
"timeGrain": "PT1M",
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: strPtr("blob"), Operator: strPtr("sw"), Filter: &testFilter}},
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: new("blob"), Operator: new("sw"), Filter: &testFilter}},
|
||||
"top": "30",
|
||||
},
|
||||
queryInterval: duration,
|
||||
expectedInterval: "PT1M",
|
||||
azureMonitorQueryTarget: "aggregation=Average&api-version=2021-05-01&interval=PT1M&metricnames=Percentage+CPU&metricnamespace=Microsoft.Compute%2FvirtualMachines×pan=2018-03-15T13%3A00%3A00Z%2F2018-03-15T13%3A34%3A00Z&top=30",
|
||||
expectedParamFilter: "blob sw 'test'",
|
||||
expectedPortalURL: Pointer("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22filterCollection%22%3A%7B%22filters%22%3A%5B%7B%22key%22%3A%22blob%22%2C%22operator%22%3A3%2C%22values%22%3A%5B%22test%22%5D%7D%5D%7D%2C%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
expectedPortalURL: new("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22filterCollection%22%3A%7B%22filters%22%3A%5B%7B%22key%22%3A%22blob%22%2C%22operator%22%3A3%2C%22values%22%3A%5B%22test%22%5D%7D%5D%7D%2C%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
},
|
||||
{
|
||||
name: "correctly sets dimension operator to eq (irrespective of operator) when filter value is '*'",
|
||||
azureMonitorVariedProperties: map[string]any{
|
||||
"timeGrain": "PT1M",
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: strPtr("blob"), Operator: strPtr("sw"), Filter: &wildcardFilter}, {Dimension: strPtr("tier"), Operator: strPtr("ne"), Filter: &wildcardFilter}},
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: new("blob"), Operator: new("sw"), Filter: &wildcardFilter}, {Dimension: new("tier"), Operator: new("ne"), Filter: &wildcardFilter}},
|
||||
"top": "30",
|
||||
},
|
||||
queryInterval: duration,
|
||||
expectedInterval: "PT1M",
|
||||
azureMonitorQueryTarget: "aggregation=Average&api-version=2021-05-01&interval=PT1M&metricnames=Percentage+CPU&metricnamespace=Microsoft.Compute%2FvirtualMachines×pan=2018-03-15T13%3A00%3A00Z%2F2018-03-15T13%3A34%3A00Z&top=30",
|
||||
expectedParamFilter: "blob eq '*' and tier eq '*'",
|
||||
expectedPortalURL: Pointer("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
expectedPortalURL: new("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
},
|
||||
{
|
||||
name: "correctly constructs target when multiple filter values are provided for the 'eq' operator",
|
||||
azureMonitorVariedProperties: map[string]any{
|
||||
"timeGrain": "PT1M",
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: strPtr("blob"), Operator: strPtr("eq"), Filter: &wildcardFilter, Filters: []string{"test", "test2"}}},
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: new("blob"), Operator: new("eq"), Filter: &wildcardFilter, Filters: []string{"test", "test2"}}},
|
||||
"top": "30",
|
||||
},
|
||||
queryInterval: duration,
|
||||
expectedInterval: "PT1M",
|
||||
azureMonitorQueryTarget: "aggregation=Average&api-version=2021-05-01&interval=PT1M&metricnames=Percentage+CPU&metricnamespace=Microsoft.Compute%2FvirtualMachines×pan=2018-03-15T13%3A00%3A00Z%2F2018-03-15T13%3A34%3A00Z&top=30",
|
||||
expectedParamFilter: "blob eq 'test' or blob eq 'test2'",
|
||||
expectedPortalURL: Pointer("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22filterCollection%22%3A%7B%22filters%22%3A%5B%7B%22key%22%3A%22blob%22%2C%22operator%22%3A0%2C%22values%22%3A%5B%22test%22%2C%22test2%22%5D%7D%5D%7D%2C%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
expectedPortalURL: new("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22filterCollection%22%3A%7B%22filters%22%3A%5B%7B%22key%22%3A%22blob%22%2C%22operator%22%3A0%2C%22values%22%3A%5B%22test%22%2C%22test2%22%5D%7D%5D%7D%2C%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
},
|
||||
{
|
||||
name: "correctly constructs target when multiple filter values are provided for ne 'eq' operator",
|
||||
azureMonitorVariedProperties: map[string]any{
|
||||
"timeGrain": "PT1M",
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: strPtr("blob"), Operator: strPtr("ne"), Filter: &wildcardFilter, Filters: []string{"test", "test2"}}},
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: new("blob"), Operator: new("ne"), Filter: &wildcardFilter, Filters: []string{"test", "test2"}}},
|
||||
"top": "30",
|
||||
},
|
||||
queryInterval: duration,
|
||||
expectedInterval: "PT1M",
|
||||
azureMonitorQueryTarget: "aggregation=Average&api-version=2021-05-01&interval=PT1M&metricnames=Percentage+CPU&metricnamespace=Microsoft.Compute%2FvirtualMachines×pan=2018-03-15T13%3A00%3A00Z%2F2018-03-15T13%3A34%3A00Z&top=30",
|
||||
expectedParamFilter: "blob ne 'test' and blob ne 'test2'",
|
||||
expectedPortalURL: Pointer("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22filterCollection%22%3A%7B%22filters%22%3A%5B%7B%22key%22%3A%22blob%22%2C%22operator%22%3A1%2C%22values%22%3A%5B%22test%22%2C%22test2%22%5D%7D%5D%7D%2C%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
expectedPortalURL: new("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22filterCollection%22%3A%7B%22filters%22%3A%5B%7B%22key%22%3A%22blob%22%2C%22operator%22%3A1%2C%22values%22%3A%5B%22test%22%2C%22test2%22%5D%7D%5D%7D%2C%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
},
|
||||
{
|
||||
name: "Includes a region",
|
||||
|
|
@ -227,7 +225,7 @@ func TestAzureMonitorBuildQueries(t *testing.T) {
|
|||
"timeGrain": "PT1M",
|
||||
"top": "10",
|
||||
"region": "westus",
|
||||
"resources": []dataquery.AzureMonitorResource{{ResourceGroup: strPtr("rg"), ResourceName: strPtr("vm")}, {ResourceGroup: strPtr("rg2"), ResourceName: strPtr("vm2")}},
|
||||
"resources": []dataquery.AzureMonitorResource{{ResourceGroup: new("rg"), ResourceName: new("vm")}, {ResourceGroup: new("rg2"), ResourceName: new("vm2")}},
|
||||
},
|
||||
expectedInterval: "PT1M",
|
||||
azureMonitorQueryTarget: "aggregation=Average&api-version=2021-05-01&interval=PT1M&metricnames=Percentage+CPU&metricnamespace=Microsoft.Compute%2FvirtualMachines®ion=westus×pan=2018-03-15T13%3A00%3A00Z%2F2018-03-15T13%3A34%3A00Z&top=10",
|
||||
|
|
@ -238,7 +236,7 @@ func TestAzureMonitorBuildQueries(t *testing.T) {
|
|||
name: "includes a single resource as a parameter filter",
|
||||
azureMonitorVariedProperties: map[string]any{
|
||||
"timeGrain": "PT1M",
|
||||
"resources": []dataquery.AzureMonitorResource{{ResourceGroup: strPtr("rg"), ResourceName: strPtr("vm")}},
|
||||
"resources": []dataquery.AzureMonitorResource{{ResourceGroup: new("rg"), ResourceName: new("vm")}},
|
||||
},
|
||||
queryInterval: duration,
|
||||
expectedInterval: "PT1M",
|
||||
|
|
@ -249,8 +247,8 @@ func TestAzureMonitorBuildQueries(t *testing.T) {
|
|||
name: "includes a resource and a dimesion as filters",
|
||||
azureMonitorVariedProperties: map[string]any{
|
||||
"timeGrain": "PT1M",
|
||||
"resources": []dataquery.AzureMonitorResource{{ResourceGroup: strPtr("rg"), ResourceName: strPtr("vm")}, {ResourceGroup: strPtr("rg2"), ResourceName: strPtr("vm2")}},
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: strPtr("blob"), Operator: strPtr("ne"), Filter: &wildcardFilter, Filters: []string{"test", "test2"}}},
|
||||
"resources": []dataquery.AzureMonitorResource{{ResourceGroup: new("rg"), ResourceName: new("vm")}, {ResourceGroup: new("rg2"), ResourceName: new("vm2")}},
|
||||
"dimensionFilters": []dataquery.AzureMetricDimension{{Dimension: new("blob"), Operator: new("ne"), Filter: &wildcardFilter, Filters: []string{"test", "test2"}}},
|
||||
"top": "30",
|
||||
},
|
||||
queryInterval: duration,
|
||||
|
|
@ -258,7 +256,7 @@ func TestAzureMonitorBuildQueries(t *testing.T) {
|
|||
expectedURL: "/subscriptions/12345678-aaaa-bbbb-cccc-123456789abc/providers/microsoft.insights/metrics",
|
||||
azureMonitorQueryTarget: "aggregation=Average&api-version=2021-05-01&interval=PT1M&metricnames=Percentage+CPU&metricnamespace=Microsoft.Compute%2FvirtualMachines×pan=2018-03-15T13%3A00%3A00Z%2F2018-03-15T13%3A34%3A00Z&top=30",
|
||||
expectedBodyFilter: "(Microsoft.ResourceId eq '/subscriptions/12345678-aaaa-bbbb-cccc-123456789abc/resourceGroups/rg/providers/Microsoft.Compute/virtualMachines/vm' or Microsoft.ResourceId eq '/subscriptions/12345678-aaaa-bbbb-cccc-123456789abc/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/vm2') and (blob ne 'test' and blob ne 'test2')",
|
||||
expectedPortalURL: Pointer("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22filterCollection%22%3A%7B%22filters%22%3A%5B%7B%22key%22%3A%22blob%22%2C%22operator%22%3A1%2C%22values%22%3A%5B%22test%22%2C%22test2%22%5D%7D%5D%7D%2C%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
expectedPortalURL: new("http://ds/#blade/Microsoft_Azure_MonitoringMetrics/Metrics.ReactView/Referer/MetricsExplorer/TimeContext/%7B%22absolute%22%3A%7B%22startTime%22%3A%222018-03-15T13%3A00%3A00Z%22%2C%22endTime%22%3A%222018-03-15T13%3A34%3A00Z%22%7D%7D/ChartDefinition/%7B%22v2charts%22%3A%5B%7B%22filterCollection%22%3A%7B%22filters%22%3A%5B%7B%22key%22%3A%22blob%22%2C%22operator%22%3A1%2C%22values%22%3A%5B%22test%22%2C%22test2%22%5D%7D%5D%7D%2C%22grouping%22%3A%7B%22dimension%22%3A%22blob%22%2C%22sort%22%3A2%2C%22top%22%3A10%7D%2C%22metrics%22%3A%5B%7B%22resourceMetadata%22%3A%7B%22id%22%3A%22%2Fsubscriptions%2F12345678-aaaa-bbbb-cccc-123456789abc%2FresourceGroups%2Fgrafanastaging%2Fproviders%2FMicrosoft.Compute%2FvirtualMachines%2Fgrafana%22%7D%2C%22name%22%3A%22Percentage%20CPU%22%2C%22aggregationType%22%3A4%2C%22namespace%22%3A%22Microsoft.Compute%2FvirtualMachines%22%2C%22metricVisualization%22%3A%7B%22displayName%22%3A%22Percentage%20CPU%22%2C%22resourceDisplayName%22%3A%22grafana%22%7D%7D%5D%7D%5D%7D"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -304,7 +302,7 @@ func TestAzureMonitorBuildQueries(t *testing.T) {
|
|||
resources[strings.ToLower(fmt.Sprintf("/subscriptions/12345678-aaaa-bbbb-cccc-123456789abc/resourceGroups/%s/providers/Microsoft.Compute/virtualMachines/%s", *resource.ResourceGroup, *resource.ResourceName))] = resource
|
||||
}
|
||||
} else {
|
||||
resources[strings.ToLower("/subscriptions/12345678-aaaa-bbbb-cccc-123456789abc/resourceGroups/grafanastaging/providers/Microsoft.Compute/virtualMachines/grafana")] = dataquery.AzureMonitorResource{ResourceGroup: strPtr("grafanastaging"), ResourceName: strPtr("grafana")}
|
||||
resources[strings.ToLower("/subscriptions/12345678-aaaa-bbbb-cccc-123456789abc/resourceGroups/grafanastaging/providers/Microsoft.Compute/virtualMachines/grafana")] = dataquery.AzureMonitorResource{ResourceGroup: new("grafanastaging"), ResourceName: new("grafana")}
|
||||
}
|
||||
|
||||
azureMonitorQuery := &types.AzureMonitorQuery{
|
||||
|
|
@ -369,7 +367,7 @@ func TestCustomNamespace(t *testing.T) {
|
|||
func TestAzureMonitorParseResponse(t *testing.T) {
|
||||
resources := map[string]dataquery.AzureMonitorResource{}
|
||||
resources[strings.ToLower("/subscriptions/12345678-aaaa-bbbb-cccc-123456789abc/resourceGroups/grafanastaging/providers/Microsoft.Compute/virtualMachines/grafana")] =
|
||||
dataquery.AzureMonitorResource{ResourceGroup: strPtr("grafanastaging"), ResourceName: strPtr("grafana")}
|
||||
dataquery.AzureMonitorResource{ResourceGroup: new("grafanastaging"), ResourceName: new("grafana")}
|
||||
subscription := "12345678-aaaa-bbbb-cccc-123456789abc"
|
||||
|
||||
tests := []struct {
|
||||
|
|
@ -486,7 +484,7 @@ func TestAzureMonitorParseResponse(t *testing.T) {
|
|||
Params: url.Values{
|
||||
"aggregation": {"Average"},
|
||||
},
|
||||
Resources: map[string]dataquery.AzureMonitorResource{strings.ToLower("/subscriptions/12345678-aaaa-bbbb-cccc-123456789abc/resourceGroups/grafanatest/providers/Microsoft.Storage/storageAccounts/testblobaccount/blobServices/default/providers/Microsoft.Insights/metrics"): {ResourceGroup: strPtr("grafanatest"), ResourceName: strPtr("testblobaccount")}},
|
||||
Resources: map[string]dataquery.AzureMonitorResource{strings.ToLower("/subscriptions/12345678-aaaa-bbbb-cccc-123456789abc/resourceGroups/grafanatest/providers/Microsoft.Storage/storageAccounts/testblobaccount/blobServices/default/providers/Microsoft.Insights/metrics"): {ResourceGroup: new("grafanatest"), ResourceName: new("testblobaccount")}},
|
||||
Subscription: subscription,
|
||||
},
|
||||
},
|
||||
|
|
@ -571,7 +569,7 @@ func TestAzureMonitorParseResponse(t *testing.T) {
|
|||
func TestAzureMonitorParseResponseGrafanaSqlRenamesFields(t *testing.T) {
|
||||
resources := map[string]dataquery.AzureMonitorResource{}
|
||||
resources[strings.ToLower("/subscriptions/12345678-aaaa-bbbb-cccc-123456789abc/resourceGroups/grafanastaging/providers/Microsoft.Compute/virtualMachines/grafana")] =
|
||||
dataquery.AzureMonitorResource{ResourceGroup: strPtr("grafanastaging"), ResourceName: strPtr("grafana")}
|
||||
dataquery.AzureMonitorResource{ResourceGroup: new("grafanastaging"), ResourceName: new("grafana")}
|
||||
subscription := "12345678-aaaa-bbbb-cccc-123456789abc"
|
||||
|
||||
azData := loadTestFile(t, "azuremonitor/1-azure-monitor-response-avg.json")
|
||||
|
|
@ -704,10 +702,10 @@ func TestAzureMonitorParseResponseGrafanaSqlMultiResource(t *testing.T) {
|
|||
|
||||
resources := map[string]dataquery.AzureMonitorResource{
|
||||
strings.ToLower("/subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm-a"): {
|
||||
ResourceGroup: strPtr("rg1"), ResourceName: strPtr("vm-a"),
|
||||
ResourceGroup: new("rg1"), ResourceName: new("vm-a"),
|
||||
},
|
||||
strings.ToLower("/subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm-b"): {
|
||||
ResourceGroup: strPtr("rg1"), ResourceName: strPtr("vm-b"),
|
||||
ResourceGroup: new("rg1"), ResourceName: new("vm-b"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -738,7 +736,7 @@ func TestAzureMonitorParseResponseGrafanaSqlMultiResource(t *testing.T) {
|
|||
func TestAzureMonitorParseResponseGrafanaSqlFalseKeepsDefaultFieldNames(t *testing.T) {
|
||||
resources := map[string]dataquery.AzureMonitorResource{}
|
||||
resources[strings.ToLower("/subscriptions/12345678-aaaa-bbbb-cccc-123456789abc/resourceGroups/grafanastaging/providers/Microsoft.Compute/virtualMachines/grafana")] =
|
||||
dataquery.AzureMonitorResource{ResourceGroup: strPtr("grafanastaging"), ResourceName: strPtr("grafana")}
|
||||
dataquery.AzureMonitorResource{ResourceGroup: new("grafanastaging"), ResourceName: new("grafana")}
|
||||
subscription := "12345678-aaaa-bbbb-cccc-123456789abc"
|
||||
|
||||
azData := loadTestFile(t, "azuremonitor/1-azure-monitor-response-avg.json")
|
||||
|
|
@ -908,7 +906,3 @@ func TestExtractResourceNameFromMetricsURL(t *testing.T) {
|
|||
require.Equal(t, expected, extractResourceNameFromMetricsURL((url)))
|
||||
})
|
||||
}
|
||||
|
||||
func strPtr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,33 +19,33 @@ func TestDimensionFiltersMigration(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "will return new format unchanged",
|
||||
dimensionFilters: []dataquery.AzureMetricDimension{{Dimension: strPtr("testDimension"), Operator: strPtr("eq"), Filters: []string{"testFilter"}}},
|
||||
expectedDimensionFilters: []dataquery.AzureMetricDimension{{Dimension: strPtr("testDimension"), Operator: strPtr("eq"), Filters: []string{"testFilter"}}},
|
||||
dimensionFilters: []dataquery.AzureMetricDimension{{Dimension: new("testDimension"), Operator: new("eq"), Filters: []string{"testFilter"}}},
|
||||
expectedDimensionFilters: []dataquery.AzureMetricDimension{{Dimension: new("testDimension"), Operator: new("eq"), Filters: []string{"testFilter"}}},
|
||||
},
|
||||
{
|
||||
name: "correctly updates old format with wildcard",
|
||||
dimensionFilters: []dataquery.AzureMetricDimension{{Dimension: strPtr("testDimension"), Operator: strPtr("eq"), Filter: &wildcard}},
|
||||
expectedDimensionFilters: []dataquery.AzureMetricDimension{{Dimension: strPtr("testDimension"), Operator: strPtr("eq")}},
|
||||
dimensionFilters: []dataquery.AzureMetricDimension{{Dimension: new("testDimension"), Operator: new("eq"), Filter: &wildcard}},
|
||||
expectedDimensionFilters: []dataquery.AzureMetricDimension{{Dimension: new("testDimension"), Operator: new("eq")}},
|
||||
},
|
||||
{
|
||||
name: "correctly updates old format with a value",
|
||||
dimensionFilters: []dataquery.AzureMetricDimension{{Dimension: strPtr("testDimension"), Operator: strPtr("eq"), Filter: &testFilter}},
|
||||
expectedDimensionFilters: []dataquery.AzureMetricDimension{{Dimension: strPtr("testDimension"), Operator: strPtr("eq"), Filters: []string{testFilter}}},
|
||||
dimensionFilters: []dataquery.AzureMetricDimension{{Dimension: new("testDimension"), Operator: new("eq"), Filter: &testFilter}},
|
||||
expectedDimensionFilters: []dataquery.AzureMetricDimension{{Dimension: new("testDimension"), Operator: new("eq"), Filters: []string{testFilter}}},
|
||||
},
|
||||
{
|
||||
name: "correctly ignores wildcard if filters has a value",
|
||||
dimensionFilters: []dataquery.AzureMetricDimension{{Dimension: strPtr("testDimension"), Operator: strPtr("eq"), Filter: &wildcard, Filters: []string{testFilter}}},
|
||||
expectedDimensionFilters: []dataquery.AzureMetricDimension{{Dimension: strPtr("testDimension"), Operator: strPtr("eq"), Filters: []string{testFilter}}},
|
||||
dimensionFilters: []dataquery.AzureMetricDimension{{Dimension: new("testDimension"), Operator: new("eq"), Filter: &wildcard, Filters: []string{testFilter}}},
|
||||
expectedDimensionFilters: []dataquery.AzureMetricDimension{{Dimension: new("testDimension"), Operator: new("eq"), Filters: []string{testFilter}}},
|
||||
},
|
||||
{
|
||||
name: "correctly merges values if filters has a value (ignores duplicates)",
|
||||
dimensionFilters: []dataquery.AzureMetricDimension{{Dimension: strPtr("testDimension"), Operator: strPtr("eq"), Filter: &testFilter, Filters: []string{testFilter}}},
|
||||
expectedDimensionFilters: []dataquery.AzureMetricDimension{{Dimension: strPtr("testDimension"), Operator: strPtr("eq"), Filters: []string{testFilter}}},
|
||||
dimensionFilters: []dataquery.AzureMetricDimension{{Dimension: new("testDimension"), Operator: new("eq"), Filter: &testFilter, Filters: []string{testFilter}}},
|
||||
expectedDimensionFilters: []dataquery.AzureMetricDimension{{Dimension: new("testDimension"), Operator: new("eq"), Filters: []string{testFilter}}},
|
||||
},
|
||||
{
|
||||
name: "correctly merges values if filters has a value",
|
||||
dimensionFilters: []dataquery.AzureMetricDimension{{Dimension: strPtr("testDimension"), Operator: strPtr("eq"), Filter: &additionalTestFilter, Filters: []string{testFilter}}},
|
||||
expectedDimensionFilters: []dataquery.AzureMetricDimension{{Dimension: strPtr("testDimension"), Operator: strPtr("eq"), Filters: []string{testFilter, additionalTestFilter}}},
|
||||
dimensionFilters: []dataquery.AzureMetricDimension{{Dimension: new("testDimension"), Operator: new("eq"), Filter: &additionalTestFilter, Filters: []string{testFilter}}},
|
||||
expectedDimensionFilters: []dataquery.AzureMetricDimension{{Dimension: new("testDimension"), Operator: new("eq"), Filters: []string{testFilter, additionalTestFilter}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
t.Run("AzureMonitor Resource URI Builder", func(t *testing.T) {
|
||||
t.Run("when there is no resource uri", func(t *testing.T) {
|
||||
ub := &UrlBuilder{
|
||||
DefaultSubscription: strPtr("default-sub"),
|
||||
MetricDefinition: strPtr("Microsoft.Web/serverFarms"),
|
||||
ResourceGroup: strPtr("rg"),
|
||||
ResourceName: strPtr("rn1"),
|
||||
DefaultSubscription: new("default-sub"),
|
||||
MetricDefinition: new("Microsoft.Web/serverFarms"),
|
||||
ResourceGroup: new("rg"),
|
||||
ResourceName: new("rn1"),
|
||||
}
|
||||
|
||||
result, err := ub.BuildResourceURI()
|
||||
|
|
@ -27,7 +27,7 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
|
||||
t.Run("when only resource uri is provided it returns the resource URI", func(t *testing.T) {
|
||||
ub := &UrlBuilder{
|
||||
ResourceURI: strPtr("/subscriptions/sub/resource/uri"),
|
||||
ResourceURI: new("/subscriptions/sub/resource/uri"),
|
||||
}
|
||||
|
||||
url, err := ub.BuildResourceURI()
|
||||
|
|
@ -37,11 +37,11 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
|
||||
t.Run("when resource uri and legacy fields are provided the legacy fields are ignored", func(t *testing.T) {
|
||||
ub := &UrlBuilder{
|
||||
ResourceURI: strPtr("/subscriptions/sub/resource/uri"),
|
||||
DefaultSubscription: strPtr("default-sub"),
|
||||
ResourceGroup: strPtr("rg"),
|
||||
MetricNamespace: strPtr("Microsoft.NetApp/netAppAccounts/capacityPools/volumes"),
|
||||
ResourceName: strPtr("rn1/rn2/rn3"),
|
||||
ResourceURI: new("/subscriptions/sub/resource/uri"),
|
||||
DefaultSubscription: new("default-sub"),
|
||||
ResourceGroup: new("rg"),
|
||||
MetricNamespace: new("Microsoft.NetApp/netAppAccounts/capacityPools/volumes"),
|
||||
ResourceName: new("rn1/rn2/rn3"),
|
||||
}
|
||||
|
||||
url, err := ub.BuildResourceURI()
|
||||
|
|
@ -52,10 +52,10 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
t.Run("Legacy URL Builder params", func(t *testing.T) {
|
||||
t.Run("when metric definition is in the short form", func(t *testing.T) {
|
||||
ub := &UrlBuilder{
|
||||
DefaultSubscription: strPtr("default-sub"),
|
||||
ResourceGroup: strPtr("rg"),
|
||||
MetricNamespace: strPtr("Microsoft.Compute/virtualMachines"),
|
||||
ResourceName: strPtr("rn"),
|
||||
DefaultSubscription: new("default-sub"),
|
||||
ResourceGroup: new("rg"),
|
||||
MetricNamespace: new("Microsoft.Compute/virtualMachines"),
|
||||
ResourceName: new("rn"),
|
||||
}
|
||||
|
||||
url, err := ub.BuildResourceURI()
|
||||
|
|
@ -66,11 +66,11 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
|
||||
t.Run("when metric definition is in the short form and a subscription is defined", func(t *testing.T) {
|
||||
ub := &UrlBuilder{
|
||||
DefaultSubscription: strPtr("default-sub"),
|
||||
Subscription: strPtr("specified-sub"),
|
||||
ResourceGroup: strPtr("rg"),
|
||||
MetricNamespace: strPtr("Microsoft.Compute/virtualMachines"),
|
||||
ResourceName: strPtr("rn"),
|
||||
DefaultSubscription: new("default-sub"),
|
||||
Subscription: new("specified-sub"),
|
||||
ResourceGroup: new("rg"),
|
||||
MetricNamespace: new("Microsoft.Compute/virtualMachines"),
|
||||
ResourceName: new("rn"),
|
||||
}
|
||||
|
||||
url, err := ub.BuildResourceURI()
|
||||
|
|
@ -80,10 +80,10 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
|
||||
t.Run("when metric definition is Microsoft.Storage/storageAccounts/blobServices", func(t *testing.T) {
|
||||
ub := &UrlBuilder{
|
||||
DefaultSubscription: strPtr("default-sub"),
|
||||
ResourceGroup: strPtr("rg"),
|
||||
MetricNamespace: strPtr("Microsoft.Storage/storageAccounts/blobServices"),
|
||||
ResourceName: strPtr("rn1"),
|
||||
DefaultSubscription: new("default-sub"),
|
||||
ResourceGroup: new("rg"),
|
||||
MetricNamespace: new("Microsoft.Storage/storageAccounts/blobServices"),
|
||||
ResourceName: new("rn1"),
|
||||
}
|
||||
|
||||
result, err := ub.BuildResourceURI()
|
||||
|
|
@ -96,10 +96,10 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
|
||||
t.Run("when metric definition is Microsoft.Storage/storageAccounts/tableServices", func(t *testing.T) {
|
||||
ub := &UrlBuilder{
|
||||
DefaultSubscription: strPtr("default-sub"),
|
||||
ResourceGroup: strPtr("rg"),
|
||||
MetricNamespace: strPtr("Microsoft.Storage/storageAccounts/tableServices"),
|
||||
ResourceName: strPtr("rn1/default"),
|
||||
DefaultSubscription: new("default-sub"),
|
||||
ResourceGroup: new("rg"),
|
||||
MetricNamespace: new("Microsoft.Storage/storageAccounts/tableServices"),
|
||||
ResourceName: new("rn1/default"),
|
||||
}
|
||||
|
||||
url, err := ub.BuildResourceURI()
|
||||
|
|
@ -109,10 +109,10 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
|
||||
t.Run("when metric definition is Microsoft.Storage/storageAccounts/fileServices", func(t *testing.T) {
|
||||
ub := &UrlBuilder{
|
||||
DefaultSubscription: strPtr("default-sub"),
|
||||
ResourceGroup: strPtr("rg"),
|
||||
MetricNamespace: strPtr("Microsoft.Storage/storageAccounts/fileServices"),
|
||||
ResourceName: strPtr("rn1/default"),
|
||||
DefaultSubscription: new("default-sub"),
|
||||
ResourceGroup: new("rg"),
|
||||
MetricNamespace: new("Microsoft.Storage/storageAccounts/fileServices"),
|
||||
ResourceName: new("rn1/default"),
|
||||
}
|
||||
|
||||
url, err := ub.BuildResourceURI()
|
||||
|
|
@ -122,10 +122,10 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
|
||||
t.Run("when metric definition is Microsoft.NetApp/netAppAccounts/capacityPools/volumes", func(t *testing.T) {
|
||||
ub := &UrlBuilder{
|
||||
DefaultSubscription: strPtr("default-sub"),
|
||||
ResourceGroup: strPtr("rg"),
|
||||
MetricNamespace: strPtr("Microsoft.NetApp/netAppAccounts/capacityPools/volumes"),
|
||||
ResourceName: strPtr("rn1/rn2/rn3"),
|
||||
DefaultSubscription: new("default-sub"),
|
||||
ResourceGroup: new("rg"),
|
||||
MetricNamespace: new("Microsoft.NetApp/netAppAccounts/capacityPools/volumes"),
|
||||
ResourceName: new("rn1/rn2/rn3"),
|
||||
}
|
||||
|
||||
url, err := ub.BuildResourceURI()
|
||||
|
|
@ -149,10 +149,10 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
|
||||
t.Run("provider extraction from metricNamespaceArray", func(t *testing.T) {
|
||||
ub := &UrlBuilder{
|
||||
DefaultSubscription: strPtr("default-sub"),
|
||||
MetricNamespace: strPtr("provider1/service1"),
|
||||
ResourceGroup: strPtr("rg"),
|
||||
ResourceName: strPtr("rn1/rn2/rn3"),
|
||||
DefaultSubscription: new("default-sub"),
|
||||
MetricNamespace: new("provider1/service1"),
|
||||
ResourceGroup: new("rg"),
|
||||
ResourceName: new("rn1/rn2/rn3"),
|
||||
}
|
||||
expectedProvider := "provider1"
|
||||
|
||||
|
|
@ -171,8 +171,8 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
|
||||
t.Run("when metricNamespace is not in the correct format", func(t *testing.T) {
|
||||
ub := &UrlBuilder{
|
||||
DefaultSubscription: strPtr("default-sub"),
|
||||
MetricNamespace: strPtr("invalidformat"),
|
||||
DefaultSubscription: new("default-sub"),
|
||||
MetricNamespace: new("invalidformat"),
|
||||
}
|
||||
|
||||
_, err := ub.BuildResourceURI()
|
||||
|
|
@ -183,9 +183,9 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
|
||||
t.Run("when resourceNameArray index out of range", func(t *testing.T) {
|
||||
ub := &UrlBuilder{
|
||||
DefaultSubscription: strPtr("default-sub"),
|
||||
MetricNamespace: strPtr("provider1/service1"),
|
||||
ResourceName: strPtr("rn1/rn2/rn3"),
|
||||
DefaultSubscription: new("default-sub"),
|
||||
MetricNamespace: new("provider1/service1"),
|
||||
ResourceName: new("rn1/rn2/rn3"),
|
||||
}
|
||||
|
||||
_, err := ub.BuildResourceURI()
|
||||
|
|
@ -194,9 +194,9 @@ func TestBuildResourceURI(t *testing.T) {
|
|||
}
|
||||
|
||||
ub = &UrlBuilder{
|
||||
DefaultSubscription: strPtr("default-sub"),
|
||||
MetricNamespace: strPtr("provider1/service1/service2"),
|
||||
ResourceName: strPtr(""),
|
||||
DefaultSubscription: new("default-sub"),
|
||||
MetricNamespace: new("provider1/service1/service2"),
|
||||
ResourceName: new(""),
|
||||
}
|
||||
|
||||
_, err = ub.BuildResourceURI()
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ type apiResponse struct {
|
|||
}
|
||||
|
||||
func doRequest(req *http.Request, cli *http.Client, responseFn processResponse) *apiResponse {
|
||||
res, err := cli.Do(req)
|
||||
res, err := cli.Do(req) // #nosec G704 -- datasource client targets operator-configured URL
|
||||
if err != nil {
|
||||
return &apiResponse{code: http.StatusBadRequest, err: err}
|
||||
}
|
||||
|
|
@ -384,7 +384,7 @@ func getTarget(original string) (target string, err error) {
|
|||
|
||||
func writeResponseBytes(rw http.ResponseWriter, code int, msg []byte) {
|
||||
rw.WriteHeader(code)
|
||||
_, err := rw.Write(msg)
|
||||
_, err := rw.Write(msg) // #nosec G705 -- msg is the upstream datasource response body
|
||||
if err != nil {
|
||||
backend.Logger.Error("Unable to write HTTP response", "error", err, "statusSource", backend.ErrorSourceDownstream)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import (
|
|||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/features"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/mocks"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
)
|
||||
|
||||
func TestNewInstanceSettings(t *testing.T) {
|
||||
|
|
@ -279,9 +278,9 @@ func TestQuery_ResourceRequest_DescribeLogGroups_with_CrossAccountQuerying(t *te
|
|||
logsApi.AssertCalled(t, "DescribeLogGroups",
|
||||
&cloudwatchlogs.DescribeLogGroupsInput{
|
||||
AccountIdentifiers: []string{"some-account-id"},
|
||||
IncludeLinkedAccounts: utils.Pointer(true),
|
||||
IncludeLinkedAccounts: new(true),
|
||||
Limit: aws.Int32(50),
|
||||
LogGroupNamePrefix: utils.Pointer("some-pattern"),
|
||||
LogGroupNamePrefix: new("some-pattern"),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/kinds/dataquery"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/mocks"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
"github.com/patrickmn/go-cache"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
|
@ -30,7 +29,7 @@ func TestGetDimensionValuesForWildcards(t *testing.T) {
|
|||
query.MetricQueryType = models.MetricQueryTypeSearch
|
||||
query.MatchExact = false
|
||||
api := &mocks.MetricsAPI{Metrics: []cloudwatchtypes.Metric{
|
||||
{MetricName: utils.Pointer("Test_MetricName"), Dimensions: []cloudwatchtypes.Dimension{{Name: utils.Pointer("Test_DimensionName"), Value: utils.Pointer("Value")}}},
|
||||
{MetricName: new("Test_MetricName"), Dimensions: []cloudwatchtypes.Dimension{{Name: new("Test_DimensionName"), Value: new("Value")}}},
|
||||
}}
|
||||
api.On("ListMetrics").Return(nil)
|
||||
_, err := ds.getDimensionValuesForWildcards(ctx, "us-east-1", api, []*models.CloudWatchQuery{query}, tagValueCache, 50, noSkip)
|
||||
|
|
@ -62,7 +61,7 @@ func TestGetDimensionValuesForWildcards(t *testing.T) {
|
|||
|
||||
// Confirm that it calls the api again if the last call did not return any values
|
||||
api.Metrics = []cloudwatchtypes.Metric{
|
||||
{MetricName: utils.Pointer("Test_MetricName"), Dimensions: []cloudwatchtypes.Dimension{{Name: utils.Pointer("Test_DimensionName2"), Value: utils.Pointer("Value")}}},
|
||||
{MetricName: new("Test_MetricName"), Dimensions: []cloudwatchtypes.Dimension{{Name: new("Test_DimensionName2"), Value: new("Value")}}},
|
||||
}
|
||||
api.On("ListMetrics").Return(nil)
|
||||
queries, err = ds.getDimensionValuesForWildcards(ctx, "us-east-1", api, []*models.CloudWatchQuery{query}, tagValueCache, 50, noSkip)
|
||||
|
|
@ -133,10 +132,10 @@ func TestGetDimensionValuesForWildcards(t *testing.T) {
|
|||
query.MetricQueryType = models.MetricQueryTypeSearch
|
||||
query.MatchExact = false
|
||||
api := &mocks.MetricsAPI{Metrics: []cloudwatchtypes.Metric{
|
||||
{MetricName: utils.Pointer("Test_MetricName1"), Dimensions: []cloudwatchtypes.Dimension{{Name: utils.Pointer("Test_DimensionName1"), Value: utils.Pointer("Value1")}, {Name: utils.Pointer("Test_DimensionName2"), Value: utils.Pointer("Value2")}}},
|
||||
{MetricName: utils.Pointer("Test_MetricName2"), Dimensions: []cloudwatchtypes.Dimension{{Name: utils.Pointer("Test_DimensionName1"), Value: utils.Pointer("Value3")}}},
|
||||
{MetricName: utils.Pointer("Test_MetricName3"), Dimensions: []cloudwatchtypes.Dimension{{Name: utils.Pointer("Test_DimensionName1"), Value: utils.Pointer("Value4")}}},
|
||||
{MetricName: utils.Pointer("Test_MetricName4"), Dimensions: []cloudwatchtypes.Dimension{{Name: utils.Pointer("Test_DimensionName1"), Value: utils.Pointer("Value2")}}},
|
||||
{MetricName: new("Test_MetricName1"), Dimensions: []cloudwatchtypes.Dimension{{Name: new("Test_DimensionName1"), Value: new("Value1")}, {Name: new("Test_DimensionName2"), Value: new("Value2")}}},
|
||||
{MetricName: new("Test_MetricName2"), Dimensions: []cloudwatchtypes.Dimension{{Name: new("Test_DimensionName1"), Value: new("Value3")}}},
|
||||
{MetricName: new("Test_MetricName3"), Dimensions: []cloudwatchtypes.Dimension{{Name: new("Test_DimensionName1"), Value: new("Value4")}}},
|
||||
{MetricName: new("Test_MetricName4"), Dimensions: []cloudwatchtypes.Dimension{{Name: new("Test_DimensionName1"), Value: new("Value2")}}},
|
||||
}}
|
||||
api.On("ListMetrics").Return(nil)
|
||||
queries, err := ds.getDimensionValuesForWildcards(ctx, "us-east-1", api, []*models.CloudWatchQuery{query}, cache.New(0, 0), 50, shouldSkipFetchingWildcards)
|
||||
|
|
@ -155,11 +154,11 @@ func TestGetDimensionValuesForWildcards(t *testing.T) {
|
|||
query.Sql.GroupBy = &models.SQLExpressionGroupBy{
|
||||
Expressions: []dataquery.QueryEditorGroupByExpression{
|
||||
{
|
||||
Property: dataquery.QueryEditorProperty{Name: utils.Pointer("Test_DimensionName1"), Type: "string"},
|
||||
Property: dataquery.QueryEditorProperty{Name: new("Test_DimensionName1"), Type: "string"},
|
||||
Type: "groupBy",
|
||||
},
|
||||
{
|
||||
Property: dataquery.QueryEditorProperty{Name: utils.Pointer("Test_DimensionName2"), Type: "string"},
|
||||
Property: dataquery.QueryEditorProperty{Name: new("Test_DimensionName2"), Type: "string"},
|
||||
Type: "groupBy",
|
||||
},
|
||||
},
|
||||
|
|
@ -168,10 +167,10 @@ func TestGetDimensionValuesForWildcards(t *testing.T) {
|
|||
query.MetricQueryType = models.MetricQueryTypeQuery
|
||||
|
||||
api := &mocks.MetricsAPI{Metrics: []cloudwatchtypes.Metric{
|
||||
{MetricName: utils.Pointer("Test_MetricName"), Dimensions: []cloudwatchtypes.Dimension{{Name: utils.Pointer("Test_DimensionName1"), Value: utils.Pointer("Dimension1Value1")}, {Name: utils.Pointer("Test_DimensionName2"), Value: utils.Pointer("Dimension2Value1")}}},
|
||||
{MetricName: utils.Pointer("Test_MetricName"), Dimensions: []cloudwatchtypes.Dimension{{Name: utils.Pointer("Test_DimensionName1"), Value: utils.Pointer("Dimension1Value2")}, {Name: utils.Pointer("Test_DimensionName2"), Value: utils.Pointer("Dimension2Value2")}}},
|
||||
{MetricName: utils.Pointer("Test_MetricName"), Dimensions: []cloudwatchtypes.Dimension{{Name: utils.Pointer("Test_DimensionName1"), Value: utils.Pointer("Dimension1Value3")}, {Name: utils.Pointer("Test_DimensionName2"), Value: utils.Pointer("Dimension2Value3")}}},
|
||||
{MetricName: utils.Pointer("Test_MetricName"), Dimensions: []cloudwatchtypes.Dimension{{Name: utils.Pointer("Test_DimensionName1"), Value: utils.Pointer("Dimension1Value4")}, {Name: utils.Pointer("Test_DimensionName2"), Value: utils.Pointer("Dimension2Value4")}}},
|
||||
{MetricName: new("Test_MetricName"), Dimensions: []cloudwatchtypes.Dimension{{Name: new("Test_DimensionName1"), Value: new("Dimension1Value1")}, {Name: new("Test_DimensionName2"), Value: new("Dimension2Value1")}}},
|
||||
{MetricName: new("Test_MetricName"), Dimensions: []cloudwatchtypes.Dimension{{Name: new("Test_DimensionName1"), Value: new("Dimension1Value2")}, {Name: new("Test_DimensionName2"), Value: new("Dimension2Value2")}}},
|
||||
{MetricName: new("Test_MetricName"), Dimensions: []cloudwatchtypes.Dimension{{Name: new("Test_DimensionName1"), Value: new("Dimension1Value3")}, {Name: new("Test_DimensionName2"), Value: new("Dimension2Value3")}}},
|
||||
{MetricName: new("Test_MetricName"), Dimensions: []cloudwatchtypes.Dimension{{Name: new("Test_DimensionName1"), Value: new("Dimension1Value4")}, {Name: new("Test_DimensionName2"), Value: new("Dimension2Value4")}}},
|
||||
}}
|
||||
api.On("ListMetrics").Return(nil)
|
||||
queries, err := ds.getDimensionValuesForWildcards(ctx, "us-east-1", api, []*models.CloudWatchQuery{query}, cache.New(0, 0), 50, noSkip)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import (
|
|||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/kinds/dataquery"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/mocks"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
|
@ -118,8 +117,8 @@ func TestQuery_GetLogEvents_returns_response_from_GetLogEvents_to_data_frame_fie
|
|||
cli = &mocks.MockLogEvents{}
|
||||
cli.On("GetLogEvents", mock.Anything, mock.Anything, mock.Anything).Return(&cloudwatchlogs.GetLogEventsOutput{
|
||||
Events: []cloudwatchlogstypes.OutputLogEvent{{
|
||||
Message: utils.Pointer("some message"),
|
||||
Timestamp: utils.Pointer(int64(15)),
|
||||
Message: new("some message"),
|
||||
Timestamp: new(int64(15)),
|
||||
}}}, nil)
|
||||
|
||||
resp, err := ds.QueryData(context.Background(), &backend.QueryDataRequest{
|
||||
|
|
@ -148,7 +147,7 @@ func TestQuery_GetLogEvents_returns_response_from_GetLogEvents_to_data_frame_fie
|
|||
assert.True(t, ok)
|
||||
|
||||
expectedTsField := data.NewField("ts", nil, []time.Time{time.UnixMilli(15).UTC()})
|
||||
expectedMessageField := data.NewField("line", nil, []*string{utils.Pointer("some message")})
|
||||
expectedMessageField := data.NewField("line", nil, []*string{new("some message")})
|
||||
expectedTsField.SetConfig(&data.FieldConfig{DisplayName: "Time"})
|
||||
assert.Equal(t, []*data.Field{expectedTsField, expectedMessageField}, respA.Frames[0].Fields)
|
||||
}
|
||||
|
|
@ -1218,7 +1217,7 @@ func TestBuildSourceClause(t *testing.T) {
|
|||
"namePrefix with single prefix": {
|
||||
logsQuery: models.LogsQuery{
|
||||
CloudWatchLogsQuery: dataquery.CloudWatchLogsQuery{
|
||||
LogsQueryScope: utils.Pointer(dataquery.LogsQueryScopeNamePrefix),
|
||||
LogsQueryScope: new(dataquery.LogsQueryScopeNamePrefix),
|
||||
LogGroupPrefixes: []string{"/aws/lambda"},
|
||||
},
|
||||
},
|
||||
|
|
@ -1228,7 +1227,7 @@ func TestBuildSourceClause(t *testing.T) {
|
|||
"namePrefix with multiple prefixes": {
|
||||
logsQuery: models.LogsQuery{
|
||||
CloudWatchLogsQuery: dataquery.CloudWatchLogsQuery{
|
||||
LogsQueryScope: utils.Pointer(dataquery.LogsQueryScopeNamePrefix),
|
||||
LogsQueryScope: new(dataquery.LogsQueryScopeNamePrefix),
|
||||
LogGroupPrefixes: []string{"/aws/lambda", "/aws/apigateway"},
|
||||
},
|
||||
},
|
||||
|
|
@ -1238,7 +1237,7 @@ func TestBuildSourceClause(t *testing.T) {
|
|||
"allLogGroups ignores leftover prefixes": {
|
||||
logsQuery: models.LogsQuery{
|
||||
CloudWatchLogsQuery: dataquery.CloudWatchLogsQuery{
|
||||
LogsQueryScope: utils.Pointer(dataquery.LogsQueryScopeAllLogGroups),
|
||||
LogsQueryScope: new(dataquery.LogsQueryScopeAllLogGroups),
|
||||
LogGroupPrefixes: []string{"/aws/lambda"},
|
||||
},
|
||||
},
|
||||
|
|
@ -1248,7 +1247,7 @@ func TestBuildSourceClause(t *testing.T) {
|
|||
"with INFREQUENT_ACCESS class": {
|
||||
logsQuery: models.LogsQuery{
|
||||
CloudWatchLogsQuery: dataquery.CloudWatchLogsQuery{
|
||||
LogGroupClass: utils.Pointer(dataquery.LogGroupClassINFREQUENTACCESS),
|
||||
LogGroupClass: new(dataquery.LogGroupClassINFREQUENTACCESS),
|
||||
},
|
||||
},
|
||||
includeAccounts: false,
|
||||
|
|
@ -1257,7 +1256,7 @@ func TestBuildSourceClause(t *testing.T) {
|
|||
"with STANDARD class (should be omitted)": {
|
||||
logsQuery: models.LogsQuery{
|
||||
CloudWatchLogsQuery: dataquery.CloudWatchLogsQuery{
|
||||
LogGroupClass: utils.Pointer(dataquery.LogGroupClassSTANDARD),
|
||||
LogGroupClass: new(dataquery.LogGroupClassSTANDARD),
|
||||
},
|
||||
},
|
||||
includeAccounts: false,
|
||||
|
|
@ -1284,9 +1283,9 @@ func TestBuildSourceClause(t *testing.T) {
|
|||
"with all options and includeAccounts true": {
|
||||
logsQuery: models.LogsQuery{
|
||||
CloudWatchLogsQuery: dataquery.CloudWatchLogsQuery{
|
||||
LogsQueryScope: utils.Pointer(dataquery.LogsQueryScopeNamePrefix),
|
||||
LogsQueryScope: new(dataquery.LogsQueryScopeNamePrefix),
|
||||
LogGroupPrefixes: []string{"/aws/lambda"},
|
||||
LogGroupClass: utils.Pointer(dataquery.LogGroupClassINFREQUENTACCESS),
|
||||
LogGroupClass: new(dataquery.LogGroupClassINFREQUENTACCESS),
|
||||
SelectedAccountIds: []string{"123456789012"},
|
||||
},
|
||||
},
|
||||
|
|
@ -1296,9 +1295,9 @@ func TestBuildSourceClause(t *testing.T) {
|
|||
"with all options but includeAccounts false": {
|
||||
logsQuery: models.LogsQuery{
|
||||
CloudWatchLogsQuery: dataquery.CloudWatchLogsQuery{
|
||||
LogsQueryScope: utils.Pointer(dataquery.LogsQueryScopeNamePrefix),
|
||||
LogsQueryScope: new(dataquery.LogsQueryScopeNamePrefix),
|
||||
LogGroupPrefixes: []string{"/aws/lambda"},
|
||||
LogGroupClass: utils.Pointer(dataquery.LogGroupClassINFREQUENTACCESS),
|
||||
LogGroupClass: new(dataquery.LogGroupClassINFREQUENTACCESS),
|
||||
SelectedAccountIds: []string{"123456789012"},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import (
|
|||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models/resources"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/services"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
)
|
||||
|
||||
func TestLogGroupsRoute(t *testing.T) {
|
||||
|
|
@ -34,7 +33,7 @@ func TestLogGroupsRoute(t *testing.T) {
|
|||
Arn: "some arn",
|
||||
Name: "some name",
|
||||
},
|
||||
AccountId: utils.Pointer("111"),
|
||||
AccountId: new("111"),
|
||||
}}, nil)
|
||||
|
||||
rr := httptest.NewRecorder()
|
||||
|
|
@ -56,13 +55,13 @@ func TestLogGroupsRoute(t *testing.T) {
|
|||
Arn: "arn 1",
|
||||
Name: "name 1",
|
||||
},
|
||||
AccountId: utils.Pointer("111"),
|
||||
AccountId: new("111"),
|
||||
}, {
|
||||
Value: resources.LogGroup{
|
||||
Arn: "arn 2",
|
||||
Name: "name 2",
|
||||
},
|
||||
AccountId: utils.Pointer("222"),
|
||||
AccountId: new("222"),
|
||||
},
|
||||
}, nil)
|
||||
|
||||
|
|
@ -166,7 +165,7 @@ func TestLogGroupsRoute(t *testing.T) {
|
|||
|
||||
mockLogsService.AssertCalled(t, "GetLogGroups", resources.LogGroupsRequest{
|
||||
Limit: 50,
|
||||
LogGroupNamePrefix: utils.Pointer("some-prefix"),
|
||||
LogGroupNamePrefix: new("some-prefix"),
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -182,7 +181,7 @@ func TestLogGroupsRoute(t *testing.T) {
|
|||
|
||||
mockLogsService.AssertCalled(t, "GetLogGroups", resources.LogGroupsRequest{
|
||||
Limit: 50,
|
||||
LogGroupNamePattern: utils.Pointer("some-pattern"),
|
||||
LogGroupNamePattern: new("some-pattern"),
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -198,7 +197,7 @@ func TestLogGroupsRoute(t *testing.T) {
|
|||
|
||||
mockLogsService.AssertCalled(t, "GetLogGroups", resources.LogGroupsRequest{
|
||||
Limit: 50,
|
||||
ResourceRequest: resources.ResourceRequest{AccountId: utils.Pointer("some-account-id")},
|
||||
ResourceRequest: resources.ResourceRequest{AccountId: new("some-account-id")},
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
|
@ -266,8 +265,8 @@ func Test_executeSyncLogQuery_handles_RefId_from_input_queries(t *testing.T) {
|
|||
}), mock.Anything).Return(&cloudwatchlogs.GetQueryResultsOutput{
|
||||
// this result will only be returned when the argument is QueryId = "queryId for A"
|
||||
Results: [][]cloudwatchlogstypes.ResultField{{{
|
||||
Field: utils.Pointer("@log"),
|
||||
Value: utils.Pointer("A result"),
|
||||
Field: new("@log"),
|
||||
Value: new("A result"),
|
||||
}}},
|
||||
Status: "Complete"}, nil)
|
||||
cli.On("GetQueryResults", mock.Anything, mock.MatchedBy(func(input *cloudwatchlogs.GetQueryResultsInput) bool {
|
||||
|
|
@ -275,8 +274,8 @@ func Test_executeSyncLogQuery_handles_RefId_from_input_queries(t *testing.T) {
|
|||
}), mock.Anything).Return(&cloudwatchlogs.GetQueryResultsOutput{
|
||||
// this result will only be returned when the argument is QueryId = "queryId for B"
|
||||
Results: [][]cloudwatchlogstypes.ResultField{{{
|
||||
Field: utils.Pointer("@log"),
|
||||
Value: utils.Pointer("B result"),
|
||||
Field: new("@log"),
|
||||
Value: new("B result"),
|
||||
}}},
|
||||
Status: "Complete"}, nil)
|
||||
|
||||
|
|
@ -305,13 +304,13 @@ func Test_executeSyncLogQuery_handles_RefId_from_input_queries(t *testing.T) {
|
|||
},
|
||||
})
|
||||
|
||||
expectedLogFieldFromFirstCall := data.NewField("@log", nil, []*string{utils.Pointer("A result")}) // verifies the response from GetQueryResults matches the input RefId A
|
||||
expectedLogFieldFromFirstCall := data.NewField("@log", nil, []*string{new("A result")}) // verifies the response from GetQueryResults matches the input RefId A
|
||||
assert.NoError(t, err)
|
||||
respA, ok := res.Responses["A"]
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, []*data.Field{expectedLogFieldFromFirstCall}, respA.Frames[0].Fields)
|
||||
|
||||
expectedLogFieldFromSecondCall := data.NewField("@log", nil, []*string{utils.Pointer("B result")}) // verifies the response from GetQueryResults matches the input RefId B
|
||||
expectedLogFieldFromSecondCall := data.NewField("@log", nil, []*string{new("B result")}) // verifies the response from GetQueryResults matches the input RefId B
|
||||
respB, ok := res.Responses["B"]
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, []*data.Field{expectedLogFieldFromSecondCall}, respB.Frames[0].Fields)
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ func getInstanceAttributeValue(attributeName string, instance ec2types.Instance)
|
|||
attributePath := strings.Split(attributeName, ".")
|
||||
v := reflect.ValueOf(instance)
|
||||
for _, key := range attributePath {
|
||||
if v.Kind() == reflect.Ptr {
|
||||
if v.Kind() == reflect.Pointer {
|
||||
if v.IsNil() {
|
||||
return "", false, nil
|
||||
}
|
||||
|
|
@ -151,7 +151,7 @@ func getInstanceAttributeValue(attributeName string, instance ec2types.Instance)
|
|||
}
|
||||
}
|
||||
|
||||
if v.Kind() == reflect.Ptr && v.IsNil() {
|
||||
if v.Kind() == reflect.Pointer && v.IsNil() {
|
||||
return "", false, nil
|
||||
}
|
||||
if v.Kind() == reflect.String {
|
||||
|
|
@ -165,7 +165,7 @@ func getInstanceAttributeValue(attributeName string, instance ec2types.Instance)
|
|||
data = attr.String()
|
||||
} else if _, ok := v.Interface().(*bool); ok {
|
||||
data = fmt.Sprint(v.Elem().Bool())
|
||||
} else if v.Kind() == reflect.Ptr && v.Elem().CanInt() {
|
||||
} else if v.Kind() == reflect.Pointer && v.Elem().CanInt() {
|
||||
data = fmt.Sprint(v.Elem().Int())
|
||||
} else {
|
||||
return "", false, errors.New("cannot parse attribute")
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/kinds/dataquery"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
|
@ -122,7 +121,7 @@ func TestCloudWatchQuery(t *testing.T) {
|
|||
Period: 300,
|
||||
Id: "id1",
|
||||
MatchExact: true,
|
||||
AccountId: utils.Pointer("123456789"),
|
||||
AccountId: new("123456789"),
|
||||
Label: "${PROP('Namespace')}",
|
||||
Dimensions: map[string][]string{
|
||||
"InstanceId": {"i-12345678"},
|
||||
|
|
@ -144,7 +143,7 @@ func TestCloudWatchQuery(t *testing.T) {
|
|||
Region: "us-east-1",
|
||||
Statistic: "Average",
|
||||
Expression: "SEARCH(someexpression)",
|
||||
AccountId: utils.Pointer("123456789"),
|
||||
AccountId: new("123456789"),
|
||||
Period: 300,
|
||||
Id: "id1",
|
||||
MatchExact: true,
|
||||
|
|
@ -960,13 +959,13 @@ func Test_migrateAliasToDynamicLabel_single_query_preserves_old_alias_and_create
|
|||
CloudWatchMetricsQuery: dataquery.CloudWatchMetricsQuery{
|
||||
Region: "us-east-1",
|
||||
Namespace: "ec2",
|
||||
MetricName: utils.Pointer("CPUUtilization"),
|
||||
Alias: utils.Pointer(tc.inputAlias),
|
||||
MetricName: new("CPUUtilization"),
|
||||
Alias: new(tc.inputAlias),
|
||||
Dimensions: &dataquery.Dimensions{
|
||||
"InstanceId": dataquery.StringOrArrayOfString{ArrayOfString: []string{"test"}},
|
||||
},
|
||||
Statistic: &average,
|
||||
Period: utils.Pointer("600"),
|
||||
Period: new("600"),
|
||||
Hide: aws.Bool(false),
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import (
|
|||
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/mocks"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models/resources"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
|
@ -80,7 +79,7 @@ func TestListMetricsService_GetDimensionKeysByDimensionFilter(t *testing.T) {
|
|||
{
|
||||
name: "Should set account correctly on list metric input if it cross account is defined on the request",
|
||||
input: resources.DimensionKeysRequest{
|
||||
ResourceRequest: &resources.ResourceRequest{Region: "us-east-1", AccountId: utils.Pointer(useLinkedAccountsId)},
|
||||
ResourceRequest: &resources.ResourceRequest{Region: "us-east-1", AccountId: new(useLinkedAccountsId)},
|
||||
Namespace: "AWS/EC2",
|
||||
MetricName: "CPUUtilization",
|
||||
DimensionFilter: []*resources.Dimension{{Name: "InstanceId", Value: ""}},
|
||||
|
|
@ -95,7 +94,7 @@ func TestListMetricsService_GetDimensionKeysByDimensionFilter(t *testing.T) {
|
|||
{
|
||||
name: "Should set account correctly on list metric input if single account is defined on the request",
|
||||
input: resources.DimensionKeysRequest{
|
||||
ResourceRequest: &resources.ResourceRequest{Region: "us-east-1", AccountId: utils.Pointer("1234567890")},
|
||||
ResourceRequest: &resources.ResourceRequest{Region: "us-east-1", AccountId: new("1234567890")},
|
||||
Namespace: "AWS/EC2",
|
||||
MetricName: "CPUUtilization",
|
||||
DimensionFilter: []*resources.Dimension{{Name: "InstanceId", Value: ""}},
|
||||
|
|
@ -157,7 +156,7 @@ func TestListMetricsService_GetDimensionValuesByDimensionFilter(t *testing.T) {
|
|||
{
|
||||
name: "Should set account correctly on list metric input if it cross account is defined on the request",
|
||||
input: resources.DimensionValuesRequest{
|
||||
ResourceRequest: &resources.ResourceRequest{Region: "us-east-1", AccountId: utils.Pointer(useLinkedAccountsId)},
|
||||
ResourceRequest: &resources.ResourceRequest{Region: "us-east-1", AccountId: new(useLinkedAccountsId)},
|
||||
Namespace: "AWS/EC2",
|
||||
MetricName: "CPUUtilization",
|
||||
DimensionFilter: []*resources.Dimension{{Name: "InstanceId", Value: ""}},
|
||||
|
|
@ -172,7 +171,7 @@ func TestListMetricsService_GetDimensionValuesByDimensionFilter(t *testing.T) {
|
|||
{
|
||||
name: "Should set account correctly on list metric input if single account is defined on the request",
|
||||
input: resources.DimensionValuesRequest{
|
||||
ResourceRequest: &resources.ResourceRequest{Region: "us-east-1", AccountId: utils.Pointer("1234567890")},
|
||||
ResourceRequest: &resources.ResourceRequest{Region: "us-east-1", AccountId: new("1234567890")},
|
||||
Namespace: "AWS/EC2",
|
||||
MetricName: "CPUUtilization",
|
||||
DimensionFilter: []*resources.Dimension{{Name: "InstanceId", Value: ""}},
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models/resources"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
)
|
||||
|
||||
type LogGroupsService struct {
|
||||
|
|
@ -50,7 +49,7 @@ func (s *LogGroupsService) GetLogGroups(ctx context.Context, req resources.LogGr
|
|||
Arn: *logGroup.Arn,
|
||||
Name: *logGroup.LogGroupName,
|
||||
},
|
||||
AccountId: utils.Pointer(getAccountId(*logGroup.Arn)),
|
||||
AccountId: new(getAccountId(*logGroup.Arn)),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import (
|
|||
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/mocks"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models/resources"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
|
@ -23,9 +22,9 @@ func TestGetLogGroups(t *testing.T) {
|
|||
mockLogsAPI.On("DescribeLogGroups", mock.Anything).Return(
|
||||
&cloudwatchlogs.DescribeLogGroupsOutput{
|
||||
LogGroups: []cloudwatchlogstypes.LogGroup{
|
||||
{Arn: utils.Pointer("arn:aws:logs:us-east-1:111:log-group:group_a"), LogGroupName: utils.Pointer("group_a")},
|
||||
{Arn: utils.Pointer("arn:aws:logs:us-east-1:222:log-group:group_b"), LogGroupName: utils.Pointer("group_b")},
|
||||
{Arn: utils.Pointer("arn:aws:logs:us-east-1:333:log-group:group_c"), LogGroupName: utils.Pointer("group_c")},
|
||||
{Arn: new("arn:aws:logs:us-east-1:111:log-group:group_a"), LogGroupName: new("group_a")},
|
||||
{Arn: new("arn:aws:logs:us-east-1:222:log-group:group_b"), LogGroupName: new("group_b")},
|
||||
{Arn: new("arn:aws:logs:us-east-1:333:log-group:group_c"), LogGroupName: new("group_c")},
|
||||
},
|
||||
}, nil)
|
||||
service := NewLogGroupsService(mockLogsAPI, false)
|
||||
|
|
@ -35,15 +34,15 @@ func TestGetLogGroups(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, []resources.ResourceResponse[resources.LogGroup]{
|
||||
{
|
||||
AccountId: utils.Pointer("111"),
|
||||
AccountId: new("111"),
|
||||
Value: resources.LogGroup{Arn: "arn:aws:logs:us-east-1:111:log-group:group_a", Name: "group_a"},
|
||||
},
|
||||
{
|
||||
AccountId: utils.Pointer("222"),
|
||||
AccountId: new("222"),
|
||||
Value: resources.LogGroup{Arn: "arn:aws:logs:us-east-1:222:log-group:group_b", Name: "group_b"},
|
||||
},
|
||||
{
|
||||
AccountId: utils.Pointer("333"),
|
||||
AccountId: new("333"),
|
||||
Value: resources.LogGroup{Arn: "arn:aws:logs:us-east-1:333:log-group:group_c", Name: "group_c"},
|
||||
},
|
||||
}, resp)
|
||||
|
|
@ -68,13 +67,13 @@ func TestGetLogGroups(t *testing.T) {
|
|||
|
||||
_, err := service.GetLogGroups(context.Background(), resources.LogGroupsRequest{
|
||||
Limit: 0,
|
||||
LogGroupNamePrefix: utils.Pointer("test"),
|
||||
LogGroupNamePrefix: new("test"),
|
||||
})
|
||||
|
||||
assert.NoError(t, err)
|
||||
mockLogsAPI.AssertCalled(t, "DescribeLogGroups", &cloudwatchlogs.DescribeLogGroupsInput{
|
||||
Limit: aws.Int32(0),
|
||||
LogGroupNamePrefix: utils.Pointer("test"),
|
||||
LogGroupNamePrefix: new("test"),
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -107,7 +106,7 @@ func TestGetLogGroups(t *testing.T) {
|
|||
mockLogsAPI := &mocks.LogsAPI{}
|
||||
req := resources.LogGroupsRequest{
|
||||
Limit: 2,
|
||||
LogGroupNamePrefix: utils.Pointer("test"),
|
||||
LogGroupNamePrefix: new("test"),
|
||||
ListAllLogGroups: false,
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +115,7 @@ func TestGetLogGroups(t *testing.T) {
|
|||
LogGroupNamePrefix: req.LogGroupNamePrefix,
|
||||
}).Return(&cloudwatchlogs.DescribeLogGroupsOutput{
|
||||
LogGroups: []cloudwatchlogstypes.LogGroup{
|
||||
{Arn: utils.Pointer("arn:aws:logs:us-east-1:111:log-group:group_a"), LogGroupName: utils.Pointer("group_a")},
|
||||
{Arn: new("arn:aws:logs:us-east-1:111:log-group:group_a"), LogGroupName: new("group_a")},
|
||||
},
|
||||
NextToken: aws.String("next_token"),
|
||||
}, nil)
|
||||
|
|
@ -128,7 +127,7 @@ func TestGetLogGroups(t *testing.T) {
|
|||
mockLogsAPI.AssertNumberOfCalls(t, "DescribeLogGroups", 1)
|
||||
assert.Equal(t, []resources.ResourceResponse[resources.LogGroup]{
|
||||
{
|
||||
AccountId: utils.Pointer("111"),
|
||||
AccountId: new("111"),
|
||||
Value: resources.LogGroup{Arn: "arn:aws:logs:us-east-1:111:log-group:group_a", Name: "group_a"},
|
||||
},
|
||||
}, resp)
|
||||
|
|
@ -138,7 +137,7 @@ func TestGetLogGroups(t *testing.T) {
|
|||
mockLogsAPI := &mocks.LogsAPI{}
|
||||
req := resources.LogGroupsRequest{
|
||||
Limit: 2,
|
||||
LogGroupNamePrefix: utils.Pointer("test"),
|
||||
LogGroupNamePrefix: new("test"),
|
||||
ListAllLogGroups: true,
|
||||
}
|
||||
|
||||
|
|
@ -148,19 +147,19 @@ func TestGetLogGroups(t *testing.T) {
|
|||
LogGroupNamePrefix: req.LogGroupNamePrefix,
|
||||
}).Return(&cloudwatchlogs.DescribeLogGroupsOutput{
|
||||
LogGroups: []cloudwatchlogstypes.LogGroup{
|
||||
{Arn: utils.Pointer("arn:aws:logs:us-east-1:111:log-group:group_a"), LogGroupName: utils.Pointer("group_a")},
|
||||
{Arn: new("arn:aws:logs:us-east-1:111:log-group:group_a"), LogGroupName: new("group_a")},
|
||||
},
|
||||
NextToken: utils.Pointer("token"),
|
||||
NextToken: new("token"),
|
||||
}, nil)
|
||||
|
||||
// second call
|
||||
mockLogsAPI.On("DescribeLogGroups", &cloudwatchlogs.DescribeLogGroupsInput{
|
||||
Limit: aws.Int32(req.Limit),
|
||||
LogGroupNamePrefix: req.LogGroupNamePrefix,
|
||||
NextToken: utils.Pointer("token"),
|
||||
NextToken: new("token"),
|
||||
}).Return(&cloudwatchlogs.DescribeLogGroupsOutput{
|
||||
LogGroups: []cloudwatchlogstypes.LogGroup{
|
||||
{Arn: utils.Pointer("arn:aws:logs:us-east-1:222:log-group:group_b"), LogGroupName: utils.Pointer("group_b")},
|
||||
{Arn: new("arn:aws:logs:us-east-1:222:log-group:group_b"), LogGroupName: new("group_b")},
|
||||
},
|
||||
}, nil)
|
||||
service := NewLogGroupsService(mockLogsAPI, false)
|
||||
|
|
@ -169,11 +168,11 @@ func TestGetLogGroups(t *testing.T) {
|
|||
mockLogsAPI.AssertNumberOfCalls(t, "DescribeLogGroups", 2)
|
||||
assert.Equal(t, []resources.ResourceResponse[resources.LogGroup]{
|
||||
{
|
||||
AccountId: utils.Pointer("111"),
|
||||
AccountId: new("111"),
|
||||
Value: resources.LogGroup{Arn: "arn:aws:logs:us-east-1:111:log-group:group_a", Name: "group_a"},
|
||||
},
|
||||
{
|
||||
AccountId: utils.Pointer("222"),
|
||||
AccountId: new("222"),
|
||||
Value: resources.LogGroup{Arn: "arn:aws:logs:us-east-1:222:log-group:group_b", Name: "group_b"},
|
||||
},
|
||||
}, resp)
|
||||
|
|
@ -187,14 +186,14 @@ func TestGetLogGroupsCrossAccountQuerying(t *testing.T) {
|
|||
service := NewLogGroupsService(mockLogsAPI, false)
|
||||
|
||||
_, err := service.GetLogGroups(context.Background(), resources.LogGroupsRequest{
|
||||
ResourceRequest: resources.ResourceRequest{AccountId: utils.Pointer("accountId")},
|
||||
LogGroupNamePrefix: utils.Pointer("prefix"),
|
||||
ResourceRequest: resources.ResourceRequest{AccountId: new("accountId")},
|
||||
LogGroupNamePrefix: new("prefix"),
|
||||
})
|
||||
|
||||
assert.NoError(t, err)
|
||||
mockLogsAPI.AssertCalled(t, "DescribeLogGroups", &cloudwatchlogs.DescribeLogGroupsInput{
|
||||
Limit: aws.Int32(0),
|
||||
LogGroupNamePrefix: utils.Pointer("prefix"),
|
||||
LogGroupNamePrefix: new("prefix"),
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -204,17 +203,17 @@ func TestGetLogGroupsCrossAccountQuerying(t *testing.T) {
|
|||
service := NewLogGroupsService(mockLogsAPI, true)
|
||||
|
||||
_, err := service.GetLogGroups(context.Background(), resources.LogGroupsRequest{
|
||||
ResourceRequest: resources.ResourceRequest{AccountId: utils.Pointer("accountId")},
|
||||
LogGroupNamePrefix: utils.Pointer("prefix"),
|
||||
LogGroupNamePattern: utils.Pointer("pattern"),
|
||||
ResourceRequest: resources.ResourceRequest{AccountId: new("accountId")},
|
||||
LogGroupNamePrefix: new("prefix"),
|
||||
LogGroupNamePattern: new("pattern"),
|
||||
})
|
||||
|
||||
assert.NoError(t, err)
|
||||
mockLogsAPI.AssertCalled(t, "DescribeLogGroups", &cloudwatchlogs.DescribeLogGroupsInput{
|
||||
AccountIdentifiers: []string{"accountId"},
|
||||
Limit: aws.Int32(0),
|
||||
LogGroupNamePrefix: utils.Pointer("pattern"),
|
||||
IncludeLinkedAccounts: utils.Pointer(true),
|
||||
LogGroupNamePrefix: new("pattern"),
|
||||
IncludeLinkedAccounts: new(true),
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -224,13 +223,13 @@ func TestGetLogGroupsCrossAccountQuerying(t *testing.T) {
|
|||
service := NewLogGroupsService(mockLogsAPI, true)
|
||||
|
||||
_, err := service.GetLogGroups(context.Background(), resources.LogGroupsRequest{
|
||||
ResourceRequest: resources.ResourceRequest{AccountId: utils.Pointer("accountId")},
|
||||
ResourceRequest: resources.ResourceRequest{AccountId: new("accountId")},
|
||||
})
|
||||
|
||||
assert.NoError(t, err)
|
||||
mockLogsAPI.AssertCalled(t, "DescribeLogGroups", &cloudwatchlogs.DescribeLogGroupsInput{
|
||||
Limit: aws.Int32(0),
|
||||
IncludeLinkedAccounts: utils.Pointer(true),
|
||||
IncludeLinkedAccounts: new(true),
|
||||
AccountIdentifiers: []string{"accountId"},
|
||||
})
|
||||
})
|
||||
|
|
@ -241,15 +240,15 @@ func TestGetLogGroupsCrossAccountQuerying(t *testing.T) {
|
|||
service := NewLogGroupsService(mockLogsAPI, true)
|
||||
|
||||
_, err := service.GetLogGroups(context.Background(), resources.LogGroupsRequest{
|
||||
ResourceRequest: resources.ResourceRequest{AccountId: utils.Pointer("accountId")},
|
||||
LogGroupNamePrefix: utils.Pointer("prefix"),
|
||||
ResourceRequest: resources.ResourceRequest{AccountId: new("accountId")},
|
||||
LogGroupNamePrefix: new("prefix"),
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
mockLogsAPI.AssertCalled(t, "DescribeLogGroups", &cloudwatchlogs.DescribeLogGroupsInput{
|
||||
AccountIdentifiers: []string{"accountId"},
|
||||
Limit: aws.Int32(0),
|
||||
LogGroupNamePrefix: utils.Pointer("prefix"),
|
||||
IncludeLinkedAccounts: utils.Pointer(true),
|
||||
LogGroupNamePrefix: new("prefix"),
|
||||
IncludeLinkedAccounts: new(true),
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -259,13 +258,13 @@ func TestGetLogGroupsCrossAccountQuerying(t *testing.T) {
|
|||
service := NewLogGroupsService(mockLogsAPI, true)
|
||||
|
||||
_, err := service.GetLogGroups(context.Background(), resources.LogGroupsRequest{
|
||||
LogGroupNamePrefix: utils.Pointer("prefix"),
|
||||
LogGroupNamePrefix: new("prefix"),
|
||||
})
|
||||
|
||||
assert.NoError(t, err)
|
||||
mockLogsAPI.AssertCalled(t, "DescribeLogGroups", &cloudwatchlogs.DescribeLogGroupsInput{
|
||||
Limit: aws.Int32(0),
|
||||
LogGroupNamePrefix: utils.Pointer("prefix"),
|
||||
LogGroupNamePrefix: new("prefix"),
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -276,17 +275,17 @@ func TestGetLogGroupsCrossAccountQuerying(t *testing.T) {
|
|||
|
||||
_, err := service.GetLogGroups(context.Background(), resources.LogGroupsRequest{
|
||||
ResourceRequest: resources.ResourceRequest{
|
||||
AccountId: utils.Pointer("accountId"),
|
||||
AccountId: new("accountId"),
|
||||
},
|
||||
LogGroupNamePrefix: utils.Pointer("prefix"),
|
||||
LogGroupNamePrefix: new("prefix"),
|
||||
})
|
||||
|
||||
assert.NoError(t, err)
|
||||
mockLogsAPI.AssertCalled(t, "DescribeLogGroups", &cloudwatchlogs.DescribeLogGroupsInput{
|
||||
AccountIdentifiers: []string{"accountId"},
|
||||
IncludeLinkedAccounts: utils.Pointer(true),
|
||||
IncludeLinkedAccounts: new(true),
|
||||
Limit: aws.Int32(0),
|
||||
LogGroupNamePrefix: utils.Pointer("prefix"),
|
||||
LogGroupNamePrefix: new("prefix"),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
@ -370,7 +369,7 @@ func TestGetLogGroupFields(t *testing.T) {
|
|||
|
||||
mockLogsAPI.AssertCalled(t, "GetLogGroupFields", &cloudwatchlogs.GetLogGroupFieldsInput{
|
||||
LogGroupIdentifier: nil,
|
||||
LogGroupName: utils.Pointer("logGroupName"),
|
||||
LogGroupName: new("logGroupName"),
|
||||
})
|
||||
assert.NotNil(t, resp)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -389,7 +388,7 @@ func TestGetLogGroupFields(t *testing.T) {
|
|||
|
||||
mockLogsAPI.AssertCalled(t, "GetLogGroupFields", &cloudwatchlogs.GetLogGroupFieldsInput{
|
||||
LogGroupIdentifier: nil,
|
||||
LogGroupName: utils.Pointer("logGroupName"),
|
||||
LogGroupName: new("logGroupName"),
|
||||
})
|
||||
assert.NotNil(t, resp)
|
||||
assert.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/mocks"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models/resources"
|
||||
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -21,7 +20,7 @@ func TestRegions(t *testing.T) {
|
|||
mockRegions := &ec2.DescribeRegionsOutput{
|
||||
Regions: []ec2types.Region{
|
||||
{
|
||||
RegionName: utils.Pointer("earth-1"),
|
||||
RegionName: new("earth-1"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue