CI: "make generate" target; use ent 0.12.5 (#2871)

* CI: "make generate" target; pin tool versions
* use ent 0.12.5
* fix make help
* fix model generation target; re-run swagger
This commit is contained in:
mmetc 2024-03-07 14:25:25 +01:00 committed by GitHub
parent 5731491b4e
commit 8108e4156d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 367 additions and 11 deletions

View file

@ -202,6 +202,10 @@ cscli: goversion ## Build cscli
crowdsec: goversion ## Build crowdsec crowdsec: goversion ## Build crowdsec
@$(MAKE) -C $(CROWDSEC_FOLDER) build $(MAKE_FLAGS) @$(MAKE) -C $(CROWDSEC_FOLDER) build $(MAKE_FLAGS)
.PHONY: generate
generate: ## Generate code for the database and APIs
$(GO) generate ./pkg/database/ent
$(GO) generate ./pkg/models
.PHONY: testclean .PHONY: testclean
testclean: bats-clean ## Remove test artifacts testclean: bats-clean ## Remove test artifacts

2
go.mod
View file

@ -7,7 +7,7 @@ go 1.21
// toolchain go1.21.3 // toolchain go1.21.3
require ( require (
entgo.io/ent v0.12.4 entgo.io/ent v0.12.5
github.com/AlecAivazis/survey/v2 v2.3.7 github.com/AlecAivazis/survey/v2 v2.3.7
github.com/Masterminds/semver/v3 v3.2.1 github.com/Masterminds/semver/v3 v3.2.1
github.com/Masterminds/sprig/v3 v3.2.3 github.com/Masterminds/sprig/v3 v3.2.3

6
go.sum
View file

@ -2,8 +2,8 @@ ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935 h1:JnYs/y8RJ3+MiIUp+3RgyyeO
ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935/go.mod h1:isZrlzJ5cpoCoKFoY9knZug7Lq4pP1cm8g3XciLZ0Pw= ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935/go.mod h1:isZrlzJ5cpoCoKFoY9knZug7Lq4pP1cm8g3XciLZ0Pw=
bitbucket.org/creachadair/stringset v0.0.9 h1:L4vld9nzPt90UZNrXjNelTshD74ps4P5NGs3Iq6yN3o= bitbucket.org/creachadair/stringset v0.0.9 h1:L4vld9nzPt90UZNrXjNelTshD74ps4P5NGs3Iq6yN3o=
bitbucket.org/creachadair/stringset v0.0.9/go.mod h1:t+4WcQ4+PXTa8aQdNKe40ZP6iwesoMFWAxPGd3UGjyY= bitbucket.org/creachadair/stringset v0.0.9/go.mod h1:t+4WcQ4+PXTa8aQdNKe40ZP6iwesoMFWAxPGd3UGjyY=
entgo.io/ent v0.12.4 h1:LddPnAyxls/O7DTXZvUGDj0NZIdGSu317+aoNLJWbD8= entgo.io/ent v0.12.5 h1:KREM5E4CSoej4zeGa88Ou/gfturAnpUv0mzAjch1sj4=
entgo.io/ent v0.12.4/go.mod h1:Y3JVAjtlIk8xVZYSn3t3mf8xlZIn5SAOXZQxD6kKI+Q= entgo.io/ent v0.12.5/go.mod h1:Y3JVAjtlIk8xVZYSn3t3mf8xlZIn5SAOXZQxD6kKI+Q=
github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= 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/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
@ -540,8 +540,6 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 h1:rc3tiVYb5z54aKaDfakKn0dDjIyPpTtszkjuMzyt7ec= github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 h1:rc3tiVYb5z54aKaDfakKn0dDjIyPpTtszkjuMzyt7ec=

View file

@ -62,6 +62,14 @@ func (au *AlertUpdate) SetScenario(s string) *AlertUpdate {
return au return au
} }
// SetNillableScenario sets the "scenario" field if the given value is not nil.
func (au *AlertUpdate) SetNillableScenario(s *string) *AlertUpdate {
if s != nil {
au.SetScenario(*s)
}
return au
}
// SetBucketId sets the "bucketId" field. // SetBucketId sets the "bucketId" field.
func (au *AlertUpdate) SetBucketId(s string) *AlertUpdate { func (au *AlertUpdate) SetBucketId(s string) *AlertUpdate {
au.mutation.SetBucketId(s) au.mutation.SetBucketId(s)
@ -1029,6 +1037,14 @@ func (auo *AlertUpdateOne) SetScenario(s string) *AlertUpdateOne {
return auo return auo
} }
// SetNillableScenario sets the "scenario" field if the given value is not nil.
func (auo *AlertUpdateOne) SetNillableScenario(s *string) *AlertUpdateOne {
if s != nil {
auo.SetScenario(*s)
}
return auo
}
// SetBucketId sets the "bucketId" field. // SetBucketId sets the "bucketId" field.
func (auo *AlertUpdateOne) SetBucketId(s string) *AlertUpdateOne { func (auo *AlertUpdateOne) SetBucketId(s string) *AlertUpdateOne {
auo.mutation.SetBucketId(s) auo.mutation.SetBucketId(s)

View file

@ -58,18 +58,42 @@ func (bu *BouncerUpdate) SetName(s string) *BouncerUpdate {
return bu return bu
} }
// SetNillableName sets the "name" field if the given value is not nil.
func (bu *BouncerUpdate) SetNillableName(s *string) *BouncerUpdate {
if s != nil {
bu.SetName(*s)
}
return bu
}
// SetAPIKey sets the "api_key" field. // SetAPIKey sets the "api_key" field.
func (bu *BouncerUpdate) SetAPIKey(s string) *BouncerUpdate { func (bu *BouncerUpdate) SetAPIKey(s string) *BouncerUpdate {
bu.mutation.SetAPIKey(s) bu.mutation.SetAPIKey(s)
return bu return bu
} }
// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
func (bu *BouncerUpdate) SetNillableAPIKey(s *string) *BouncerUpdate {
if s != nil {
bu.SetAPIKey(*s)
}
return bu
}
// SetRevoked sets the "revoked" field. // SetRevoked sets the "revoked" field.
func (bu *BouncerUpdate) SetRevoked(b bool) *BouncerUpdate { func (bu *BouncerUpdate) SetRevoked(b bool) *BouncerUpdate {
bu.mutation.SetRevoked(b) bu.mutation.SetRevoked(b)
return bu return bu
} }
// SetNillableRevoked sets the "revoked" field if the given value is not nil.
func (bu *BouncerUpdate) SetNillableRevoked(b *bool) *BouncerUpdate {
if b != nil {
bu.SetRevoked(*b)
}
return bu
}
// SetIPAddress sets the "ip_address" field. // SetIPAddress sets the "ip_address" field.
func (bu *BouncerUpdate) SetIPAddress(s string) *BouncerUpdate { func (bu *BouncerUpdate) SetIPAddress(s string) *BouncerUpdate {
bu.mutation.SetIPAddress(s) bu.mutation.SetIPAddress(s)
@ -333,18 +357,42 @@ func (buo *BouncerUpdateOne) SetName(s string) *BouncerUpdateOne {
return buo return buo
} }
// SetNillableName sets the "name" field if the given value is not nil.
func (buo *BouncerUpdateOne) SetNillableName(s *string) *BouncerUpdateOne {
if s != nil {
buo.SetName(*s)
}
return buo
}
// SetAPIKey sets the "api_key" field. // SetAPIKey sets the "api_key" field.
func (buo *BouncerUpdateOne) SetAPIKey(s string) *BouncerUpdateOne { func (buo *BouncerUpdateOne) SetAPIKey(s string) *BouncerUpdateOne {
buo.mutation.SetAPIKey(s) buo.mutation.SetAPIKey(s)
return buo return buo
} }
// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
func (buo *BouncerUpdateOne) SetNillableAPIKey(s *string) *BouncerUpdateOne {
if s != nil {
buo.SetAPIKey(*s)
}
return buo
}
// SetRevoked sets the "revoked" field. // SetRevoked sets the "revoked" field.
func (buo *BouncerUpdateOne) SetRevoked(b bool) *BouncerUpdateOne { func (buo *BouncerUpdateOne) SetRevoked(b bool) *BouncerUpdateOne {
buo.mutation.SetRevoked(b) buo.mutation.SetRevoked(b)
return buo return buo
} }
// SetNillableRevoked sets the "revoked" field if the given value is not nil.
func (buo *BouncerUpdateOne) SetNillableRevoked(b *bool) *BouncerUpdateOne {
if b != nil {
buo.SetRevoked(*b)
}
return buo
}
// SetIPAddress sets the "ip_address" field. // SetIPAddress sets the "ip_address" field.
func (buo *BouncerUpdateOne) SetIPAddress(s string) *BouncerUpdateOne { func (buo *BouncerUpdateOne) SetIPAddress(s string) *BouncerUpdateOne {
buo.mutation.SetIPAddress(s) buo.mutation.SetIPAddress(s)

View file

@ -50,9 +50,7 @@ type Client struct {
// NewClient creates a new client configured with the given options. // NewClient creates a new client configured with the given options.
func NewClient(opts ...Option) *Client { func NewClient(opts ...Option) *Client {
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} client := &Client{config: newConfig(opts...)}
cfg.options(opts...)
client := &Client{config: cfg}
client.init() client.init()
return client return client
} }
@ -87,6 +85,13 @@ type (
Option func(*config) Option func(*config)
) )
// newConfig creates a new config for the client.
func newConfig(opts ...Option) config {
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
cfg.options(opts...)
return cfg
}
// options applies the options on the config object. // options applies the options on the config object.
func (c *config) options(opts ...Option) { func (c *config) options(opts ...Option) {
for _, opt := range opts { for _, opt := range opts {

View file

@ -58,12 +58,28 @@ func (ciu *ConfigItemUpdate) SetName(s string) *ConfigItemUpdate {
return ciu return ciu
} }
// SetNillableName sets the "name" field if the given value is not nil.
func (ciu *ConfigItemUpdate) SetNillableName(s *string) *ConfigItemUpdate {
if s != nil {
ciu.SetName(*s)
}
return ciu
}
// SetValue sets the "value" field. // SetValue sets the "value" field.
func (ciu *ConfigItemUpdate) SetValue(s string) *ConfigItemUpdate { func (ciu *ConfigItemUpdate) SetValue(s string) *ConfigItemUpdate {
ciu.mutation.SetValue(s) ciu.mutation.SetValue(s)
return ciu return ciu
} }
// SetNillableValue sets the "value" field if the given value is not nil.
func (ciu *ConfigItemUpdate) SetNillableValue(s *string) *ConfigItemUpdate {
if s != nil {
ciu.SetValue(*s)
}
return ciu
}
// Mutation returns the ConfigItemMutation object of the builder. // Mutation returns the ConfigItemMutation object of the builder.
func (ciu *ConfigItemUpdate) Mutation() *ConfigItemMutation { func (ciu *ConfigItemUpdate) Mutation() *ConfigItemMutation {
return ciu.mutation return ciu.mutation
@ -186,12 +202,28 @@ func (ciuo *ConfigItemUpdateOne) SetName(s string) *ConfigItemUpdateOne {
return ciuo return ciuo
} }
// SetNillableName sets the "name" field if the given value is not nil.
func (ciuo *ConfigItemUpdateOne) SetNillableName(s *string) *ConfigItemUpdateOne {
if s != nil {
ciuo.SetName(*s)
}
return ciuo
}
// SetValue sets the "value" field. // SetValue sets the "value" field.
func (ciuo *ConfigItemUpdateOne) SetValue(s string) *ConfigItemUpdateOne { func (ciuo *ConfigItemUpdateOne) SetValue(s string) *ConfigItemUpdateOne {
ciuo.mutation.SetValue(s) ciuo.mutation.SetValue(s)
return ciuo return ciuo
} }
// SetNillableValue sets the "value" field if the given value is not nil.
func (ciuo *ConfigItemUpdateOne) SetNillableValue(s *string) *ConfigItemUpdateOne {
if s != nil {
ciuo.SetValue(*s)
}
return ciuo
}
// Mutation returns the ConfigItemMutation object of the builder. // Mutation returns the ConfigItemMutation object of the builder.
func (ciuo *ConfigItemUpdateOne) Mutation() *ConfigItemMutation { func (ciuo *ConfigItemUpdateOne) Mutation() *ConfigItemMutation {
return ciuo.mutation return ciuo.mutation

View file

@ -79,12 +79,28 @@ func (du *DecisionUpdate) SetScenario(s string) *DecisionUpdate {
return du return du
} }
// SetNillableScenario sets the "scenario" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableScenario(s *string) *DecisionUpdate {
if s != nil {
du.SetScenario(*s)
}
return du
}
// SetType sets the "type" field. // SetType sets the "type" field.
func (du *DecisionUpdate) SetType(s string) *DecisionUpdate { func (du *DecisionUpdate) SetType(s string) *DecisionUpdate {
du.mutation.SetType(s) du.mutation.SetType(s)
return du return du
} }
// SetNillableType sets the "type" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableType(s *string) *DecisionUpdate {
if s != nil {
du.SetType(*s)
}
return du
}
// SetStartIP sets the "start_ip" field. // SetStartIP sets the "start_ip" field.
func (du *DecisionUpdate) SetStartIP(i int64) *DecisionUpdate { func (du *DecisionUpdate) SetStartIP(i int64) *DecisionUpdate {
du.mutation.ResetStartIP() du.mutation.ResetStartIP()
@ -226,18 +242,42 @@ func (du *DecisionUpdate) SetScope(s string) *DecisionUpdate {
return du return du
} }
// SetNillableScope sets the "scope" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableScope(s *string) *DecisionUpdate {
if s != nil {
du.SetScope(*s)
}
return du
}
// SetValue sets the "value" field. // SetValue sets the "value" field.
func (du *DecisionUpdate) SetValue(s string) *DecisionUpdate { func (du *DecisionUpdate) SetValue(s string) *DecisionUpdate {
du.mutation.SetValue(s) du.mutation.SetValue(s)
return du return du
} }
// SetNillableValue sets the "value" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableValue(s *string) *DecisionUpdate {
if s != nil {
du.SetValue(*s)
}
return du
}
// SetOrigin sets the "origin" field. // SetOrigin sets the "origin" field.
func (du *DecisionUpdate) SetOrigin(s string) *DecisionUpdate { func (du *DecisionUpdate) SetOrigin(s string) *DecisionUpdate {
du.mutation.SetOrigin(s) du.mutation.SetOrigin(s)
return du return du
} }
// SetNillableOrigin sets the "origin" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableOrigin(s *string) *DecisionUpdate {
if s != nil {
du.SetOrigin(*s)
}
return du
}
// SetSimulated sets the "simulated" field. // SetSimulated sets the "simulated" field.
func (du *DecisionUpdate) SetSimulated(b bool) *DecisionUpdate { func (du *DecisionUpdate) SetSimulated(b bool) *DecisionUpdate {
du.mutation.SetSimulated(b) du.mutation.SetSimulated(b)
@ -557,12 +597,28 @@ func (duo *DecisionUpdateOne) SetScenario(s string) *DecisionUpdateOne {
return duo return duo
} }
// SetNillableScenario sets the "scenario" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableScenario(s *string) *DecisionUpdateOne {
if s != nil {
duo.SetScenario(*s)
}
return duo
}
// SetType sets the "type" field. // SetType sets the "type" field.
func (duo *DecisionUpdateOne) SetType(s string) *DecisionUpdateOne { func (duo *DecisionUpdateOne) SetType(s string) *DecisionUpdateOne {
duo.mutation.SetType(s) duo.mutation.SetType(s)
return duo return duo
} }
// SetNillableType sets the "type" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableType(s *string) *DecisionUpdateOne {
if s != nil {
duo.SetType(*s)
}
return duo
}
// SetStartIP sets the "start_ip" field. // SetStartIP sets the "start_ip" field.
func (duo *DecisionUpdateOne) SetStartIP(i int64) *DecisionUpdateOne { func (duo *DecisionUpdateOne) SetStartIP(i int64) *DecisionUpdateOne {
duo.mutation.ResetStartIP() duo.mutation.ResetStartIP()
@ -704,18 +760,42 @@ func (duo *DecisionUpdateOne) SetScope(s string) *DecisionUpdateOne {
return duo return duo
} }
// SetNillableScope sets the "scope" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableScope(s *string) *DecisionUpdateOne {
if s != nil {
duo.SetScope(*s)
}
return duo
}
// SetValue sets the "value" field. // SetValue sets the "value" field.
func (duo *DecisionUpdateOne) SetValue(s string) *DecisionUpdateOne { func (duo *DecisionUpdateOne) SetValue(s string) *DecisionUpdateOne {
duo.mutation.SetValue(s) duo.mutation.SetValue(s)
return duo return duo
} }
// SetNillableValue sets the "value" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableValue(s *string) *DecisionUpdateOne {
if s != nil {
duo.SetValue(*s)
}
return duo
}
// SetOrigin sets the "origin" field. // SetOrigin sets the "origin" field.
func (duo *DecisionUpdateOne) SetOrigin(s string) *DecisionUpdateOne { func (duo *DecisionUpdateOne) SetOrigin(s string) *DecisionUpdateOne {
duo.mutation.SetOrigin(s) duo.mutation.SetOrigin(s)
return duo return duo
} }
// SetNillableOrigin sets the "origin" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableOrigin(s *string) *DecisionUpdateOne {
if s != nil {
duo.SetOrigin(*s)
}
return duo
}
// SetSimulated sets the "simulated" field. // SetSimulated sets the "simulated" field.
func (duo *DecisionUpdateOne) SetSimulated(b bool) *DecisionUpdateOne { func (duo *DecisionUpdateOne) SetSimulated(b bool) *DecisionUpdateOne {
duo.mutation.SetSimulated(b) duo.mutation.SetSimulated(b)

View file

@ -59,12 +59,28 @@ func (eu *EventUpdate) SetTime(t time.Time) *EventUpdate {
return eu return eu
} }
// SetNillableTime sets the "time" field if the given value is not nil.
func (eu *EventUpdate) SetNillableTime(t *time.Time) *EventUpdate {
if t != nil {
eu.SetTime(*t)
}
return eu
}
// SetSerialized sets the "serialized" field. // SetSerialized sets the "serialized" field.
func (eu *EventUpdate) SetSerialized(s string) *EventUpdate { func (eu *EventUpdate) SetSerialized(s string) *EventUpdate {
eu.mutation.SetSerialized(s) eu.mutation.SetSerialized(s)
return eu return eu
} }
// SetNillableSerialized sets the "serialized" field if the given value is not nil.
func (eu *EventUpdate) SetNillableSerialized(s *string) *EventUpdate {
if s != nil {
eu.SetSerialized(*s)
}
return eu
}
// SetAlertEvents sets the "alert_events" field. // SetAlertEvents sets the "alert_events" field.
func (eu *EventUpdate) SetAlertEvents(i int) *EventUpdate { func (eu *EventUpdate) SetAlertEvents(i int) *EventUpdate {
eu.mutation.SetAlertEvents(i) eu.mutation.SetAlertEvents(i)
@ -274,12 +290,28 @@ func (euo *EventUpdateOne) SetTime(t time.Time) *EventUpdateOne {
return euo return euo
} }
// SetNillableTime sets the "time" field if the given value is not nil.
func (euo *EventUpdateOne) SetNillableTime(t *time.Time) *EventUpdateOne {
if t != nil {
euo.SetTime(*t)
}
return euo
}
// SetSerialized sets the "serialized" field. // SetSerialized sets the "serialized" field.
func (euo *EventUpdateOne) SetSerialized(s string) *EventUpdateOne { func (euo *EventUpdateOne) SetSerialized(s string) *EventUpdateOne {
euo.mutation.SetSerialized(s) euo.mutation.SetSerialized(s)
return euo return euo
} }
// SetNillableSerialized sets the "serialized" field if the given value is not nil.
func (euo *EventUpdateOne) SetNillableSerialized(s *string) *EventUpdateOne {
if s != nil {
euo.SetSerialized(*s)
}
return euo
}
// SetAlertEvents sets the "alert_events" field. // SetAlertEvents sets the "alert_events" field.
func (euo *EventUpdateOne) SetAlertEvents(i int) *EventUpdateOne { func (euo *EventUpdateOne) SetAlertEvents(i int) *EventUpdateOne {
euo.mutation.SetAlertEvents(i) euo.mutation.SetAlertEvents(i)

View file

@ -1,4 +1,4 @@
package ent package ent
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema //go:generate go run -mod=mod entgo.io/ent/cmd/ent@v0.12.5 generate ./schema

View file

@ -34,6 +34,14 @@ func (lu *LockUpdate) SetName(s string) *LockUpdate {
return lu return lu
} }
// SetNillableName sets the "name" field if the given value is not nil.
func (lu *LockUpdate) SetNillableName(s *string) *LockUpdate {
if s != nil {
lu.SetName(*s)
}
return lu
}
// SetCreatedAt sets the "created_at" field. // SetCreatedAt sets the "created_at" field.
func (lu *LockUpdate) SetCreatedAt(t time.Time) *LockUpdate { func (lu *LockUpdate) SetCreatedAt(t time.Time) *LockUpdate {
lu.mutation.SetCreatedAt(t) lu.mutation.SetCreatedAt(t)
@ -121,6 +129,14 @@ func (luo *LockUpdateOne) SetName(s string) *LockUpdateOne {
return luo return luo
} }
// SetNillableName sets the "name" field if the given value is not nil.
func (luo *LockUpdateOne) SetNillableName(s *string) *LockUpdateOne {
if s != nil {
luo.SetName(*s)
}
return luo
}
// SetCreatedAt sets the "created_at" field. // SetCreatedAt sets the "created_at" field.
func (luo *LockUpdateOne) SetCreatedAt(t time.Time) *LockUpdateOne { func (luo *LockUpdateOne) SetCreatedAt(t time.Time) *LockUpdateOne {
luo.mutation.SetCreatedAt(t) luo.mutation.SetCreatedAt(t)

View file

@ -83,18 +83,42 @@ func (mu *MachineUpdate) SetMachineId(s string) *MachineUpdate {
return mu return mu
} }
// SetNillableMachineId sets the "machineId" field if the given value is not nil.
func (mu *MachineUpdate) SetNillableMachineId(s *string) *MachineUpdate {
if s != nil {
mu.SetMachineId(*s)
}
return mu
}
// SetPassword sets the "password" field. // SetPassword sets the "password" field.
func (mu *MachineUpdate) SetPassword(s string) *MachineUpdate { func (mu *MachineUpdate) SetPassword(s string) *MachineUpdate {
mu.mutation.SetPassword(s) mu.mutation.SetPassword(s)
return mu return mu
} }
// SetNillablePassword sets the "password" field if the given value is not nil.
func (mu *MachineUpdate) SetNillablePassword(s *string) *MachineUpdate {
if s != nil {
mu.SetPassword(*s)
}
return mu
}
// SetIpAddress sets the "ipAddress" field. // SetIpAddress sets the "ipAddress" field.
func (mu *MachineUpdate) SetIpAddress(s string) *MachineUpdate { func (mu *MachineUpdate) SetIpAddress(s string) *MachineUpdate {
mu.mutation.SetIpAddress(s) mu.mutation.SetIpAddress(s)
return mu return mu
} }
// SetNillableIpAddress sets the "ipAddress" field if the given value is not nil.
func (mu *MachineUpdate) SetNillableIpAddress(s *string) *MachineUpdate {
if s != nil {
mu.SetIpAddress(*s)
}
return mu
}
// SetScenarios sets the "scenarios" field. // SetScenarios sets the "scenarios" field.
func (mu *MachineUpdate) SetScenarios(s string) *MachineUpdate { func (mu *MachineUpdate) SetScenarios(s string) *MachineUpdate {
mu.mutation.SetScenarios(s) mu.mutation.SetScenarios(s)
@ -470,18 +494,42 @@ func (muo *MachineUpdateOne) SetMachineId(s string) *MachineUpdateOne {
return muo return muo
} }
// SetNillableMachineId sets the "machineId" field if the given value is not nil.
func (muo *MachineUpdateOne) SetNillableMachineId(s *string) *MachineUpdateOne {
if s != nil {
muo.SetMachineId(*s)
}
return muo
}
// SetPassword sets the "password" field. // SetPassword sets the "password" field.
func (muo *MachineUpdateOne) SetPassword(s string) *MachineUpdateOne { func (muo *MachineUpdateOne) SetPassword(s string) *MachineUpdateOne {
muo.mutation.SetPassword(s) muo.mutation.SetPassword(s)
return muo return muo
} }
// SetNillablePassword sets the "password" field if the given value is not nil.
func (muo *MachineUpdateOne) SetNillablePassword(s *string) *MachineUpdateOne {
if s != nil {
muo.SetPassword(*s)
}
return muo
}
// SetIpAddress sets the "ipAddress" field. // SetIpAddress sets the "ipAddress" field.
func (muo *MachineUpdateOne) SetIpAddress(s string) *MachineUpdateOne { func (muo *MachineUpdateOne) SetIpAddress(s string) *MachineUpdateOne {
muo.mutation.SetIpAddress(s) muo.mutation.SetIpAddress(s)
return muo return muo
} }
// SetNillableIpAddress sets the "ipAddress" field if the given value is not nil.
func (muo *MachineUpdateOne) SetNillableIpAddress(s *string) *MachineUpdateOne {
if s != nil {
muo.SetIpAddress(*s)
}
return muo
}
// SetScenarios sets the "scenarios" field. // SetScenarios sets the "scenarios" field.
func (muo *MachineUpdateOne) SetScenarios(s string) *MachineUpdateOne { func (muo *MachineUpdateOne) SetScenarios(s string) *MachineUpdateOne {
muo.mutation.SetScenarios(s) muo.mutation.SetScenarios(s)

View file

@ -59,12 +59,28 @@ func (mu *MetaUpdate) SetKey(s string) *MetaUpdate {
return mu return mu
} }
// SetNillableKey sets the "key" field if the given value is not nil.
func (mu *MetaUpdate) SetNillableKey(s *string) *MetaUpdate {
if s != nil {
mu.SetKey(*s)
}
return mu
}
// SetValue sets the "value" field. // SetValue sets the "value" field.
func (mu *MetaUpdate) SetValue(s string) *MetaUpdate { func (mu *MetaUpdate) SetValue(s string) *MetaUpdate {
mu.mutation.SetValue(s) mu.mutation.SetValue(s)
return mu return mu
} }
// SetNillableValue sets the "value" field if the given value is not nil.
func (mu *MetaUpdate) SetNillableValue(s *string) *MetaUpdate {
if s != nil {
mu.SetValue(*s)
}
return mu
}
// SetAlertMetas sets the "alert_metas" field. // SetAlertMetas sets the "alert_metas" field.
func (mu *MetaUpdate) SetAlertMetas(i int) *MetaUpdate { func (mu *MetaUpdate) SetAlertMetas(i int) *MetaUpdate {
mu.mutation.SetAlertMetas(i) mu.mutation.SetAlertMetas(i)
@ -274,12 +290,28 @@ func (muo *MetaUpdateOne) SetKey(s string) *MetaUpdateOne {
return muo return muo
} }
// SetNillableKey sets the "key" field if the given value is not nil.
func (muo *MetaUpdateOne) SetNillableKey(s *string) *MetaUpdateOne {
if s != nil {
muo.SetKey(*s)
}
return muo
}
// SetValue sets the "value" field. // SetValue sets the "value" field.
func (muo *MetaUpdateOne) SetValue(s string) *MetaUpdateOne { func (muo *MetaUpdateOne) SetValue(s string) *MetaUpdateOne {
muo.mutation.SetValue(s) muo.mutation.SetValue(s)
return muo return muo
} }
// SetNillableValue sets the "value" field if the given value is not nil.
func (muo *MetaUpdateOne) SetNillableValue(s *string) *MetaUpdateOne {
if s != nil {
muo.SetValue(*s)
}
return muo
}
// SetAlertMetas sets the "alert_metas" field. // SetAlertMetas sets the "alert_metas" field.
func (muo *MetaUpdateOne) SetAlertMetas(i int) *MetaUpdateOne { func (muo *MetaUpdateOne) SetAlertMetas(i int) *MetaUpdateOne {
muo.mutation.SetAlertMetas(i) muo.mutation.SetAlertMetas(i)

View file

@ -5,6 +5,6 @@ package runtime
// The schema-stitching logic is generated in github.com/crowdsecurity/crowdsec/pkg/database/ent/runtime.go // The schema-stitching logic is generated in github.com/crowdsecurity/crowdsec/pkg/database/ent/runtime.go
const ( const (
Version = "v0.12.4" // Version of ent codegen. Version = "v0.12.5" // Version of ent codegen.
Sum = "h1:LddPnAyxls/O7DTXZvUGDj0NZIdGSu317+aoNLJWbD8=" // Sum of ent codegen. Sum = "h1:KREM5E4CSoej4zeGa88Ou/gfturAnpUv0mzAjch1sj4=" // Sum of ent codegen.
) )

View file

@ -54,6 +54,11 @@ func (m AddAlertsRequest) ContextValidate(ctx context.Context, formats strfmt.Re
for i := 0; i < len(m); i++ { for i := 0; i < len(m); i++ {
if m[i] != nil { if m[i] != nil {
if swag.IsZero(m[i]) { // not required
return nil
}
if err := m[i].ContextValidate(ctx, formats); err != nil { if err := m[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok { if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i)) return ve.ValidateName(strconv.Itoa(i))

View file

@ -399,6 +399,11 @@ func (m *Alert) contextValidateDecisions(ctx context.Context, formats strfmt.Reg
for i := 0; i < len(m.Decisions); i++ { for i := 0; i < len(m.Decisions); i++ {
if m.Decisions[i] != nil { if m.Decisions[i] != nil {
if swag.IsZero(m.Decisions[i]) { // not required
return nil
}
if err := m.Decisions[i].ContextValidate(ctx, formats); err != nil { if err := m.Decisions[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok { if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("decisions" + "." + strconv.Itoa(i)) return ve.ValidateName("decisions" + "." + strconv.Itoa(i))
@ -419,6 +424,11 @@ func (m *Alert) contextValidateEvents(ctx context.Context, formats strfmt.Regist
for i := 0; i < len(m.Events); i++ { for i := 0; i < len(m.Events); i++ {
if m.Events[i] != nil { if m.Events[i] != nil {
if swag.IsZero(m.Events[i]) { // not required
return nil
}
if err := m.Events[i].ContextValidate(ctx, formats); err != nil { if err := m.Events[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok { if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("events" + "." + strconv.Itoa(i)) return ve.ValidateName("events" + "." + strconv.Itoa(i))
@ -469,6 +479,7 @@ func (m *Alert) contextValidateMeta(ctx context.Context, formats strfmt.Registry
func (m *Alert) contextValidateSource(ctx context.Context, formats strfmt.Registry) error { func (m *Alert) contextValidateSource(ctx context.Context, formats strfmt.Registry) error {
if m.Source != nil { if m.Source != nil {
if err := m.Source.ContextValidate(ctx, formats); err != nil { if err := m.Source.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok { if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("source") return ve.ValidateName("source")

4
pkg/models/generate.go Normal file
View file

@ -0,0 +1,4 @@
package models
//go:generate go run -mod=mod github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5 generate model --spec=./localapi_swagger.yaml --target=../

View file

@ -54,6 +54,11 @@ func (m GetAlertsResponse) ContextValidate(ctx context.Context, formats strfmt.R
for i := 0; i < len(m); i++ { for i := 0; i < len(m); i++ {
if m[i] != nil { if m[i] != nil {
if swag.IsZero(m[i]) { // not required
return nil
}
if err := m[i].ContextValidate(ctx, formats); err != nil { if err := m[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok { if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i)) return ve.ValidateName(strconv.Itoa(i))

View file

@ -54,6 +54,11 @@ func (m GetDecisionsResponse) ContextValidate(ctx context.Context, formats strfm
for i := 0; i < len(m); i++ { for i := 0; i < len(m); i++ {
if m[i] != nil { if m[i] != nil {
if swag.IsZero(m[i]) { // not required
return nil
}
if err := m[i].ContextValidate(ctx, formats); err != nil { if err := m[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok { if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i)) return ve.ValidateName(strconv.Itoa(i))

View file

@ -56,6 +56,11 @@ func (m Meta) ContextValidate(ctx context.Context, formats strfmt.Registry) erro
for i := 0; i < len(m); i++ { for i := 0; i < len(m); i++ {
if m[i] != nil { if m[i] != nil {
if swag.IsZero(m[i]) { // not required
return nil
}
if err := m[i].ContextValidate(ctx, formats); err != nil { if err := m[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok { if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName(strconv.Itoa(i)) return ve.ValidateName(strconv.Itoa(i))

View file

@ -141,6 +141,11 @@ func (m *Metrics) contextValidateBouncers(ctx context.Context, formats strfmt.Re
for i := 0; i < len(m.Bouncers); i++ { for i := 0; i < len(m.Bouncers); i++ {
if m.Bouncers[i] != nil { if m.Bouncers[i] != nil {
if swag.IsZero(m.Bouncers[i]) { // not required
return nil
}
if err := m.Bouncers[i].ContextValidate(ctx, formats); err != nil { if err := m.Bouncers[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok { if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("bouncers" + "." + strconv.Itoa(i)) return ve.ValidateName("bouncers" + "." + strconv.Itoa(i))
@ -161,6 +166,11 @@ func (m *Metrics) contextValidateMachines(ctx context.Context, formats strfmt.Re
for i := 0; i < len(m.Machines); i++ { for i := 0; i < len(m.Machines); i++ {
if m.Machines[i] != nil { if m.Machines[i] != nil {
if swag.IsZero(m.Machines[i]) { // not required
return nil
}
if err := m.Machines[i].ContextValidate(ctx, formats); err != nil { if err := m.Machines[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok { if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("machines" + "." + strconv.Itoa(i)) return ve.ValidateName("machines" + "." + strconv.Itoa(i))