diff --git a/go.mod b/go.mod index c889b62cb8c..b01f815a924 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,13 @@ module github.com/crowdsecurity/crowdsec -go 1.23 +go 1.23.0 // 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 @@ -83,7 +83,7 @@ require ( github.com/wasilibs/go-re2 v1.7.0 github.com/xhit/go-simple-mail/v2 v2.16.0 golang.org/x/crypto v0.26.0 - golang.org/x/mod v0.17.0 + golang.org/x/mod v0.20.0 golang.org/x/sys v0.24.0 golang.org/x/text v0.17.0 google.golang.org/grpc v1.67.1 @@ -205,7 +205,7 @@ require ( 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.21.1-0.20240508182429-e35e4ccd0d2d // 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-20240814211410-ddb44dafa142 // indirect diff --git a/go.sum b/go.sum index b2bd77c9915..94dbb923532 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= @@ -56,8 +56,6 @@ github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7Rfg github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= github.com/aws/aws-sdk-go v1.52.0 h1:ptgek/4B2v/ljsjYSEvLQ8LTD+SQyrqhOOWvHc/VGPI= github.com/aws/aws-sdk-go v1.52.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/beevik/etree v1.3.0 h1:hQTc+pylzIKDb23yYprodCWWTt+ojFfUZyzU09a/hmU= -github.com/beevik/etree v1.3.0/go.mod h1:aiPf89g/1k3AShMVAzriilpcE4R/Vuor90y83zVZWFc= github.com/beevik/etree v1.4.1 h1:PmQJDDYahBGNKDcpdX8uPy1xRCwoCGVUiW669MEirVI= github.com/beevik/etree v1.4.1/go.mod h1:gPNJNaBGVZ9AwsidazFZyygnd+0pAU38N4D+WemwKNs= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -774,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.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.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= @@ -895,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.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +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_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. )