diff --git a/.github/workflows/bats-hub.yml b/.github/workflows/bats-hub.yml index 473af9b1312..e631c3ebc71 100644 --- a/.github/workflows/bats-hub.yml +++ b/.github/workflows/bats-hub.yml @@ -33,7 +33,7 @@ jobs: - name: "Set up Go" uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.23" - name: "Install bats dependencies" env: diff --git a/.github/workflows/bats-mysql.yml b/.github/workflows/bats-mysql.yml index 211d856bc34..a94e28b1f97 100644 --- a/.github/workflows/bats-mysql.yml +++ b/.github/workflows/bats-mysql.yml @@ -36,7 +36,7 @@ jobs: - name: "Set up Go" uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.23" - name: "Install bats dependencies" env: diff --git a/.github/workflows/bats-postgres.yml b/.github/workflows/bats-postgres.yml index aec707f0c03..a1054463341 100644 --- a/.github/workflows/bats-postgres.yml +++ b/.github/workflows/bats-postgres.yml @@ -45,7 +45,7 @@ jobs: - name: "Set up Go" uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.23" - name: "Install bats dependencies" env: diff --git a/.github/workflows/bats-sqlite-coverage.yml b/.github/workflows/bats-sqlite-coverage.yml index c1ae9077310..9d79f1d7c2e 100644 --- a/.github/workflows/bats-sqlite-coverage.yml +++ b/.github/workflows/bats-sqlite-coverage.yml @@ -31,7 +31,7 @@ jobs: - name: "Set up Go" uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.23" - name: "Install bats dependencies" env: diff --git a/.github/workflows/ci-windows-build-msi.yml b/.github/workflows/ci-windows-build-msi.yml index a37aa43e2d0..07e29071e05 100644 --- a/.github/workflows/ci-windows-build-msi.yml +++ b/.github/workflows/ci-windows-build-msi.yml @@ -35,7 +35,7 @@ jobs: - name: "Set up Go" uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.23" - name: Build run: make windows_installer BUILD_RE2_WASM=1 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2715c6590c3..4128cb435f9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -52,7 +52,7 @@ jobs: - name: "Set up Go" uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.23" cache-dependency-path: "**/go.sum" # Initializes the CodeQL tools for scanning. diff --git a/.github/workflows/go-tests-windows.yml b/.github/workflows/go-tests-windows.yml index a31e42cf702..c0edd89e1cb 100644 --- a/.github/workflows/go-tests-windows.yml +++ b/.github/workflows/go-tests-windows.yml @@ -34,7 +34,7 @@ jobs: - name: "Set up Go" uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.23" - name: Build run: | diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index d4e3a3d843a..c1c147f208f 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -126,7 +126,7 @@ jobs: - name: "Set up Go" uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.23" - name: Create localstack streams run: | diff --git a/.github/workflows/publish-tarball-release.yml b/.github/workflows/publish-tarball-release.yml index eeefb801719..6a41c3fba53 100644 --- a/.github/workflows/publish-tarball-release.yml +++ b/.github/workflows/publish-tarball-release.yml @@ -25,7 +25,7 @@ jobs: - name: "Set up Go" uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.23" - name: Build the binaries run: | diff --git a/Dockerfile b/Dockerfile index 450ea69017f..880df88dc02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # vim: set ft=dockerfile: -FROM golang:1.22-alpine3.20 AS build +FROM golang:1.23-alpine3.20 AS build ARG BUILD_VERSION diff --git a/Dockerfile.debian b/Dockerfile.debian index 8bf2698c786..5d47f167e99 100644 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -1,5 +1,5 @@ # vim: set ft=dockerfile: -FROM golang:1.22-bookworm AS build +FROM golang:1.23-bookworm AS build ARG BUILD_VERSION diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6051ca67393..acbcabc20c5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,7 +21,7 @@ stages: - task: GoTool@0 displayName: "Install Go" inputs: - version: '1.22' + version: '1.23' - pwsh: | choco install -y make diff --git a/go.mod b/go.mod index ec8566db84a..2b63c326104 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,13 @@ module github.com/crowdsecurity/crowdsec -go 1.22 +go 1.23 // Don't use the toolchain directive to avoid uncontrolled downloads during // a build, especially in sandboxed environments (freebsd, gentoo...). // toolchain go1.21.3 require ( - entgo.io/ent v0.13.1 + entgo.io/ent v0.14.1 github.com/AlecAivazis/survey/v2 v2.3.7 github.com/Masterminds/semver/v3 v3.2.1 github.com/Masterminds/sprig/v3 v3.2.3 @@ -82,10 +82,10 @@ require ( github.com/umahmood/haversine v0.0.0-20151105152445-808ab04add26 github.com/wasilibs/go-re2 v1.7.0 github.com/xhit/go-simple-mail/v2 v2.16.0 - golang.org/x/crypto v0.22.0 - golang.org/x/mod v0.15.0 + golang.org/x/crypto v0.26.0 + golang.org/x/mod v0.20.0 golang.org/x/sys v0.24.0 - golang.org/x/text v0.14.0 + golang.org/x/text v0.17.0 google.golang.org/grpc v1.56.3 google.golang.org/protobuf v1.33.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 @@ -201,11 +201,11 @@ require ( go.mongodb.org/mongo-driver v1.9.4 // indirect go.uber.org/atomic v1.10.0 // indirect golang.org/x/arch v0.7.0 // indirect - golang.org/x/net v0.24.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/term v0.19.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/term v0.23.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.18.0 // indirect + golang.org/x/tools v0.24.0 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect diff --git a/go.sum b/go.sum index ff73dc56332..eda951fc3ff 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 h1:GwdJbXydHCYPedeeLt4x/lrl ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU= bitbucket.org/creachadair/stringset v0.0.9 h1:L4vld9nzPt90UZNrXjNelTshD74ps4P5NGs3Iq6yN3o= bitbucket.org/creachadair/stringset v0.0.9/go.mod h1:t+4WcQ4+PXTa8aQdNKe40ZP6iwesoMFWAxPGd3UGjyY= -entgo.io/ent v0.13.1 h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE= -entgo.io/ent v0.13.1/go.mod h1:qCEmo+biw3ccBn9OyL4ZK5dfpwg++l1Gxwac5B1206A= +entgo.io/ent v0.14.1 h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s= +entgo.io/ent v0.14.1/go.mod h1:MH6XLG0KXpkcDQhKiHfANZSzR55TJyPL5IGNpI8wpco= github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= @@ -763,8 +763,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= @@ -772,8 +772,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= +golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -797,8 +797,8 @@ golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -808,8 +808,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -854,8 +854,8 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= +golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -868,8 +868,8 @@ golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -893,8 +893,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= -golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/database/ent/alert_query.go b/pkg/database/ent/alert_query.go index 7eddb6ce024..ae0fbc96531 100644 --- a/pkg/database/ent/alert_query.go +++ b/pkg/database/ent/alert_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -158,7 +159,7 @@ func (aq *AlertQuery) QueryMetas() *MetaQuery { // First returns the first Alert entity from the query. // Returns a *NotFoundError when no Alert was found. func (aq *AlertQuery) First(ctx context.Context) (*Alert, error) { - nodes, err := aq.Limit(1).All(setContextOp(ctx, aq.ctx, "First")) + nodes, err := aq.Limit(1).All(setContextOp(ctx, aq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -181,7 +182,7 @@ func (aq *AlertQuery) FirstX(ctx context.Context) *Alert { // Returns a *NotFoundError when no Alert ID was found. func (aq *AlertQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = aq.Limit(1).IDs(setContextOp(ctx, aq.ctx, "FirstID")); err != nil { + if ids, err = aq.Limit(1).IDs(setContextOp(ctx, aq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -204,7 +205,7 @@ func (aq *AlertQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one Alert entity is found. // Returns a *NotFoundError when no Alert entities are found. func (aq *AlertQuery) Only(ctx context.Context) (*Alert, error) { - nodes, err := aq.Limit(2).All(setContextOp(ctx, aq.ctx, "Only")) + nodes, err := aq.Limit(2).All(setContextOp(ctx, aq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -232,7 +233,7 @@ func (aq *AlertQuery) OnlyX(ctx context.Context) *Alert { // Returns a *NotFoundError when no entities are found. func (aq *AlertQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = aq.Limit(2).IDs(setContextOp(ctx, aq.ctx, "OnlyID")); err != nil { + if ids, err = aq.Limit(2).IDs(setContextOp(ctx, aq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -257,7 +258,7 @@ func (aq *AlertQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of Alerts. func (aq *AlertQuery) All(ctx context.Context) ([]*Alert, error) { - ctx = setContextOp(ctx, aq.ctx, "All") + ctx = setContextOp(ctx, aq.ctx, ent.OpQueryAll) if err := aq.prepareQuery(ctx); err != nil { return nil, err } @@ -279,7 +280,7 @@ func (aq *AlertQuery) IDs(ctx context.Context) (ids []int, err error) { if aq.ctx.Unique == nil && aq.path != nil { aq.Unique(true) } - ctx = setContextOp(ctx, aq.ctx, "IDs") + ctx = setContextOp(ctx, aq.ctx, ent.OpQueryIDs) if err = aq.Select(alert.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -297,7 +298,7 @@ func (aq *AlertQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (aq *AlertQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, aq.ctx, "Count") + ctx = setContextOp(ctx, aq.ctx, ent.OpQueryCount) if err := aq.prepareQuery(ctx); err != nil { return 0, err } @@ -315,7 +316,7 @@ func (aq *AlertQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (aq *AlertQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, aq.ctx, "Exist") + ctx = setContextOp(ctx, aq.ctx, ent.OpQueryExist) switch _, err := aq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -759,7 +760,7 @@ func (agb *AlertGroupBy) Aggregate(fns ...AggregateFunc) *AlertGroupBy { // Scan applies the selector query and scans the result into the given value. func (agb *AlertGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, agb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, agb.build.ctx, ent.OpQueryGroupBy) if err := agb.build.prepareQuery(ctx); err != nil { return err } @@ -807,7 +808,7 @@ func (as *AlertSelect) Aggregate(fns ...AggregateFunc) *AlertSelect { // Scan applies the selector query and scans the result into the given value. func (as *AlertSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, as.ctx, "Select") + ctx = setContextOp(ctx, as.ctx, ent.OpQuerySelect) if err := as.prepareQuery(ctx); err != nil { return err } diff --git a/pkg/database/ent/bouncer_query.go b/pkg/database/ent/bouncer_query.go index ea2b7495733..4277dbc0fc1 100644 --- a/pkg/database/ent/bouncer_query.go +++ b/pkg/database/ent/bouncer_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -60,7 +61,7 @@ func (bq *BouncerQuery) Order(o ...bouncer.OrderOption) *BouncerQuery { // First returns the first Bouncer entity from the query. // Returns a *NotFoundError when no Bouncer was found. func (bq *BouncerQuery) First(ctx context.Context) (*Bouncer, error) { - nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, "First")) + nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -83,7 +84,7 @@ func (bq *BouncerQuery) FirstX(ctx context.Context) *Bouncer { // Returns a *NotFoundError when no Bouncer ID was found. func (bq *BouncerQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, "FirstID")); err != nil { + if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -106,7 +107,7 @@ func (bq *BouncerQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one Bouncer entity is found. // Returns a *NotFoundError when no Bouncer entities are found. func (bq *BouncerQuery) Only(ctx context.Context) (*Bouncer, error) { - nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, "Only")) + nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -134,7 +135,7 @@ func (bq *BouncerQuery) OnlyX(ctx context.Context) *Bouncer { // Returns a *NotFoundError when no entities are found. func (bq *BouncerQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, "OnlyID")); err != nil { + if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -159,7 +160,7 @@ func (bq *BouncerQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of Bouncers. func (bq *BouncerQuery) All(ctx context.Context) ([]*Bouncer, error) { - ctx = setContextOp(ctx, bq.ctx, "All") + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryAll) if err := bq.prepareQuery(ctx); err != nil { return nil, err } @@ -181,7 +182,7 @@ func (bq *BouncerQuery) IDs(ctx context.Context) (ids []int, err error) { if bq.ctx.Unique == nil && bq.path != nil { bq.Unique(true) } - ctx = setContextOp(ctx, bq.ctx, "IDs") + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryIDs) if err = bq.Select(bouncer.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -199,7 +200,7 @@ func (bq *BouncerQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (bq *BouncerQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, bq.ctx, "Count") + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryCount) if err := bq.prepareQuery(ctx); err != nil { return 0, err } @@ -217,7 +218,7 @@ func (bq *BouncerQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (bq *BouncerQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, bq.ctx, "Exist") + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryExist) switch _, err := bq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -449,7 +450,7 @@ func (bgb *BouncerGroupBy) Aggregate(fns ...AggregateFunc) *BouncerGroupBy { // Scan applies the selector query and scans the result into the given value. func (bgb *BouncerGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, bgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, bgb.build.ctx, ent.OpQueryGroupBy) if err := bgb.build.prepareQuery(ctx); err != nil { return err } @@ -497,7 +498,7 @@ func (bs *BouncerSelect) Aggregate(fns ...AggregateFunc) *BouncerSelect { // Scan applies the selector query and scans the result into the given value. func (bs *BouncerSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, bs.ctx, "Select") + ctx = setContextOp(ctx, bs.ctx, ent.OpQuerySelect) if err := bs.prepareQuery(ctx); err != nil { return err } diff --git a/pkg/database/ent/configitem_query.go b/pkg/database/ent/configitem_query.go index f68b8953ddb..b1d6403de1f 100644 --- a/pkg/database/ent/configitem_query.go +++ b/pkg/database/ent/configitem_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -60,7 +61,7 @@ func (ciq *ConfigItemQuery) Order(o ...configitem.OrderOption) *ConfigItemQuery // First returns the first ConfigItem entity from the query. // Returns a *NotFoundError when no ConfigItem was found. func (ciq *ConfigItemQuery) First(ctx context.Context) (*ConfigItem, error) { - nodes, err := ciq.Limit(1).All(setContextOp(ctx, ciq.ctx, "First")) + nodes, err := ciq.Limit(1).All(setContextOp(ctx, ciq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -83,7 +84,7 @@ func (ciq *ConfigItemQuery) FirstX(ctx context.Context) *ConfigItem { // Returns a *NotFoundError when no ConfigItem ID was found. func (ciq *ConfigItemQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = ciq.Limit(1).IDs(setContextOp(ctx, ciq.ctx, "FirstID")); err != nil { + if ids, err = ciq.Limit(1).IDs(setContextOp(ctx, ciq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -106,7 +107,7 @@ func (ciq *ConfigItemQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one ConfigItem entity is found. // Returns a *NotFoundError when no ConfigItem entities are found. func (ciq *ConfigItemQuery) Only(ctx context.Context) (*ConfigItem, error) { - nodes, err := ciq.Limit(2).All(setContextOp(ctx, ciq.ctx, "Only")) + nodes, err := ciq.Limit(2).All(setContextOp(ctx, ciq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -134,7 +135,7 @@ func (ciq *ConfigItemQuery) OnlyX(ctx context.Context) *ConfigItem { // Returns a *NotFoundError when no entities are found. func (ciq *ConfigItemQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = ciq.Limit(2).IDs(setContextOp(ctx, ciq.ctx, "OnlyID")); err != nil { + if ids, err = ciq.Limit(2).IDs(setContextOp(ctx, ciq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -159,7 +160,7 @@ func (ciq *ConfigItemQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of ConfigItems. func (ciq *ConfigItemQuery) All(ctx context.Context) ([]*ConfigItem, error) { - ctx = setContextOp(ctx, ciq.ctx, "All") + ctx = setContextOp(ctx, ciq.ctx, ent.OpQueryAll) if err := ciq.prepareQuery(ctx); err != nil { return nil, err } @@ -181,7 +182,7 @@ func (ciq *ConfigItemQuery) IDs(ctx context.Context) (ids []int, err error) { if ciq.ctx.Unique == nil && ciq.path != nil { ciq.Unique(true) } - ctx = setContextOp(ctx, ciq.ctx, "IDs") + ctx = setContextOp(ctx, ciq.ctx, ent.OpQueryIDs) if err = ciq.Select(configitem.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -199,7 +200,7 @@ func (ciq *ConfigItemQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (ciq *ConfigItemQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, ciq.ctx, "Count") + ctx = setContextOp(ctx, ciq.ctx, ent.OpQueryCount) if err := ciq.prepareQuery(ctx); err != nil { return 0, err } @@ -217,7 +218,7 @@ func (ciq *ConfigItemQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (ciq *ConfigItemQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, ciq.ctx, "Exist") + ctx = setContextOp(ctx, ciq.ctx, ent.OpQueryExist) switch _, err := ciq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -449,7 +450,7 @@ func (cigb *ConfigItemGroupBy) Aggregate(fns ...AggregateFunc) *ConfigItemGroupB // Scan applies the selector query and scans the result into the given value. func (cigb *ConfigItemGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, cigb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, cigb.build.ctx, ent.OpQueryGroupBy) if err := cigb.build.prepareQuery(ctx); err != nil { return err } @@ -497,7 +498,7 @@ func (cis *ConfigItemSelect) Aggregate(fns ...AggregateFunc) *ConfigItemSelect { // Scan applies the selector query and scans the result into the given value. func (cis *ConfigItemSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, cis.ctx, "Select") + ctx = setContextOp(ctx, cis.ctx, ent.OpQuerySelect) if err := cis.prepareQuery(ctx); err != nil { return err } diff --git a/pkg/database/ent/decision_query.go b/pkg/database/ent/decision_query.go index b050a4d9649..e5f0b16e8ad 100644 --- a/pkg/database/ent/decision_query.go +++ b/pkg/database/ent/decision_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -84,7 +85,7 @@ func (dq *DecisionQuery) QueryOwner() *AlertQuery { // First returns the first Decision entity from the query. // Returns a *NotFoundError when no Decision was found. func (dq *DecisionQuery) First(ctx context.Context) (*Decision, error) { - nodes, err := dq.Limit(1).All(setContextOp(ctx, dq.ctx, "First")) + nodes, err := dq.Limit(1).All(setContextOp(ctx, dq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -107,7 +108,7 @@ func (dq *DecisionQuery) FirstX(ctx context.Context) *Decision { // Returns a *NotFoundError when no Decision ID was found. func (dq *DecisionQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = dq.Limit(1).IDs(setContextOp(ctx, dq.ctx, "FirstID")); err != nil { + if ids, err = dq.Limit(1).IDs(setContextOp(ctx, dq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -130,7 +131,7 @@ func (dq *DecisionQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one Decision entity is found. // Returns a *NotFoundError when no Decision entities are found. func (dq *DecisionQuery) Only(ctx context.Context) (*Decision, error) { - nodes, err := dq.Limit(2).All(setContextOp(ctx, dq.ctx, "Only")) + nodes, err := dq.Limit(2).All(setContextOp(ctx, dq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -158,7 +159,7 @@ func (dq *DecisionQuery) OnlyX(ctx context.Context) *Decision { // Returns a *NotFoundError when no entities are found. func (dq *DecisionQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = dq.Limit(2).IDs(setContextOp(ctx, dq.ctx, "OnlyID")); err != nil { + if ids, err = dq.Limit(2).IDs(setContextOp(ctx, dq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -183,7 +184,7 @@ func (dq *DecisionQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of Decisions. func (dq *DecisionQuery) All(ctx context.Context) ([]*Decision, error) { - ctx = setContextOp(ctx, dq.ctx, "All") + ctx = setContextOp(ctx, dq.ctx, ent.OpQueryAll) if err := dq.prepareQuery(ctx); err != nil { return nil, err } @@ -205,7 +206,7 @@ func (dq *DecisionQuery) IDs(ctx context.Context) (ids []int, err error) { if dq.ctx.Unique == nil && dq.path != nil { dq.Unique(true) } - ctx = setContextOp(ctx, dq.ctx, "IDs") + ctx = setContextOp(ctx, dq.ctx, ent.OpQueryIDs) if err = dq.Select(decision.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -223,7 +224,7 @@ func (dq *DecisionQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (dq *DecisionQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, dq.ctx, "Count") + ctx = setContextOp(ctx, dq.ctx, ent.OpQueryCount) if err := dq.prepareQuery(ctx); err != nil { return 0, err } @@ -241,7 +242,7 @@ func (dq *DecisionQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (dq *DecisionQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, dq.ctx, "Exist") + ctx = setContextOp(ctx, dq.ctx, ent.OpQueryExist) switch _, err := dq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -528,7 +529,7 @@ func (dgb *DecisionGroupBy) Aggregate(fns ...AggregateFunc) *DecisionGroupBy { // Scan applies the selector query and scans the result into the given value. func (dgb *DecisionGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, dgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, dgb.build.ctx, ent.OpQueryGroupBy) if err := dgb.build.prepareQuery(ctx); err != nil { return err } @@ -576,7 +577,7 @@ func (ds *DecisionSelect) Aggregate(fns ...AggregateFunc) *DecisionSelect { // Scan applies the selector query and scans the result into the given value. func (ds *DecisionSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ds.ctx, "Select") + ctx = setContextOp(ctx, ds.ctx, ent.OpQuerySelect) if err := ds.prepareQuery(ctx); err != nil { return err } diff --git a/pkg/database/ent/ent.go b/pkg/database/ent/ent.go index 2a5ad188197..612b231518d 100644 --- a/pkg/database/ent/ent.go +++ b/pkg/database/ent/ent.go @@ -77,7 +77,7 @@ var ( columnCheck sql.ColumnCheck ) -// columnChecker checks if the column exists in the given table. +// checkColumn checks if the column exists in the given table. func checkColumn(table, column string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ diff --git a/pkg/database/ent/event_query.go b/pkg/database/ent/event_query.go index 1493d7bd32c..2a8a8d64119 100644 --- a/pkg/database/ent/event_query.go +++ b/pkg/database/ent/event_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -84,7 +85,7 @@ func (eq *EventQuery) QueryOwner() *AlertQuery { // First returns the first Event entity from the query. // Returns a *NotFoundError when no Event was found. func (eq *EventQuery) First(ctx context.Context) (*Event, error) { - nodes, err := eq.Limit(1).All(setContextOp(ctx, eq.ctx, "First")) + nodes, err := eq.Limit(1).All(setContextOp(ctx, eq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -107,7 +108,7 @@ func (eq *EventQuery) FirstX(ctx context.Context) *Event { // Returns a *NotFoundError when no Event ID was found. func (eq *EventQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = eq.Limit(1).IDs(setContextOp(ctx, eq.ctx, "FirstID")); err != nil { + if ids, err = eq.Limit(1).IDs(setContextOp(ctx, eq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -130,7 +131,7 @@ func (eq *EventQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one Event entity is found. // Returns a *NotFoundError when no Event entities are found. func (eq *EventQuery) Only(ctx context.Context) (*Event, error) { - nodes, err := eq.Limit(2).All(setContextOp(ctx, eq.ctx, "Only")) + nodes, err := eq.Limit(2).All(setContextOp(ctx, eq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -158,7 +159,7 @@ func (eq *EventQuery) OnlyX(ctx context.Context) *Event { // Returns a *NotFoundError when no entities are found. func (eq *EventQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = eq.Limit(2).IDs(setContextOp(ctx, eq.ctx, "OnlyID")); err != nil { + if ids, err = eq.Limit(2).IDs(setContextOp(ctx, eq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -183,7 +184,7 @@ func (eq *EventQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of Events. func (eq *EventQuery) All(ctx context.Context) ([]*Event, error) { - ctx = setContextOp(ctx, eq.ctx, "All") + ctx = setContextOp(ctx, eq.ctx, ent.OpQueryAll) if err := eq.prepareQuery(ctx); err != nil { return nil, err } @@ -205,7 +206,7 @@ func (eq *EventQuery) IDs(ctx context.Context) (ids []int, err error) { if eq.ctx.Unique == nil && eq.path != nil { eq.Unique(true) } - ctx = setContextOp(ctx, eq.ctx, "IDs") + ctx = setContextOp(ctx, eq.ctx, ent.OpQueryIDs) if err = eq.Select(event.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -223,7 +224,7 @@ func (eq *EventQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (eq *EventQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, eq.ctx, "Count") + ctx = setContextOp(ctx, eq.ctx, ent.OpQueryCount) if err := eq.prepareQuery(ctx); err != nil { return 0, err } @@ -241,7 +242,7 @@ func (eq *EventQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (eq *EventQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, eq.ctx, "Exist") + ctx = setContextOp(ctx, eq.ctx, ent.OpQueryExist) switch _, err := eq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -528,7 +529,7 @@ func (egb *EventGroupBy) Aggregate(fns ...AggregateFunc) *EventGroupBy { // Scan applies the selector query and scans the result into the given value. func (egb *EventGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, egb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, egb.build.ctx, ent.OpQueryGroupBy) if err := egb.build.prepareQuery(ctx); err != nil { return err } @@ -576,7 +577,7 @@ func (es *EventSelect) Aggregate(fns ...AggregateFunc) *EventSelect { // Scan applies the selector query and scans the result into the given value. func (es *EventSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, es.ctx, "Select") + ctx = setContextOp(ctx, es.ctx, ent.OpQuerySelect) if err := es.prepareQuery(ctx); err != nil { return err } diff --git a/pkg/database/ent/generate.go b/pkg/database/ent/generate.go index 8ada999d7ab..37ecd793cea 100644 --- a/pkg/database/ent/generate.go +++ b/pkg/database/ent/generate.go @@ -1,4 +1,4 @@ package ent -//go:generate go run -mod=mod entgo.io/ent/cmd/ent@v0.13.1 generate ./schema +//go:generate go run -mod=mod entgo.io/ent/cmd/ent@v0.14.1 generate ./schema diff --git a/pkg/database/ent/lock_query.go b/pkg/database/ent/lock_query.go index 75e5da48a94..5bc2c749a7f 100644 --- a/pkg/database/ent/lock_query.go +++ b/pkg/database/ent/lock_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -60,7 +61,7 @@ func (lq *LockQuery) Order(o ...lock.OrderOption) *LockQuery { // First returns the first Lock entity from the query. // Returns a *NotFoundError when no Lock was found. func (lq *LockQuery) First(ctx context.Context) (*Lock, error) { - nodes, err := lq.Limit(1).All(setContextOp(ctx, lq.ctx, "First")) + nodes, err := lq.Limit(1).All(setContextOp(ctx, lq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -83,7 +84,7 @@ func (lq *LockQuery) FirstX(ctx context.Context) *Lock { // Returns a *NotFoundError when no Lock ID was found. func (lq *LockQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = lq.Limit(1).IDs(setContextOp(ctx, lq.ctx, "FirstID")); err != nil { + if ids, err = lq.Limit(1).IDs(setContextOp(ctx, lq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -106,7 +107,7 @@ func (lq *LockQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one Lock entity is found. // Returns a *NotFoundError when no Lock entities are found. func (lq *LockQuery) Only(ctx context.Context) (*Lock, error) { - nodes, err := lq.Limit(2).All(setContextOp(ctx, lq.ctx, "Only")) + nodes, err := lq.Limit(2).All(setContextOp(ctx, lq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -134,7 +135,7 @@ func (lq *LockQuery) OnlyX(ctx context.Context) *Lock { // Returns a *NotFoundError when no entities are found. func (lq *LockQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = lq.Limit(2).IDs(setContextOp(ctx, lq.ctx, "OnlyID")); err != nil { + if ids, err = lq.Limit(2).IDs(setContextOp(ctx, lq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -159,7 +160,7 @@ func (lq *LockQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of Locks. func (lq *LockQuery) All(ctx context.Context) ([]*Lock, error) { - ctx = setContextOp(ctx, lq.ctx, "All") + ctx = setContextOp(ctx, lq.ctx, ent.OpQueryAll) if err := lq.prepareQuery(ctx); err != nil { return nil, err } @@ -181,7 +182,7 @@ func (lq *LockQuery) IDs(ctx context.Context) (ids []int, err error) { if lq.ctx.Unique == nil && lq.path != nil { lq.Unique(true) } - ctx = setContextOp(ctx, lq.ctx, "IDs") + ctx = setContextOp(ctx, lq.ctx, ent.OpQueryIDs) if err = lq.Select(lock.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -199,7 +200,7 @@ func (lq *LockQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (lq *LockQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, lq.ctx, "Count") + ctx = setContextOp(ctx, lq.ctx, ent.OpQueryCount) if err := lq.prepareQuery(ctx); err != nil { return 0, err } @@ -217,7 +218,7 @@ func (lq *LockQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (lq *LockQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, lq.ctx, "Exist") + ctx = setContextOp(ctx, lq.ctx, ent.OpQueryExist) switch _, err := lq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -449,7 +450,7 @@ func (lgb *LockGroupBy) Aggregate(fns ...AggregateFunc) *LockGroupBy { // Scan applies the selector query and scans the result into the given value. func (lgb *LockGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, lgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, lgb.build.ctx, ent.OpQueryGroupBy) if err := lgb.build.prepareQuery(ctx); err != nil { return err } @@ -497,7 +498,7 @@ func (ls *LockSelect) Aggregate(fns ...AggregateFunc) *LockSelect { // Scan applies the selector query and scans the result into the given value. func (ls *LockSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ls.ctx, "Select") + ctx = setContextOp(ctx, ls.ctx, ent.OpQuerySelect) if err := ls.prepareQuery(ctx); err != nil { return err } diff --git a/pkg/database/ent/machine.go b/pkg/database/ent/machine.go index 1b8122060d1..76127065791 100644 --- a/pkg/database/ent/machine.go +++ b/pkg/database/ent/machine.go @@ -202,7 +202,7 @@ func (m *Machine) assignValues(columns []string, values []any) error { return fmt.Errorf("unexpected type %T for field hubstate", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &m.Hubstate); err != nil { - return fmt.Errorf("parsing field hubstate: %w", err) + return fmt.Errorf("unmarshal field hubstate: %w", err) } } case machine.FieldDatasources: @@ -210,7 +210,7 @@ func (m *Machine) assignValues(columns []string, values []any) error { return fmt.Errorf("unexpected type %T for field datasources", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &m.Datasources); err != nil { - return fmt.Errorf("parsing field datasources: %w", err) + return fmt.Errorf("unmarshal field datasources: %w", err) } } default: diff --git a/pkg/database/ent/machine_query.go b/pkg/database/ent/machine_query.go index 462c2cf35b1..4367dc39670 100644 --- a/pkg/database/ent/machine_query.go +++ b/pkg/database/ent/machine_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -85,7 +86,7 @@ func (mq *MachineQuery) QueryAlerts() *AlertQuery { // First returns the first Machine entity from the query. // Returns a *NotFoundError when no Machine was found. func (mq *MachineQuery) First(ctx context.Context) (*Machine, error) { - nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First")) + nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -108,7 +109,7 @@ func (mq *MachineQuery) FirstX(ctx context.Context) *Machine { // Returns a *NotFoundError when no Machine ID was found. func (mq *MachineQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil { + if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -131,7 +132,7 @@ func (mq *MachineQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one Machine entity is found. // Returns a *NotFoundError when no Machine entities are found. func (mq *MachineQuery) Only(ctx context.Context) (*Machine, error) { - nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only")) + nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -159,7 +160,7 @@ func (mq *MachineQuery) OnlyX(ctx context.Context) *Machine { // Returns a *NotFoundError when no entities are found. func (mq *MachineQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil { + if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -184,7 +185,7 @@ func (mq *MachineQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of Machines. func (mq *MachineQuery) All(ctx context.Context) ([]*Machine, error) { - ctx = setContextOp(ctx, mq.ctx, "All") + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryAll) if err := mq.prepareQuery(ctx); err != nil { return nil, err } @@ -206,7 +207,7 @@ func (mq *MachineQuery) IDs(ctx context.Context) (ids []int, err error) { if mq.ctx.Unique == nil && mq.path != nil { mq.Unique(true) } - ctx = setContextOp(ctx, mq.ctx, "IDs") + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryIDs) if err = mq.Select(machine.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -224,7 +225,7 @@ func (mq *MachineQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (mq *MachineQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, mq.ctx, "Count") + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryCount) if err := mq.prepareQuery(ctx); err != nil { return 0, err } @@ -242,7 +243,7 @@ func (mq *MachineQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (mq *MachineQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, mq.ctx, "Exist") + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryExist) switch _, err := mq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -529,7 +530,7 @@ func (mgb *MachineGroupBy) Aggregate(fns ...AggregateFunc) *MachineGroupBy { // Scan applies the selector query and scans the result into the given value. func (mgb *MachineGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, mgb.build.ctx, ent.OpQueryGroupBy) if err := mgb.build.prepareQuery(ctx); err != nil { return err } @@ -577,7 +578,7 @@ func (ms *MachineSelect) Aggregate(fns ...AggregateFunc) *MachineSelect { // Scan applies the selector query and scans the result into the given value. func (ms *MachineSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ms.ctx, "Select") + ctx = setContextOp(ctx, ms.ctx, ent.OpQuerySelect) if err := ms.prepareQuery(ctx); err != nil { return err } diff --git a/pkg/database/ent/meta_query.go b/pkg/database/ent/meta_query.go index 87d91d09e0e..9b8acefaaea 100644 --- a/pkg/database/ent/meta_query.go +++ b/pkg/database/ent/meta_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -84,7 +85,7 @@ func (mq *MetaQuery) QueryOwner() *AlertQuery { // First returns the first Meta entity from the query. // Returns a *NotFoundError when no Meta was found. func (mq *MetaQuery) First(ctx context.Context) (*Meta, error) { - nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First")) + nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -107,7 +108,7 @@ func (mq *MetaQuery) FirstX(ctx context.Context) *Meta { // Returns a *NotFoundError when no Meta ID was found. func (mq *MetaQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil { + if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -130,7 +131,7 @@ func (mq *MetaQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one Meta entity is found. // Returns a *NotFoundError when no Meta entities are found. func (mq *MetaQuery) Only(ctx context.Context) (*Meta, error) { - nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only")) + nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -158,7 +159,7 @@ func (mq *MetaQuery) OnlyX(ctx context.Context) *Meta { // Returns a *NotFoundError when no entities are found. func (mq *MetaQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil { + if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -183,7 +184,7 @@ func (mq *MetaQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of MetaSlice. func (mq *MetaQuery) All(ctx context.Context) ([]*Meta, error) { - ctx = setContextOp(ctx, mq.ctx, "All") + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryAll) if err := mq.prepareQuery(ctx); err != nil { return nil, err } @@ -205,7 +206,7 @@ func (mq *MetaQuery) IDs(ctx context.Context) (ids []int, err error) { if mq.ctx.Unique == nil && mq.path != nil { mq.Unique(true) } - ctx = setContextOp(ctx, mq.ctx, "IDs") + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryIDs) if err = mq.Select(meta.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -223,7 +224,7 @@ func (mq *MetaQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (mq *MetaQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, mq.ctx, "Count") + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryCount) if err := mq.prepareQuery(ctx); err != nil { return 0, err } @@ -241,7 +242,7 @@ func (mq *MetaQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (mq *MetaQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, mq.ctx, "Exist") + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryExist) switch _, err := mq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -528,7 +529,7 @@ func (mgb *MetaGroupBy) Aggregate(fns ...AggregateFunc) *MetaGroupBy { // Scan applies the selector query and scans the result into the given value. func (mgb *MetaGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, mgb.build.ctx, ent.OpQueryGroupBy) if err := mgb.build.prepareQuery(ctx); err != nil { return err } @@ -576,7 +577,7 @@ func (ms *MetaSelect) Aggregate(fns ...AggregateFunc) *MetaSelect { // Scan applies the selector query and scans the result into the given value. func (ms *MetaSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ms.ctx, "Select") + ctx = setContextOp(ctx, ms.ctx, ent.OpQuerySelect) if err := ms.prepareQuery(ctx); err != nil { return err } diff --git a/pkg/database/ent/metric_query.go b/pkg/database/ent/metric_query.go index 6e1c6f08b4a..d8007eea31c 100644 --- a/pkg/database/ent/metric_query.go +++ b/pkg/database/ent/metric_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -60,7 +61,7 @@ func (mq *MetricQuery) Order(o ...metric.OrderOption) *MetricQuery { // First returns the first Metric entity from the query. // Returns a *NotFoundError when no Metric was found. func (mq *MetricQuery) First(ctx context.Context) (*Metric, error) { - nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First")) + nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -83,7 +84,7 @@ func (mq *MetricQuery) FirstX(ctx context.Context) *Metric { // Returns a *NotFoundError when no Metric ID was found. func (mq *MetricQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil { + if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -106,7 +107,7 @@ func (mq *MetricQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one Metric entity is found. // Returns a *NotFoundError when no Metric entities are found. func (mq *MetricQuery) Only(ctx context.Context) (*Metric, error) { - nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only")) + nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -134,7 +135,7 @@ func (mq *MetricQuery) OnlyX(ctx context.Context) *Metric { // Returns a *NotFoundError when no entities are found. func (mq *MetricQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil { + if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -159,7 +160,7 @@ func (mq *MetricQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of Metrics. func (mq *MetricQuery) All(ctx context.Context) ([]*Metric, error) { - ctx = setContextOp(ctx, mq.ctx, "All") + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryAll) if err := mq.prepareQuery(ctx); err != nil { return nil, err } @@ -181,7 +182,7 @@ func (mq *MetricQuery) IDs(ctx context.Context) (ids []int, err error) { if mq.ctx.Unique == nil && mq.path != nil { mq.Unique(true) } - ctx = setContextOp(ctx, mq.ctx, "IDs") + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryIDs) if err = mq.Select(metric.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -199,7 +200,7 @@ func (mq *MetricQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (mq *MetricQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, mq.ctx, "Count") + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryCount) if err := mq.prepareQuery(ctx); err != nil { return 0, err } @@ -217,7 +218,7 @@ func (mq *MetricQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (mq *MetricQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, mq.ctx, "Exist") + ctx = setContextOp(ctx, mq.ctx, ent.OpQueryExist) switch _, err := mq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -449,7 +450,7 @@ func (mgb *MetricGroupBy) Aggregate(fns ...AggregateFunc) *MetricGroupBy { // Scan applies the selector query and scans the result into the given value. func (mgb *MetricGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, mgb.build.ctx, ent.OpQueryGroupBy) if err := mgb.build.prepareQuery(ctx); err != nil { return err } @@ -497,7 +498,7 @@ func (ms *MetricSelect) Aggregate(fns ...AggregateFunc) *MetricSelect { // Scan applies the selector query and scans the result into the given value. func (ms *MetricSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ms.ctx, "Select") + ctx = setContextOp(ctx, ms.ctx, ent.OpQuerySelect) if err := ms.prepareQuery(ctx); err != nil { return err } diff --git a/pkg/database/ent/runtime/runtime.go b/pkg/database/ent/runtime/runtime.go index 9cb9d96258a..80f6699cc31 100644 --- a/pkg/database/ent/runtime/runtime.go +++ b/pkg/database/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in github.com/crowdsecurity/crowdsec/pkg/database/ent/runtime.go const ( - Version = "v0.13.1" // Version of ent codegen. - Sum = "h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE=" // Sum of ent codegen. + Version = "v0.14.1" // Version of ent codegen. + Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen. )