Ent update : 0.7.0 (#692)

* up regenerate new schema

* new ent

* update documentation for min required versions

* update documentation
This commit is contained in:
Thibault "bui" Koechlin 2021-03-15 18:46:52 +01:00 committed by GitHub
parent 9d1e2f3795
commit 28446b6d29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 414 additions and 373 deletions

View file

@ -202,135 +202,136 @@ This is the schema of the database (as seen by `entc describe`)
```
Alert:
+-----------------+-----------+--------+----------+----------+---------+---------------+-----------+----------------------------------+------------+
| Field | Type | Unique | Optional | Nillable | Default | UpdateDefault | Immutable | StructTag | Validators |
+-----------------+-----------+--------+----------+----------+---------+---------------+-----------+----------------------------------+------------+
| id | int | false | false | false | false | false | false | json:"id,omitempty" | 0 |
| created_at | time.Time | false | false | false | true | false | false | json:"created_at,omitempty" | 0 |
| updated_at | time.Time | false | false | false | true | false | false | json:"updated_at,omitempty" | 0 |
| scenario | string | false | false | false | false | false | false | json:"scenario,omitempty" | 0 |
| bucketId | string | false | true | false | true | false | false | json:"bucketId,omitempty" | 0 |
| message | string | false | true | false | true | false | false | json:"message,omitempty" | 0 |
| eventsCount | int32 | false | true | false | true | false | false | json:"eventsCount,omitempty" | 0 |
| startedAt | time.Time | false | true | false | true | false | false | json:"startedAt,omitempty" | 0 |
| stoppedAt | time.Time | false | true | false | true | false | false | json:"stoppedAt,omitempty" | 0 |
| sourceIp | string | false | true | false | false | false | false | json:"sourceIp,omitempty" | 0 |
| sourceRange | string | false | true | false | false | false | false | json:"sourceRange,omitempty" | 0 |
| sourceAsNumber | string | false | true | false | false | false | false | json:"sourceAsNumber,omitempty" | 0 |
| sourceAsName | string | false | true | false | false | false | false | json:"sourceAsName,omitempty" | 0 |
| sourceCountry | string | false | true | false | false | false | false | json:"sourceCountry,omitempty" | 0 |
| sourceLatitude | float32 | false | true | false | false | false | false | json:"sourceLatitude,omitempty" | 0 |
| sourceLongitude | float32 | false | true | false | false | false | false | json:"sourceLongitude,omitempty" | 0 |
| sourceScope | string | false | true | false | false | false | false | json:"sourceScope,omitempty" | 0 |
| sourceValue | string | false | true | false | false | false | false | json:"sourceValue,omitempty" | 0 |
| capacity | int32 | false | true | false | false | false | false | json:"capacity,omitempty" | 0 |
| leakSpeed | string | false | true | false | false | false | false | json:"leakSpeed,omitempty" | 0 |
| scenarioVersion | string | false | true | false | false | false | false | json:"scenarioVersion,omitempty" | 0 |
| scenarioHash | string | false | true | false | false | false | false | json:"scenarioHash,omitempty" | 0 |
| simulated | bool | false | false | false | true | false | false | json:"simulated,omitempty" | 0 |
+-----------------+-----------+--------+----------+----------+---------+---------------+-----------+----------------------------------+------------+
+-----------+----------+---------+---------+----------+--------+----------+
| Edge | Type | Inverse | BackRef | Relation | Unique | Optional |
+-----------+----------+---------+---------+----------+--------+----------+
| owner | Machine | true | alerts | M2O | true | true |
| decisions | Decision | false | | O2M | false | true |
| events | Event | false | | O2M | false | true |
| metas | Meta | false | | O2M | false | true |
+-----------+----------+---------+---------+----------+--------+----------+
+-----------------+-----------+--------+----------+----------+---------+---------------+-----------+----------------------------------+------------+
| Field | Type | Unique | Optional | Nillable | Default | UpdateDefault | Immutable | StructTag | Validators |
+-----------------+-----------+--------+----------+----------+---------+---------------+-----------+----------------------------------+------------+
| id | int | false | false | false | false | false | false | json:"id,omitempty" | 0 |
| created_at | time.Time | false | false | false | true | false | false | json:"created_at,omitempty" | 0 |
| updated_at | time.Time | false | false | false | true | false | false | json:"updated_at,omitempty" | 0 |
| scenario | string | false | false | false | false | false | false | json:"scenario,omitempty" | 0 |
| bucketId | string | false | true | false | true | false | false | json:"bucketId,omitempty" | 0 |
| message | string | false | true | false | true | false | false | json:"message,omitempty" | 0 |
| eventsCount | int32 | false | true | false | true | false | false | json:"eventsCount,omitempty" | 0 |
| startedAt | time.Time | false | true | false | true | false | false | json:"startedAt,omitempty" | 0 |
| stoppedAt | time.Time | false | true | false | true | false | false | json:"stoppedAt,omitempty" | 0 |
| sourceIp | string | false | true | false | false | false | false | json:"sourceIp,omitempty" | 0 |
| sourceRange | string | false | true | false | false | false | false | json:"sourceRange,omitempty" | 0 |
| sourceAsNumber | string | false | true | false | false | false | false | json:"sourceAsNumber,omitempty" | 0 |
| sourceAsName | string | false | true | false | false | false | false | json:"sourceAsName,omitempty" | 0 |
| sourceCountry | string | false | true | false | false | false | false | json:"sourceCountry,omitempty" | 0 |
| sourceLatitude | float32 | false | true | false | false | false | false | json:"sourceLatitude,omitempty" | 0 |
| sourceLongitude | float32 | false | true | false | false | false | false | json:"sourceLongitude,omitempty" | 0 |
| sourceScope | string | false | true | false | false | false | false | json:"sourceScope,omitempty" | 0 |
| sourceValue | string | false | true | false | false | false | false | json:"sourceValue,omitempty" | 0 |
| capacity | int32 | false | true | false | false | false | false | json:"capacity,omitempty" | 0 |
| leakSpeed | string | false | true | false | false | false | false | json:"leakSpeed,omitempty" | 0 |
| scenarioVersion | string | false | true | false | false | false | false | json:"scenarioVersion,omitempty" | 0 |
| scenarioHash | string | false | true | false | false | false | false | json:"scenarioHash,omitempty" | 0 |
| simulated | bool | false | false | false | true | false | false | json:"simulated,omitempty" | 0 |
+-----------------+-----------+--------+----------+----------+---------+---------------+-----------+----------------------------------+------------+
+-----------+----------+---------+---------+----------+--------+----------+
| Edge | Type | Inverse | BackRef | Relation | Unique | Optional |
+-----------+----------+---------+---------+----------+--------+----------+
| owner | Machine | true | alerts | M2O | true | true |
| decisions | Decision | false | | O2M | false | true |
| events | Event | false | | O2M | false | true |
| metas | Meta | false | | O2M | false | true |
+-----------+----------+---------+---------+----------+--------+----------+
Bouncer:
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
| Field | Type | Unique | Optional | Nillable | Default | UpdateDefault | Immutable | StructTag | Validators |
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
| id | int | false | false | false | false | false | false | json:"id,omitempty" | 0 |
| created_at | time.Time | false | false | false | true | false | false | json:"created_at,omitempty" | 0 |
| updated_at | time.Time | false | false | false | true | false | false | json:"updated_at,omitempty" | 0 |
| name | string | true | false | false | false | false | false | json:"name,omitempty" | 0 |
| api_key | string | false | false | false | false | false | false | json:"api_key,omitempty" | 0 |
| revoked | bool | false | false | false | false | false | false | json:"revoked,omitempty" | 0 |
| ip_address | string | false | true | false | true | false | false | json:"ip_address,omitempty" | 0 |
| type | string | false | true | false | false | false | false | json:"type,omitempty" | 0 |
| version | string | false | true | false | false | false | false | json:"version,omitempty" | 0 |
| until | time.Time | false | true | false | true | false | false | json:"until,omitempty" | 0 |
| last_pull | time.Time | false | false | false | true | false | false | json:"last_pull,omitempty" | 0 |
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
| Field | Type | Unique | Optional | Nillable | Default | UpdateDefault | Immutable | StructTag | Validators |
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
| id | int | false | false | false | false | false | false | json:"id,omitempty" | 0 |
| created_at | time.Time | false | false | false | true | false | false | json:"created_at,omitempty" | 0 |
| updated_at | time.Time | false | false | false | true | false | false | json:"updated_at,omitempty" | 0 |
| name | string | true | false | false | false | false | false | json:"name,omitempty" | 0 |
| api_key | string | false | false | false | false | false | false | json:"api_key,omitempty" | 0 |
| revoked | bool | false | false | false | false | false | false | json:"revoked,omitempty" | 0 |
| ip_address | string | false | true | false | true | false | false | json:"ip_address,omitempty" | 0 |
| type | string | false | true | false | false | false | false | json:"type,omitempty" | 0 |
| version | string | false | true | false | false | false | false | json:"version,omitempty" | 0 |
| until | time.Time | false | true | false | true | false | false | json:"until,omitempty" | 0 |
| last_pull | time.Time | false | false | false | true | false | false | json:"last_pull,omitempty" | 0 |
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
Decision:
+--------------+-----------+--------+----------+----------+---------+---------------+-----------+-------------------------------+------------+
| Field | Type | Unique | Optional | Nillable | Default | UpdateDefault | Immutable | StructTag | Validators |
+--------------+-----------+--------+----------+----------+---------+---------------+-----------+-------------------------------+------------+
| id | int | false | false | false | false | false | false | json:"id,omitempty" | 0 |
| created_at | time.Time | false | false | false | true | false | false | json:"created_at,omitempty" | 0 |
| updated_at | time.Time | false | false | false | true | false | false | json:"updated_at,omitempty" | 0 |
| until | time.Time | false | false | false | false | false | false | json:"until,omitempty" | 0 |
| scenario | string | false | false | false | false | false | false | json:"scenario,omitempty" | 0 |
| type | string | false | false | false | false | false | false | json:"type,omitempty" | 0 |
| start_ip | int64 | false | true | false | false | false | false | json:"start_ip,omitempty" | 0 |
| end_ip | int64 | false | true | false | false | false | false | json:"end_ip,omitempty" | 0 |
| start_suffix | int64 | false | true | false | false | false | false | json:"start_suffix,omitempty" | 0 |
| end_suffix | int64 | false | true | false | false | false | false | json:"end_suffix,omitempty" | 0 |
| ip_size | int64 | false | true | false | false | false | false | json:"ip_size,omitempty" | 0 |
| scope | string | false | false | false | false | false | false | json:"scope,omitempty" | 0 |
| value | string | false | false | false | false | false | false | json:"value,omitempty" | 0 |
| origin | string | false | false | false | false | false | false | json:"origin,omitempty" | 0 |
| simulated | bool | false | false | false | true | false | false | json:"simulated,omitempty" | 0 |
+--------------+-----------+--------+----------+----------+---------+---------------+-----------+-------------------------------+------------+
+-------+-------+---------+-----------+----------+--------+----------+
| Edge | Type | Inverse | BackRef | Relation | Unique | Optional |
+-------+-------+---------+-----------+----------+--------+----------+
| owner | Alert | true | decisions | M2O | true | true |
+-------+-------+---------+-----------+----------+--------+----------+
+--------------+-----------+--------+----------+----------+---------+---------------+-----------+-------------------------------+------------+
| Field | Type | Unique | Optional | Nillable | Default | UpdateDefault | Immutable | StructTag | Validators |
+--------------+-----------+--------+----------+----------+---------+---------------+-----------+-------------------------------+------------+
| id | int | false | false | false | false | false | false | json:"id,omitempty" | 0 |
| created_at | time.Time | false | false | false | true | false | false | json:"created_at,omitempty" | 0 |
| updated_at | time.Time | false | false | false | true | false | false | json:"updated_at,omitempty" | 0 |
| until | time.Time | false | false | false | false | false | false | json:"until,omitempty" | 0 |
| scenario | string | false | false | false | false | false | false | json:"scenario,omitempty" | 0 |
| type | string | false | false | false | false | false | false | json:"type,omitempty" | 0 |
| start_ip | int64 | false | true | false | false | false | false | json:"start_ip,omitempty" | 0 |
| end_ip | int64 | false | true | false | false | false | false | json:"end_ip,omitempty" | 0 |
| start_suffix | int64 | false | true | false | false | false | false | json:"start_suffix,omitempty" | 0 |
| end_suffix | int64 | false | true | false | false | false | false | json:"end_suffix,omitempty" | 0 |
| ip_size | int64 | false | true | false | false | false | false | json:"ip_size,omitempty" | 0 |
| scope | string | false | false | false | false | false | false | json:"scope,omitempty" | 0 |
| value | string | false | false | false | false | false | false | json:"value,omitempty" | 0 |
| origin | string | false | false | false | false | false | false | json:"origin,omitempty" | 0 |
| simulated | bool | false | false | false | true | false | false | json:"simulated,omitempty" | 0 |
+--------------+-----------+--------+----------+----------+---------+---------------+-----------+-------------------------------+------------+
+-------+-------+---------+-----------+----------+--------+----------+
| Edge | Type | Inverse | BackRef | Relation | Unique | Optional |
+-------+-------+---------+-----------+----------+--------+----------+
| owner | Alert | true | decisions | M2O | true | true |
+-------+-------+---------+-----------+----------+--------+----------+
Event:
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
| Field | Type | Unique | Optional | Nillable | Default | UpdateDefault | Immutable | StructTag | Validators |
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
| id | int | false | false | false | false | false | false | json:"id,omitempty" | 0 |
| created_at | time.Time | false | false | false | true | false | false | json:"created_at,omitempty" | 0 |
| updated_at | time.Time | false | false | false | true | false | false | json:"updated_at,omitempty" | 0 |
| time | time.Time | false | false | false | false | false | false | json:"time,omitempty" | 0 |
| serialized | string | false | false | false | false | false | false | json:"serialized,omitempty" | 1 |
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
+-------+-------+---------+---------+----------+--------+----------+
| Edge | Type | Inverse | BackRef | Relation | Unique | Optional |
+-------+-------+---------+---------+----------+--------+----------+
| owner | Alert | true | events | M2O | true | true |
+-------+-------+---------+---------+----------+--------+----------+
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
| Field | Type | Unique | Optional | Nillable | Default | UpdateDefault | Immutable | StructTag | Validators |
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
| id | int | false | false | false | false | false | false | json:"id,omitempty" | 0 |
| created_at | time.Time | false | false | false | true | false | false | json:"created_at,omitempty" | 0 |
| updated_at | time.Time | false | false | false | true | false | false | json:"updated_at,omitempty" | 0 |
| time | time.Time | false | false | false | false | false | false | json:"time,omitempty" | 0 |
| serialized | string | false | false | false | false | false | false | json:"serialized,omitempty" | 1 |
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
+-------+-------+---------+---------+----------+--------+----------+
| Edge | Type | Inverse | BackRef | Relation | Unique | Optional |
+-------+-------+---------+---------+----------+--------+----------+
| owner | Alert | true | events | M2O | true | true |
+-------+-------+---------+---------+----------+--------+----------+
Machine:
+-------------+-----------+--------+----------+----------+---------+---------------+-----------+------------------------------+------------+
| Field | Type | Unique | Optional | Nillable | Default | UpdateDefault | Immutable | StructTag | Validators |
+-------------+-----------+--------+----------+----------+---------+---------------+-----------+------------------------------+------------+
| id | int | false | false | false | false | false | false | json:"id,omitempty" | 0 |
| created_at | time.Time | false | false | false | true | false | false | json:"created_at,omitempty" | 0 |
| updated_at | time.Time | false | false | false | true | false | false | json:"updated_at,omitempty" | 0 |
| machineId | string | true | false | false | false | false | false | json:"machineId,omitempty" | 0 |
| password | string | false | false | false | false | false | false | json:"password,omitempty" | 0 |
| ipAddress | string | false | false | false | false | false | false | json:"ipAddress,omitempty" | 0 |
| scenarios | string | false | true | false | false | false | false | json:"scenarios,omitempty" | 1 |
| version | string | false | true | false | false | false | false | json:"version,omitempty" | 0 |
| isValidated | bool | false | false | false | true | false | false | json:"isValidated,omitempty" | 0 |
| status | string | false | true | false | false | false | false | json:"status,omitempty" | 0 |
+-------------+-----------+--------+----------+----------+---------+---------------+-----------+------------------------------+------------+
+--------+-------+---------+---------+----------+--------+----------+
| Edge | Type | Inverse | BackRef | Relation | Unique | Optional |
+--------+-------+---------+---------+----------+--------+----------+
| alerts | Alert | false | | O2M | false | true |
+--------+-------+---------+---------+----------+--------+----------+
+-------------+-----------+--------+----------+----------+---------+---------------+-----------+------------------------------+------------+
| Field | Type | Unique | Optional | Nillable | Default | UpdateDefault | Immutable | StructTag | Validators |
+-------------+-----------+--------+----------+----------+---------+---------------+-----------+------------------------------+------------+
| id | int | false | false | false | false | false | false | json:"id,omitempty" | 0 |
| created_at | time.Time | false | false | false | true | false | false | json:"created_at,omitempty" | 0 |
| updated_at | time.Time | false | false | false | true | false | false | json:"updated_at,omitempty" | 0 |
| machineId | string | true | false | false | false | false | false | json:"machineId,omitempty" | 0 |
| password | string | false | false | false | false | false | false | json:"password,omitempty" | 0 |
| ipAddress | string | false | false | false | false | false | false | json:"ipAddress,omitempty" | 0 |
| scenarios | string | false | true | false | false | false | false | json:"scenarios,omitempty" | 1 |
| version | string | false | true | false | false | false | false | json:"version,omitempty" | 0 |
| isValidated | bool | false | false | false | true | false | false | json:"isValidated,omitempty" | 0 |
| status | string | false | true | false | false | false | false | json:"status,omitempty" | 0 |
+-------------+-----------+--------+----------+----------+---------+---------------+-----------+------------------------------+------------+
+--------+-------+---------+---------+----------+--------+----------+
| Edge | Type | Inverse | BackRef | Relation | Unique | Optional |
+--------+-------+---------+---------+----------+--------+----------+
| alerts | Alert | false | | O2M | false | true |
+--------+-------+---------+---------+----------+--------+----------+
Meta:
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
| Field | Type | Unique | Optional | Nillable | Default | UpdateDefault | Immutable | StructTag | Validators |
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
| id | int | false | false | false | false | false | false | json:"id,omitempty" | 0 |
| created_at | time.Time | false | false | false | true | false | false | json:"created_at,omitempty" | 0 |
| updated_at | time.Time | false | false | false | true | false | false | json:"updated_at,omitempty" | 0 |
| key | string | false | false | false | false | false | false | json:"key,omitempty" | 0 |
| value | string | false | false | false | false | false | false | json:"value,omitempty" | 1 |
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
+-------+-------+---------+---------+----------+--------+----------+
| Edge | Type | Inverse | BackRef | Relation | Unique | Optional |
+-------+-------+---------+---------+----------+--------+----------+
| owner | Alert | true | metas | M2O | true | true |
+-------+-------+---------+---------+----------+--------+----------+
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
| Field | Type | Unique | Optional | Nillable | Default | UpdateDefault | Immutable | StructTag | Validators |
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
| id | int | false | false | false | false | false | false | json:"id,omitempty" | 0 |
| created_at | time.Time | false | false | false | true | false | false | json:"created_at,omitempty" | 0 |
| updated_at | time.Time | false | false | false | true | false | false | json:"updated_at,omitempty" | 0 |
| key | string | false | false | false | false | false | false | json:"key,omitempty" | 0 |
| value | string | false | false | false | false | false | false | json:"value,omitempty" | 1 |
+------------+-----------+--------+----------+----------+---------+---------------+-----------+-----------------------------+------------+
+-------+-------+---------+---------+----------+--------+----------+
| Edge | Type | Inverse | BackRef | Relation | Unique | Optional |
+-------+-------+---------+---------+----------+--------+----------+
| owner | Alert | true | metas | M2O | true | true |
+-------+-------+---------+---------+----------+--------+----------+
```

View file

@ -2,7 +2,16 @@
By default, the crowdsec Local API use `SQLite` as backend storage. But in case you expect a lot of traffic on your local API, you should use `MySQL` or `PostgreSQL`.
For `SQLite`, there is nothing to do on your side in order to make it work with crowdsec. But for `MySQL` and `PostgreSQL` , you have to create the database and the user.
For `SQLite`, there is nothing to do to make it work with crowdsec. But for `MySQL` and `PostgreSQL` , you have to create the database and the user.
Please refer to [ent.](https://entgo.io/) [supported database](https://entgo.io/docs/dialects/). At the time of writting :
- MySQL `5.6.35`, `5.7.26` and `8`
- MariaDB `10.2` and latest
- PostgreSQL `10`, `11` and `12`
- SQLite
- Gremlin
## MySQL

14
go.mod
View file

@ -3,6 +3,7 @@ module github.com/crowdsecurity/crowdsec
go 1.13
require (
entgo.io/ent v0.7.0
github.com/AlecAivazis/survey/v2 v2.2.7
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/antonmedv/expr v1.8.9
@ -17,7 +18,6 @@ require (
github.com/docker/docker v20.10.2+incompatible
github.com/docker/go-connections v0.4.0
github.com/enescakir/emoji v1.0.0
github.com/facebook/ent v0.5.4
github.com/gin-gonic/gin v1.6.3
github.com/go-co-op/gocron v0.5.1
github.com/go-openapi/errors v0.19.9
@ -28,22 +28,20 @@ require (
github.com/go-sql-driver/mysql v1.5.1-0.20200311113236-681ffa848bae
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-querystring v1.0.0
github.com/google/uuid v1.1.5 // indirect
github.com/goombaio/namegenerator v0.0.0-20181006234301-989e774b106e
github.com/hashicorp/go-version v1.2.1
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lib/pq v1.9.0
github.com/lib/pq v1.10.0
github.com/logrusorgru/grokky v0.0.0-20180829062225-47edf017d42c
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-runewidth v0.0.10 // indirect
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/morikuni/aec v1.0.0 // indirect
github.com/nxadm/tail v1.4.6
github.com/olekukonko/tablewriter v0.0.4
github.com/olekukonko/tablewriter v0.0.5
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/oschwald/geoip2-golang v1.4.0
@ -56,14 +54,14 @@ require (
github.com/rivo/uniseg v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.7.0
github.com/spf13/cobra v1.1.1
github.com/stretchr/testify v1.6.1
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.0
github.com/ugorji/go v1.2.3 // indirect
github.com/vjeantet/grok v1.0.1 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/mod v0.4.1
golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
golang.org/x/text v0.3.5 // indirect
google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f // indirect

40
go.sum
View file

@ -11,6 +11,8 @@ cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqCl
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
entgo.io/ent v0.7.0 h1:E3EjO0cUL61DvUg5ZEZdxa4yTL+4SuZv0LqBExo8CQA=
entgo.io/ent v0.7.0/go.mod h1:HZZJxglL8ro4OVDmM06lijj4bOTGcaDdrZttDZ8fVJs=
github.com/AlecAivazis/survey/v2 v2.2.7 h1:5NbxkF4RSKmpywYdcRgUmos1o+roJY8duCLZXbVjoig=
github.com/AlecAivazis/survey/v2 v2.2.7/go.mod h1:9DYvHgXtiXm6nCn+jXnOXLKbH+Yo9u8fAS/SduGdoPk=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
@ -85,6 +87,7 @@ github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
@ -138,10 +141,9 @@ github.com/enescakir/emoji v1.0.0/go.mod h1:Bt1EKuLnKDTYpLALApstIkAjdDrS/8IAgTkK
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/facebook/ent v0.5.4 h1:kIf2BQUdRJ7XrlTXzCyJCg69ar1K1FjFR2UQWRo/M8M=
github.com/facebook/ent v0.5.4/go.mod h1:ZioHzZjDTB/uPABl7pff/v2+cdsEBca8roSTWW3/UaE=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
@ -346,6 +348,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@ -356,10 +360,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.4 h1:0ecGp3skIrHWPNGPJDaBIghfA6Sp7Ruo2Io8eLKzWm0=
github.com/google/uuid v1.1.4/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.5 h1:kxhtnfFVi+rYdOALN0B3k9UT86zVJKfBimRaciULW4I=
github.com/google/uuid v1.1.5/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/goombaio/namegenerator v0.0.0-20181006234301-989e774b106e h1:XmA6L9IPRdUr28a+SK/oMchGgQy159wvzXA5tJ7l+40=
@ -454,8 +456,8 @@ github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8=
github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.0 h1:Zx5DJFEYQXio93kgXnQ09fXNiUKsqv4OUEu2UtGcB1E=
github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
github.com/logrusorgru/grokky v0.0.0-20180829062225-47edf017d42c h1:S3P1IbG7Z7V2p9juEttr1oRwozZd2kxw+RQiYBYB1wQ=
@ -486,7 +488,6 @@ github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHX
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.8 h1:3tS41NlGYSmhhe/8fhGRzc+z3AYCw1Fe1WAyLuujKs0=
github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
@ -548,8 +549,8 @@ github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtb
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
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/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
@ -663,8 +664,8 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4=
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M=
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
@ -687,6 +688,8 @@ github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tidwall/gjson v1.6.0 h1:9VEQWz6LLMUsUl6PueE49ir4Ka6CzLymOAZDxpFsTDc=
github.com/tidwall/gjson v1.6.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
@ -731,7 +734,7 @@ go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
@ -870,8 +873,8 @@ golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 h1:nVuTkr9L6Bq62qpUqKo/RnZCFfzDBL0bYo6w9OJUqZY=
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M=
@ -925,9 +928,9 @@ golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210105164027-a548c3f4af2d h1:v9TQ4+tS+0r4R+9E6svkcl6ocSxeHONeVkK2y6YhzmA=
golang.org/x/tools v0.0.0-20210105164027-a548c3f4af2d/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
@ -976,6 +979,7 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.35.0 h1:TwIQcH3es+MojMVojxxfQ3l3OF2KzlRxML2xZq0kRo8=
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=

View file

@ -7,9 +7,9 @@ import (
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
"github.com/facebook/ent/dialect/sql"
)
// Alert is the model entity for the Alert schema.
@ -70,13 +70,13 @@ type Alert struct {
// AlertEdges holds the relations/edges for other nodes in the graph.
type AlertEdges struct {
// Owner holds the value of the owner edge.
Owner *Machine
Owner *Machine `json:"owner,omitempty"`
// Decisions holds the value of the decisions edge.
Decisions []*Decision
Decisions []*Decision `json:"decisions,omitempty"`
// Events holds the value of the events edge.
Events []*Event
Events []*Event `json:"events,omitempty"`
// Metas holds the value of the metas edge.
Metas []*Meta
Metas []*Meta `json:"metas,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [4]bool

View file

@ -55,7 +55,6 @@ const (
FieldScenarioHash = "scenario_hash"
// FieldSimulated holds the string denoting the simulated field in the database.
FieldSimulated = "simulated"
// EdgeOwner holds the string denoting the owner edge name in mutations.
EdgeOwner = "owner"
// EdgeDecisions holds the string denoting the decisions edge name in mutations.
@ -64,7 +63,6 @@ const (
EdgeEvents = "events"
// EdgeMetas holds the string denoting the metas edge name in mutations.
EdgeMetas = "metas"
// Table holds the table name of the alert in the database.
Table = "alerts"
// OwnerTable is the table the holds the owner relation/edge.
@ -124,7 +122,8 @@ var Columns = []string{
FieldSimulated,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the Alert type.
// ForeignKeys holds the SQL foreign-keys that are owned by the "alerts"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"machine_alerts",
}

View file

@ -5,9 +5,9 @@ package alert
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.

View file

@ -8,13 +8,13 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/event"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// AlertCreate is the builder for creating a Alert entity.
@ -708,6 +708,7 @@ func (ac *AlertCreate) createSpec() (*Alert, *sqlgraph.CreateSpec) {
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.machine_alerts = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := ac.mutation.DecisionsIDs(); len(nodes) > 0 {

View file

@ -6,11 +6,11 @@ import (
"context"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// AlertDelete is the builder for deleting a Alert entity.

View file

@ -9,15 +9,15 @@ import (
"fmt"
"math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/event"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// AlertQuery is the builder for querying Alert entities.
@ -70,7 +70,7 @@ func (aq *AlertQuery) QueryOwner() *MachineQuery {
if err := aq.prepareQuery(ctx); err != nil {
return nil, err
}
selector := aq.sqlQuery()
selector := aq.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
@ -92,7 +92,7 @@ func (aq *AlertQuery) QueryDecisions() *DecisionQuery {
if err := aq.prepareQuery(ctx); err != nil {
return nil, err
}
selector := aq.sqlQuery()
selector := aq.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
@ -114,7 +114,7 @@ func (aq *AlertQuery) QueryEvents() *EventQuery {
if err := aq.prepareQuery(ctx); err != nil {
return nil, err
}
selector := aq.sqlQuery()
selector := aq.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
@ -136,7 +136,7 @@ func (aq *AlertQuery) QueryMetas() *MetaQuery {
if err := aq.prepareQuery(ctx); err != nil {
return nil, err
}
selector := aq.sqlQuery()
selector := aq.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
@ -408,7 +408,7 @@ func (aq *AlertQuery) GroupBy(field string, fields ...string) *AlertGroupBy {
if err := aq.prepareQuery(ctx); err != nil {
return nil, err
}
return aq.sqlQuery(), nil
return aq.sqlQuery(ctx), nil
}
return group
}
@ -489,7 +489,8 @@ func (aq *AlertQuery) sqlAll(ctx context.Context) ([]*Alert, error) {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Alert)
for i := range nodes {
if fk := nodes[i].machine_alerts; fk != nil {
fk := nodes[i].machine_alerts
if fk != nil {
ids = append(ids, *fk)
nodeids[*fk] = append(nodeids[*fk], nodes[i])
}
@ -608,7 +609,7 @@ func (aq *AlertQuery) sqlCount(ctx context.Context) (int, error) {
func (aq *AlertQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := aq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("ent: check existence: %v", err)
return false, fmt.Errorf("ent: check existence: %w", err)
}
return n > 0, nil
}
@ -658,7 +659,7 @@ func (aq *AlertQuery) querySpec() *sqlgraph.QuerySpec {
return _spec
}
func (aq *AlertQuery) sqlQuery() *sql.Selector {
func (aq *AlertQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(aq.driver.Dialect())
t1 := builder.Table(alert.Table)
selector := builder.Select(t1.Columns(alert.Columns...)...).From(t1)
@ -953,7 +954,7 @@ func (as *AlertSelect) Scan(ctx context.Context, v interface{}) error {
if err := as.prepareQuery(ctx); err != nil {
return err
}
as.sql = as.AlertQuery.sqlQuery()
as.sql = as.AlertQuery.sqlQuery(ctx)
return as.sqlScan(ctx, v)
}

View file

@ -7,15 +7,15 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/event"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// AlertUpdate is the builder for updating Alert entities.
@ -1820,6 +1820,13 @@ func (auo *AlertUpdateOne) sqlSave(ctx context.Context) (_node *Alert, err error
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Alert.ID for update")}
}
_spec.Node.ID.Value = id
if ps := auo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := auo.mutation.CreatedAt(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,

View file

@ -7,8 +7,8 @@ import (
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/bouncer"
"github.com/facebook/ent/dialect/sql"
)
// Bouncer is the model entity for the Bouncer schema.

View file

@ -31,7 +31,6 @@ const (
FieldUntil = "until"
// FieldLastPull holds the string denoting the last_pull field in the database.
FieldLastPull = "last_pull"
// Table holds the table name of the bouncer in the database.
Table = "bouncers"
)

View file

@ -5,8 +5,8 @@ package bouncer
import (
"time"
"entgo.io/ent/dialect/sql"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
)
// ID filters vertices based on their ID field.

View file

@ -8,9 +8,9 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/bouncer"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// BouncerCreate is the builder for creating a Bouncer entity.

View file

@ -6,11 +6,11 @@ import (
"context"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/bouncer"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// BouncerDelete is the builder for deleting a Bouncer entity.

View file

@ -8,11 +8,11 @@ import (
"fmt"
"math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/bouncer"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// BouncerQuery is the builder for querying Bouncer entities.
@ -261,7 +261,7 @@ func (bq *BouncerQuery) GroupBy(field string, fields ...string) *BouncerGroupBy
if err := bq.prepareQuery(ctx); err != nil {
return nil, err
}
return bq.sqlQuery(), nil
return bq.sqlQuery(ctx), nil
}
return group
}
@ -334,7 +334,7 @@ func (bq *BouncerQuery) sqlCount(ctx context.Context) (int, error) {
func (bq *BouncerQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := bq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("ent: check existence: %v", err)
return false, fmt.Errorf("ent: check existence: %w", err)
}
return n > 0, nil
}
@ -384,7 +384,7 @@ func (bq *BouncerQuery) querySpec() *sqlgraph.QuerySpec {
return _spec
}
func (bq *BouncerQuery) sqlQuery() *sql.Selector {
func (bq *BouncerQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(bq.driver.Dialect())
t1 := builder.Table(bouncer.Table)
selector := builder.Select(t1.Columns(bouncer.Columns...)...).From(t1)
@ -679,7 +679,7 @@ func (bs *BouncerSelect) Scan(ctx context.Context, v interface{}) error {
if err := bs.prepareQuery(ctx); err != nil {
return err
}
bs.sql = bs.BouncerQuery.sqlQuery()
bs.sql = bs.BouncerQuery.sqlQuery(ctx)
return bs.sqlScan(ctx, v)
}

View file

@ -7,11 +7,11 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/bouncer"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// BouncerUpdate is the builder for updating Bouncer entities.
@ -565,6 +565,13 @@ func (buo *BouncerUpdateOne) sqlSave(ctx context.Context) (_node *Bouncer, err e
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Bouncer.ID for update")}
}
_spec.Node.ID.Value = id
if ps := buo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := buo.mutation.CreatedAt(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,

View file

@ -16,9 +16,9 @@ import (
"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
"github.com/facebook/ent/dialect"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
// Client is the client that holds all ent builders.
@ -83,9 +83,10 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
}
tx, err := newTx(ctx, c.driver)
if err != nil {
return nil, fmt.Errorf("ent: starting a transaction: %v", err)
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
}
cfg := config{driver: tx, log: c.log, debug: c.debug, hooks: c.hooks}
cfg := c.config
cfg.driver = tx
return &Tx{
ctx: ctx,
config: cfg,
@ -103,11 +104,14 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
if _, ok := c.driver.(*txDriver); ok {
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
}
tx, err := c.driver.(*sql.Driver).BeginTx(ctx, opts)
tx, err := c.driver.(interface {
BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
}).BeginTx(ctx, opts)
if err != nil {
return nil, fmt.Errorf("ent: starting a transaction: %v", err)
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
}
cfg := config{driver: &txDriver{tx: tx, drv: c.driver}, log: c.log, debug: c.debug, hooks: c.hooks}
cfg := c.config
cfg.driver = &txDriver{tx: tx, drv: c.driver}
return &Tx{
config: cfg,
Alert: NewAlertClient(cfg),
@ -130,7 +134,8 @@ func (c *Client) Debug() *Client {
if c.debug {
return c
}
cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true, hooks: c.hooks}
cfg := c.config
cfg.driver = dialect.Debug(c.driver, c.log)
client := &Client{config: cfg}
client.init()
return client

View file

@ -3,8 +3,8 @@
package ent
import (
"github.com/facebook/ent"
"github.com/facebook/ent/dialect"
"entgo.io/ent"
"entgo.io/ent/dialect"
)
// Option function to configure the client.

View file

@ -7,9 +7,9 @@ import (
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
"github.com/facebook/ent/dialect/sql"
)
// Decision is the model entity for the Decision schema.
@ -54,7 +54,7 @@ type Decision struct {
// DecisionEdges holds the relations/edges for other nodes in the graph.
type DecisionEdges struct {
// Owner holds the value of the owner edge.
Owner *Alert
Owner *Alert `json:"owner,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool

View file

@ -39,10 +39,8 @@ const (
FieldOrigin = "origin"
// FieldSimulated holds the string denoting the simulated field in the database.
FieldSimulated = "simulated"
// EdgeOwner holds the string denoting the owner edge name in mutations.
EdgeOwner = "owner"
// Table holds the table name of the decision in the database.
Table = "decisions"
// OwnerTable is the table the holds the owner relation/edge.
@ -73,7 +71,8 @@ var Columns = []string{
FieldSimulated,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the Decision type.
// ForeignKeys holds the SQL foreign-keys that are owned by the "decisions"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"alert_decisions",
}

View file

@ -5,9 +5,9 @@ package decision
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.

View file

@ -8,10 +8,10 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// DecisionCreate is the builder for creating a Decision entity.
@ -439,6 +439,7 @@ func (dc *DecisionCreate) createSpec() (*Decision, *sqlgraph.CreateSpec) {
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.alert_decisions = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec

View file

@ -6,11 +6,11 @@ import (
"context"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// DecisionDelete is the builder for deleting a Decision entity.

View file

@ -8,12 +8,12 @@ import (
"fmt"
"math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// DecisionQuery is the builder for querying Decision entities.
@ -63,7 +63,7 @@ func (dq *DecisionQuery) QueryOwner() *AlertQuery {
if err := dq.prepareQuery(ctx); err != nil {
return nil, err
}
selector := dq.sqlQuery()
selector := dq.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
@ -299,7 +299,7 @@ func (dq *DecisionQuery) GroupBy(field string, fields ...string) *DecisionGroupB
if err := dq.prepareQuery(ctx); err != nil {
return nil, err
}
return dq.sqlQuery(), nil
return dq.sqlQuery(ctx), nil
}
return group
}
@ -377,7 +377,8 @@ func (dq *DecisionQuery) sqlAll(ctx context.Context) ([]*Decision, error) {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Decision)
for i := range nodes {
if fk := nodes[i].alert_decisions; fk != nil {
fk := nodes[i].alert_decisions
if fk != nil {
ids = append(ids, *fk)
nodeids[*fk] = append(nodeids[*fk], nodes[i])
}
@ -409,7 +410,7 @@ func (dq *DecisionQuery) sqlCount(ctx context.Context) (int, error) {
func (dq *DecisionQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := dq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("ent: check existence: %v", err)
return false, fmt.Errorf("ent: check existence: %w", err)
}
return n > 0, nil
}
@ -459,7 +460,7 @@ func (dq *DecisionQuery) querySpec() *sqlgraph.QuerySpec {
return _spec
}
func (dq *DecisionQuery) sqlQuery() *sql.Selector {
func (dq *DecisionQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(dq.driver.Dialect())
t1 := builder.Table(decision.Table)
selector := builder.Select(t1.Columns(decision.Columns...)...).From(t1)
@ -754,7 +755,7 @@ func (ds *DecisionSelect) Scan(ctx context.Context, v interface{}) error {
if err := ds.prepareQuery(ctx); err != nil {
return err
}
ds.sql = ds.DecisionQuery.sqlQuery()
ds.sql = ds.DecisionQuery.sqlQuery(ctx)
return ds.sqlScan(ctx, v)
}

View file

@ -7,12 +7,12 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// DecisionUpdate is the builder for updating Decision entities.
@ -866,6 +866,13 @@ func (duo *DecisionUpdateOne) sqlSave(ctx context.Context) (_node *Decision, err
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Decision.ID for update")}
}
_spec.Node.ID.Value = id
if ps := duo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := duo.mutation.CreatedAt(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,

View file

@ -5,12 +5,11 @@ package ent
import (
"errors"
"fmt"
"strings"
"github.com/facebook/ent"
"github.com/facebook/ent/dialect"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
// ent aliases to avoid import conflicts in user's code.
@ -238,22 +237,8 @@ func IsConstraintError(err error) bool {
}
func isSQLConstraintError(err error) (*ConstraintError, bool) {
var (
msg = err.Error()
// error format per dialect.
errors = [...]string{
"Error 1062", // MySQL 1062 error (ER_DUP_ENTRY).
"UNIQUE constraint failed", // SQLite.
"duplicate key value violates unique constraint", // PostgreSQL.
}
)
if _, ok := err.(*sqlgraph.ConstraintError); ok {
return &ConstraintError{msg, err}, true
}
for i := range errors {
if strings.Contains(msg, errors[i]) {
return &ConstraintError{msg, err}, true
}
if sqlgraph.IsConstraintError(err) {
return &ConstraintError{err.Error(), err}, true
}
return nil, false
}
@ -261,7 +246,7 @@ func isSQLConstraintError(err error) (*ConstraintError, bool) {
// rollback calls tx.Rollback and wraps the given error with the rollback error if present.
func rollback(tx dialect.Tx, err error) error {
if rerr := tx.Rollback(); rerr != nil {
err = fmt.Errorf("%s: %v", err.Error(), rerr)
err = fmt.Errorf("%w: %v", err, rerr)
}
if err, ok := isSQLConstraintError(err); ok {
return err

View file

@ -9,7 +9,7 @@ import (
// required by schema hooks.
_ "github.com/crowdsecurity/crowdsec/pkg/database/ent/runtime"
"github.com/facebook/ent/dialect/sql/schema"
"entgo.io/ent/dialect/sql/schema"
)
type (

View file

@ -7,9 +7,9 @@ import (
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/event"
"github.com/facebook/ent/dialect/sql"
)
// Event is the model entity for the Event schema.
@ -34,7 +34,7 @@ type Event struct {
// EventEdges holds the relations/edges for other nodes in the graph.
type EventEdges struct {
// Owner holds the value of the owner edge.
Owner *Alert
Owner *Alert `json:"owner,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool

View file

@ -19,10 +19,8 @@ const (
FieldTime = "time"
// FieldSerialized holds the string denoting the serialized field in the database.
FieldSerialized = "serialized"
// EdgeOwner holds the string denoting the owner edge name in mutations.
EdgeOwner = "owner"
// Table holds the table name of the event in the database.
Table = "events"
// OwnerTable is the table the holds the owner relation/edge.
@ -43,7 +41,8 @@ var Columns = []string{
FieldSerialized,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the Event type.
// ForeignKeys holds the SQL foreign-keys that are owned by the "events"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"alert_events",
}

View file

@ -5,9 +5,9 @@ package event
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.

View file

@ -8,10 +8,10 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/event"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// EventCreate is the builder for creating a Event entity.
@ -237,6 +237,7 @@ func (ec *EventCreate) createSpec() (*Event, *sqlgraph.CreateSpec) {
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.alert_events = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec

View file

@ -6,11 +6,11 @@ import (
"context"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/event"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// EventDelete is the builder for deleting a Event entity.

View file

@ -8,12 +8,12 @@ import (
"fmt"
"math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/event"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// EventQuery is the builder for querying Event entities.
@ -63,7 +63,7 @@ func (eq *EventQuery) QueryOwner() *AlertQuery {
if err := eq.prepareQuery(ctx); err != nil {
return nil, err
}
selector := eq.sqlQuery()
selector := eq.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
@ -299,7 +299,7 @@ func (eq *EventQuery) GroupBy(field string, fields ...string) *EventGroupBy {
if err := eq.prepareQuery(ctx); err != nil {
return nil, err
}
return eq.sqlQuery(), nil
return eq.sqlQuery(ctx), nil
}
return group
}
@ -377,7 +377,8 @@ func (eq *EventQuery) sqlAll(ctx context.Context) ([]*Event, error) {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Event)
for i := range nodes {
if fk := nodes[i].alert_events; fk != nil {
fk := nodes[i].alert_events
if fk != nil {
ids = append(ids, *fk)
nodeids[*fk] = append(nodeids[*fk], nodes[i])
}
@ -409,7 +410,7 @@ func (eq *EventQuery) sqlCount(ctx context.Context) (int, error) {
func (eq *EventQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := eq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("ent: check existence: %v", err)
return false, fmt.Errorf("ent: check existence: %w", err)
}
return n > 0, nil
}
@ -459,7 +460,7 @@ func (eq *EventQuery) querySpec() *sqlgraph.QuerySpec {
return _spec
}
func (eq *EventQuery) sqlQuery() *sql.Selector {
func (eq *EventQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(eq.driver.Dialect())
t1 := builder.Table(event.Table)
selector := builder.Select(t1.Columns(event.Columns...)...).From(t1)
@ -754,7 +755,7 @@ func (es *EventSelect) Scan(ctx context.Context, v interface{}) error {
if err := es.prepareQuery(ctx); err != nil {
return err
}
es.sql = es.EventQuery.sqlQuery()
es.sql = es.EventQuery.sqlQuery(ctx)
return es.sqlScan(ctx, v)
}

View file

@ -7,12 +7,12 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/event"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// EventUpdate is the builder for updating Event entities.
@ -417,6 +417,13 @@ func (euo *EventUpdateOne) sqlSave(ctx context.Context) (_node *Event, err error
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Event.ID for update")}
}
_spec.Node.ID.Value = id
if ps := euo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := euo.mutation.CreatedAt(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,

View file

@ -7,8 +7,8 @@ import (
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
"github.com/facebook/ent/dialect/sql"
)
// Machine is the model entity for the Machine schema.
@ -42,7 +42,7 @@ type Machine struct {
// MachineEdges holds the relations/edges for other nodes in the graph.
type MachineEdges struct {
// Alerts holds the value of the alerts edge.
Alerts []*Alert
Alerts []*Alert `json:"alerts,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool

View file

@ -29,10 +29,8 @@ const (
FieldIsValidated = "is_validated"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// EdgeAlerts holds the string denoting the alerts edge name in mutations.
EdgeAlerts = "alerts"
// Table holds the table name of the machine in the database.
Table = "machines"
// AlertsTable is the table the holds the alerts relation/edge.

View file

@ -5,9 +5,9 @@ package machine
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.

View file

@ -8,10 +8,10 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// MachineCreate is the builder for creating a Machine entity.

View file

@ -6,11 +6,11 @@ import (
"context"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// MachineDelete is the builder for deleting a Machine entity.

View file

@ -9,12 +9,12 @@ import (
"fmt"
"math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// MachineQuery is the builder for querying Machine entities.
@ -63,7 +63,7 @@ func (mq *MachineQuery) QueryAlerts() *AlertQuery {
if err := mq.prepareQuery(ctx); err != nil {
return nil, err
}
selector := mq.sqlQuery()
selector := mq.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
@ -299,7 +299,7 @@ func (mq *MachineQuery) GroupBy(field string, fields ...string) *MachineGroupBy
if err := mq.prepareQuery(ctx); err != nil {
return nil, err
}
return mq.sqlQuery(), nil
return mq.sqlQuery(ctx), nil
}
return group
}
@ -406,7 +406,7 @@ func (mq *MachineQuery) sqlCount(ctx context.Context) (int, error) {
func (mq *MachineQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := mq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("ent: check existence: %v", err)
return false, fmt.Errorf("ent: check existence: %w", err)
}
return n > 0, nil
}
@ -456,7 +456,7 @@ func (mq *MachineQuery) querySpec() *sqlgraph.QuerySpec {
return _spec
}
func (mq *MachineQuery) sqlQuery() *sql.Selector {
func (mq *MachineQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(mq.driver.Dialect())
t1 := builder.Table(machine.Table)
selector := builder.Select(t1.Columns(machine.Columns...)...).From(t1)
@ -751,7 +751,7 @@ func (ms *MachineSelect) Scan(ctx context.Context, v interface{}) error {
if err := ms.prepareQuery(ctx); err != nil {
return err
}
ms.sql = ms.MachineQuery.sqlQuery()
ms.sql = ms.MachineQuery.sqlQuery(ctx)
return ms.sqlScan(ctx, v)
}

View file

@ -7,12 +7,12 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/machine"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// MachineUpdate is the builder for updating Machine entities.
@ -671,6 +671,13 @@ func (muo *MachineUpdateOne) sqlSave(ctx context.Context) (_node *Machine, err e
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Machine.ID for update")}
}
_spec.Node.ID.Value = id
if ps := muo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := muo.mutation.CreatedAt(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,

View file

@ -7,9 +7,9 @@ import (
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
"github.com/facebook/ent/dialect/sql"
)
// Meta is the model entity for the Meta schema.
@ -34,7 +34,7 @@ type Meta struct {
// MetaEdges holds the relations/edges for other nodes in the graph.
type MetaEdges struct {
// Owner holds the value of the owner edge.
Owner *Alert
Owner *Alert `json:"owner,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool

View file

@ -19,10 +19,8 @@ const (
FieldKey = "key"
// FieldValue holds the string denoting the value field in the database.
FieldValue = "value"
// EdgeOwner holds the string denoting the owner edge name in mutations.
EdgeOwner = "owner"
// Table holds the table name of the meta in the database.
Table = "meta"
// OwnerTable is the table the holds the owner relation/edge.
@ -43,7 +41,8 @@ var Columns = []string{
FieldValue,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the Meta type.
// ForeignKeys holds the SQL foreign-keys that are owned by the "meta"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"alert_metas",
}

View file

@ -5,9 +5,9 @@ package meta
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.

View file

@ -8,10 +8,10 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// MetaCreate is the builder for creating a Meta entity.
@ -237,6 +237,7 @@ func (mc *MetaCreate) createSpec() (*Meta, *sqlgraph.CreateSpec) {
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.alert_metas = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec

View file

@ -6,11 +6,11 @@ import (
"context"
"fmt"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// MetaDelete is the builder for deleting a Meta entity.

View file

@ -8,12 +8,12 @@ import (
"fmt"
"math"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// MetaQuery is the builder for querying Meta entities.
@ -63,7 +63,7 @@ func (mq *MetaQuery) QueryOwner() *AlertQuery {
if err := mq.prepareQuery(ctx); err != nil {
return nil, err
}
selector := mq.sqlQuery()
selector := mq.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
@ -299,7 +299,7 @@ func (mq *MetaQuery) GroupBy(field string, fields ...string) *MetaGroupBy {
if err := mq.prepareQuery(ctx); err != nil {
return nil, err
}
return mq.sqlQuery(), nil
return mq.sqlQuery(ctx), nil
}
return group
}
@ -377,7 +377,8 @@ func (mq *MetaQuery) sqlAll(ctx context.Context) ([]*Meta, error) {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Meta)
for i := range nodes {
if fk := nodes[i].alert_metas; fk != nil {
fk := nodes[i].alert_metas
if fk != nil {
ids = append(ids, *fk)
nodeids[*fk] = append(nodeids[*fk], nodes[i])
}
@ -409,7 +410,7 @@ func (mq *MetaQuery) sqlCount(ctx context.Context) (int, error) {
func (mq *MetaQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := mq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("ent: check existence: %v", err)
return false, fmt.Errorf("ent: check existence: %w", err)
}
return n > 0, nil
}
@ -459,7 +460,7 @@ func (mq *MetaQuery) querySpec() *sqlgraph.QuerySpec {
return _spec
}
func (mq *MetaQuery) sqlQuery() *sql.Selector {
func (mq *MetaQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(mq.driver.Dialect())
t1 := builder.Table(meta.Table)
selector := builder.Select(t1.Columns(meta.Columns...)...).From(t1)
@ -754,7 +755,7 @@ func (ms *MetaSelect) Scan(ctx context.Context, v interface{}) error {
if err := ms.prepareQuery(ctx); err != nil {
return err
}
ms.sql = ms.MetaQuery.sqlQuery()
ms.sql = ms.MetaQuery.sqlQuery(ctx)
return ms.sqlScan(ctx, v)
}

View file

@ -7,12 +7,12 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// MetaUpdate is the builder for updating Meta entities.
@ -417,6 +417,13 @@ func (muo *MetaUpdateOne) sqlSave(ctx context.Context) (_node *Meta, err error)
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Meta.ID for update")}
}
_spec.Node.ID.Value = id
if ps := muo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := muo.mutation.CreatedAt(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeTime,

View file

@ -7,8 +7,8 @@ import (
"fmt"
"io"
"github.com/facebook/ent/dialect"
"github.com/facebook/ent/dialect/sql/schema"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql/schema"
)
var (
@ -48,7 +48,7 @@ func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
migrate, err := schema.NewMigrate(s.drv, opts...)
if err != nil {
return fmt.Errorf("ent/migrate: %v", err)
return fmt.Errorf("ent/migrate: %w", err)
}
return migrate.Create(ctx, Tables...)
}
@ -66,7 +66,7 @@ func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.Migrat
}
migrate, err := schema.NewMigrate(drv, opts...)
if err != nil {
return fmt.Errorf("ent/migrate: %v", err)
return fmt.Errorf("ent/migrate: %w", err)
}
return migrate.Create(ctx, Tables...)
}

View file

@ -3,8 +3,8 @@
package migrate
import (
"github.com/facebook/ent/dialect/sql/schema"
"github.com/facebook/ent/schema/field"
"entgo.io/ent/dialect/sql/schema"
"entgo.io/ent/schema/field"
)
var (
@ -16,7 +16,7 @@ var (
{Name: "scenario", Type: field.TypeString},
{Name: "bucket_id", Type: field.TypeString, Nullable: true, Default: ""},
{Name: "message", Type: field.TypeString, Nullable: true, Default: ""},
{Name: "events_count", Type: field.TypeInt32, Nullable: true},
{Name: "events_count", Type: field.TypeInt32, Nullable: true, Default: 0},
{Name: "started_at", Type: field.TypeTime, Nullable: true},
{Name: "stopped_at", Type: field.TypeTime, Nullable: true},
{Name: "source_ip", Type: field.TypeString, Nullable: true},
@ -32,7 +32,7 @@ var (
{Name: "leak_speed", Type: field.TypeString, Nullable: true},
{Name: "scenario_version", Type: field.TypeString, Nullable: true},
{Name: "scenario_hash", Type: field.TypeString, Nullable: true},
{Name: "simulated", Type: field.TypeBool},
{Name: "simulated", Type: field.TypeBool, Default: false},
{Name: "machine_alerts", Type: field.TypeInt, Nullable: true},
}
// AlertsTable holds the schema information for the "alerts" table.
@ -42,9 +42,8 @@ var (
PrimaryKey: []*schema.Column{AlertsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "alerts_machines_alerts",
Columns: []*schema.Column{AlertsColumns[23]},
Symbol: "alerts_machines_alerts",
Columns: []*schema.Column{AlertsColumns[23]},
RefColumns: []*schema.Column{MachinesColumns[0]},
OnDelete: schema.SetNull,
},
@ -87,7 +86,7 @@ var (
{Name: "scope", Type: field.TypeString},
{Name: "value", Type: field.TypeString},
{Name: "origin", Type: field.TypeString},
{Name: "simulated", Type: field.TypeBool},
{Name: "simulated", Type: field.TypeBool, Default: false},
{Name: "alert_decisions", Type: field.TypeInt, Nullable: true},
}
// DecisionsTable holds the schema information for the "decisions" table.
@ -97,9 +96,8 @@ var (
PrimaryKey: []*schema.Column{DecisionsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "decisions_alerts_decisions",
Columns: []*schema.Column{DecisionsColumns[15]},
Symbol: "decisions_alerts_decisions",
Columns: []*schema.Column{DecisionsColumns[15]},
RefColumns: []*schema.Column{AlertsColumns[0]},
OnDelete: schema.SetNull,
},
@ -121,9 +119,8 @@ var (
PrimaryKey: []*schema.Column{EventsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "events_alerts_events",
Columns: []*schema.Column{EventsColumns[5]},
Symbol: "events_alerts_events",
Columns: []*schema.Column{EventsColumns[5]},
RefColumns: []*schema.Column{AlertsColumns[0]},
OnDelete: schema.SetNull,
},
@ -139,7 +136,7 @@ var (
{Name: "ip_address", Type: field.TypeString},
{Name: "scenarios", Type: field.TypeString, Nullable: true, Size: 4095},
{Name: "version", Type: field.TypeString, Nullable: true},
{Name: "is_validated", Type: field.TypeBool},
{Name: "is_validated", Type: field.TypeBool, Default: false},
{Name: "status", Type: field.TypeString, Nullable: true},
}
// MachinesTable holds the schema information for the "machines" table.
@ -165,9 +162,8 @@ var (
PrimaryKey: []*schema.Column{MetaColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "meta_alerts_metas",
Columns: []*schema.Column{MetaColumns[5]},
Symbol: "meta_alerts_metas",
Columns: []*schema.Column{MetaColumns[5]},
RefColumns: []*schema.Column{AlertsColumns[0]},
OnDelete: schema.SetNull,
},

View file

@ -16,7 +16,7 @@ import (
"github.com/crowdsecurity/crowdsec/pkg/database/ent/meta"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/predicate"
"github.com/facebook/ent"
"entgo.io/ent"
)
const (

View file

@ -3,7 +3,7 @@
package predicate
import (
"github.com/facebook/ent/dialect/sql"
"entgo.io/ent/dialect/sql"
)
// Alert is the predicate function for alert builders.

View file

@ -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.5.4" // Version of ent codegen.
Sum = "h1:kIf2BQUdRJ7XrlTXzCyJCg69ar1K1FjFR2UQWRo/M8M=" // Sum of ent codegen.
Version = "v0.7.0" // Version of ent codegen.
Sum = "h1:E3EjO0cUL61DvUg5ZEZdxa4yTL+4SuZv0LqBExo8CQA=" // Sum of ent codegen.
)

View file

@ -3,9 +3,9 @@ package schema
import (
"time"
"github.com/facebook/ent"
"github.com/facebook/ent/schema/edge"
"github.com/facebook/ent/schema/field"
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// Alert holds the schema definition for the Alert entity.

View file

@ -3,8 +3,8 @@ package schema
import (
"time"
"github.com/facebook/ent"
"github.com/facebook/ent/schema/field"
"entgo.io/ent"
"entgo.io/ent/schema/field"
)
// Bouncer holds the schema definition for the Bouncer entity.

View file

@ -3,9 +3,9 @@ package schema
import (
"time"
"github.com/facebook/ent"
"github.com/facebook/ent/schema/edge"
"github.com/facebook/ent/schema/field"
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// Decision holds the schema definition for the Decision entity.

View file

@ -3,9 +3,9 @@ package schema
import (
"time"
"github.com/facebook/ent"
"github.com/facebook/ent/schema/edge"
"github.com/facebook/ent/schema/field"
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// Event holds the schema definition for the Event entity.

View file

@ -3,9 +3,9 @@ package schema
import (
"time"
"github.com/facebook/ent"
"github.com/facebook/ent/schema/edge"
"github.com/facebook/ent/schema/field"
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// Machine holds the schema definition for the Machine entity.

View file

@ -3,9 +3,9 @@ package schema
import (
"time"
"github.com/facebook/ent"
"github.com/facebook/ent/schema/edge"
"github.com/facebook/ent/schema/field"
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// Meta holds the schema definition for the Meta entity.

View file

@ -6,7 +6,7 @@ import (
"context"
"sync"
"github.com/facebook/ent/dialect"
"entgo.io/ent/dialect"
)
// Tx is a transactional client that is created by calling Client.Tx().