Don't omit fields of bouncer in json (#1354)

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
This commit is contained in:
Shivam Sandbhor 2022-03-16 14:10:34 +05:30 committed by GitHub
parent a74a41dac5
commit bb30a3f966
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 22 deletions

3
go.mod
View file

@ -78,6 +78,7 @@ require (
github.com/docker/go-units v0.4.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-openapi/analysis v0.19.16 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/loads v0.20.0 // indirect
@ -143,6 +144,8 @@ require (
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect

4
go.sum
View file

@ -206,6 +206,7 @@ github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpX
github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/errors v0.20.1 h1:j23mMDtRxMwIobkpId7sWh7Ddcx4ivaoqUbfXx5P+a8=
github.com/go-openapi/errors v0.20.1/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
@ -311,6 +312,8 @@ github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWe
github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ=
github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0=
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@ -1034,6 +1037,7 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
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-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View file

@ -17,25 +17,25 @@ type Bouncer struct {
// ID of the ent.
ID int `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt *time.Time `json:"created_at,omitempty"`
CreatedAt *time.Time `json:"created_at"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt *time.Time `json:"updated_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
Name string `json:"name"`
// APIKey holds the value of the "api_key" field.
APIKey string `json:"api_key,omitempty"`
APIKey string `json:"api_key"`
// Revoked holds the value of the "revoked" field.
Revoked bool `json:"revoked,omitempty"`
Revoked bool `json:"revoked"`
// IPAddress holds the value of the "ip_address" field.
IPAddress string `json:"ip_address,omitempty"`
IPAddress string `json:"ip_address"`
// Type holds the value of the "type" field.
Type string `json:"type,omitempty"`
Type string `json:"type"`
// Version holds the value of the "version" field.
Version string `json:"version,omitempty"`
Version string `json:"version"`
// Until holds the value of the "until" field.
Until time.Time `json:"until,omitempty"`
Until time.Time `json:"until"`
// LastPull holds the value of the "last_pull" field.
LastPull time.Time `json:"last_pull,omitempty"`
LastPull time.Time `json:"last_pull"`
}
// scanValues returns the types for scanning values from sql.Rows.

View file

@ -253,7 +253,7 @@ func (bq *BouncerQuery) Clone() *BouncerQuery {
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// CreatedAt time.Time `json:"created_at"`
// Count int `json:"count,omitempty"`
// }
//
@ -280,7 +280,7 @@ func (bq *BouncerQuery) GroupBy(field string, fields ...string) *BouncerGroupBy
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// CreatedAt time.Time `json:"created_at"`
// }
//
// client.Bouncer.Query().

View file

@ -16,19 +16,19 @@ func (Bouncer) Fields() []ent.Field {
return []ent.Field{
field.Time("created_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow).Nillable().Optional(),
UpdateDefault(types.UtcNow).Nillable().Optional().StructTag(`json:"created_at"`),
field.Time("updated_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow).Nillable().Optional(),
field.String("name").Unique(),
field.String("api_key"), // hash of api_key
field.Bool("revoked"),
field.String("ip_address").Default("").Optional(),
field.String("type").Optional(),
field.String("version").Optional(),
field.Time("until").Default(types.UtcNow).Optional(),
UpdateDefault(types.UtcNow).Nillable().Optional().StructTag(`json:"updated_at"`),
field.String("name").Unique().StructTag(`json:"name"`),
field.String("api_key").StructTag(`json:"api_key"`), // hash of api_key
field.Bool("revoked").StructTag(`json:"revoked"`),
field.String("ip_address").Default("").Optional().StructTag(`json:"ip_address"`),
field.String("type").Optional().StructTag(`json:"type"`),
field.String("version").Optional().StructTag(`json:"version"`),
field.Time("until").Default(types.UtcNow).Optional().StructTag(`json:"until"`),
field.Time("last_pull").
Default(types.UtcNow),
Default(types.UtcNow).StructTag(`json:"last_pull"`),
}
}