chore: update ent

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
This commit is contained in:
m.nabokikh
2021-04-30 17:48:16 +04:00
parent 2e61860d5a
commit 24fa4def5b
94 changed files with 311 additions and 261 deletions
+1 -1
View File
@@ -3,11 +3,11 @@ module github.com/dexidp/dex
go 1.16
require (
entgo.io/ent v0.7.0
github.com/AppsFlyer/go-sundheit v0.3.1
github.com/beevik/etree v1.1.0
github.com/coreos/go-oidc/v3 v3.0.0
github.com/dexidp/dex/api/v2 v2.0.0
github.com/facebook/ent v0.5.4
github.com/felixge/httpsnoop v1.0.1
github.com/ghodss/yaml v1.0.0
github.com/go-ldap/ldap/v3 v3.3.0
+3 -3
View File
@@ -8,8 +8,8 @@ import (
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/authcode"
"github.com/facebook/ent/dialect/sql"
)
// AuthCode is the model entity for the AuthCode schema.
@@ -95,7 +95,7 @@ func (ac *AuthCode) assignValues(columns []string, values []interface{}) error {
return fmt.Errorf("unexpected type %T for field scopes", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &ac.Scopes); err != nil {
return fmt.Errorf("unmarshal field scopes: %v", err)
return fmt.Errorf("unmarshal field scopes: %w", err)
}
}
case authcode.FieldNonce:
@@ -140,7 +140,7 @@ func (ac *AuthCode) assignValues(columns []string, values []interface{}) error {
return fmt.Errorf("unexpected type %T for field claims_groups", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &ac.ClaimsGroups); err != nil {
return fmt.Errorf("unmarshal field claims_groups: %v", err)
return fmt.Errorf("unmarshal field claims_groups: %w", err)
}
}
case authcode.FieldClaimsPreferredUsername:
-1
View File
@@ -37,7 +37,6 @@ const (
FieldCodeChallenge = "code_challenge"
// FieldCodeChallengeMethod holds the string denoting the code_challenge_method field in the database.
FieldCodeChallengeMethod = "code_challenge_method"
// Table holds the table name of the authcode in the database.
Table = "auth_codes"
)
+1 -1
View File
@@ -5,8 +5,8 @@ package authcode
import (
"time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
+2 -2
View File
@@ -8,9 +8,9 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/authcode"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// AuthCodeCreate is the builder for creating a AuthCode entity.
+3 -3
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/dexidp/dex/storage/ent/db/authcode"
"github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// AuthCodeDelete is the builder for deleting a AuthCode entity.
+7 -7
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/dexidp/dex/storage/ent/db/authcode"
"github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// AuthCodeQuery is the builder for querying AuthCode entities.
@@ -261,7 +261,7 @@ func (acq *AuthCodeQuery) GroupBy(field string, fields ...string) *AuthCodeGroup
if err := acq.prepareQuery(ctx); err != nil {
return nil, err
}
return acq.sqlQuery(), nil
return acq.sqlQuery(ctx), nil
}
return group
}
@@ -334,7 +334,7 @@ func (acq *AuthCodeQuery) sqlCount(ctx context.Context) (int, error) {
func (acq *AuthCodeQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := acq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("db: check existence: %v", err)
return false, fmt.Errorf("db: check existence: %w", err)
}
return n > 0, nil
}
@@ -384,7 +384,7 @@ func (acq *AuthCodeQuery) querySpec() *sqlgraph.QuerySpec {
return _spec
}
func (acq *AuthCodeQuery) sqlQuery() *sql.Selector {
func (acq *AuthCodeQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(acq.driver.Dialect())
t1 := builder.Table(authcode.Table)
selector := builder.Select(t1.Columns(authcode.Columns...)...).From(t1)
@@ -679,7 +679,7 @@ func (acs *AuthCodeSelect) Scan(ctx context.Context, v interface{}) error {
if err := acs.prepareQuery(ctx); err != nil {
return err
}
acs.sql = acs.AuthCodeQuery.sqlQuery()
acs.sql = acs.AuthCodeQuery.sqlQuery(ctx)
return acs.sqlScan(ctx, v)
}
+10 -3
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/dexidp/dex/storage/ent/db/authcode"
"github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// AuthCodeUpdate is the builder for updating AuthCode entities.
@@ -670,6 +670,13 @@ func (acuo *AuthCodeUpdateOne) sqlSave(ctx context.Context) (_node *AuthCode, er
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing AuthCode.ID for update")}
}
_spec.Node.ID.Value = id
if ps := acuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := acuo.mutation.ClientID(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
+4 -4
View File
@@ -8,8 +8,8 @@ import (
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/authrequest"
"github.com/facebook/ent/dialect/sql"
)
// AuthRequest is the model entity for the AuthRequest schema.
@@ -103,7 +103,7 @@ func (ar *AuthRequest) assignValues(columns []string, values []interface{}) erro
return fmt.Errorf("unexpected type %T for field scopes", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &ar.Scopes); err != nil {
return fmt.Errorf("unmarshal field scopes: %v", err)
return fmt.Errorf("unmarshal field scopes: %w", err)
}
}
case authrequest.FieldResponseTypes:
@@ -112,7 +112,7 @@ func (ar *AuthRequest) assignValues(columns []string, values []interface{}) erro
return fmt.Errorf("unexpected type %T for field response_types", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &ar.ResponseTypes); err != nil {
return fmt.Errorf("unmarshal field response_types: %v", err)
return fmt.Errorf("unmarshal field response_types: %w", err)
}
}
case authrequest.FieldRedirectURI:
@@ -175,7 +175,7 @@ func (ar *AuthRequest) assignValues(columns []string, values []interface{}) erro
return fmt.Errorf("unexpected type %T for field claims_groups", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &ar.ClaimsGroups); err != nil {
return fmt.Errorf("unmarshal field claims_groups: %v", err)
return fmt.Errorf("unmarshal field claims_groups: %w", err)
}
}
case authrequest.FieldClaimsPreferredUsername:
@@ -45,7 +45,6 @@ const (
FieldCodeChallenge = "code_challenge"
// FieldCodeChallengeMethod holds the string denoting the code_challenge_method field in the database.
FieldCodeChallengeMethod = "code_challenge_method"
// Table holds the table name of the authrequest in the database.
Table = "auth_requests"
)
+1 -1
View File
@@ -5,8 +5,8 @@ package authrequest
import (
"time"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
+2 -2
View File
@@ -8,9 +8,9 @@ import (
"fmt"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/authrequest"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// AuthRequestCreate is the builder for creating a AuthRequest entity.
+3 -3
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/dexidp/dex/storage/ent/db/authrequest"
"github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// AuthRequestDelete is the builder for deleting a AuthRequest entity.
+7 -7
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/dexidp/dex/storage/ent/db/authrequest"
"github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// AuthRequestQuery is the builder for querying AuthRequest entities.
@@ -261,7 +261,7 @@ func (arq *AuthRequestQuery) GroupBy(field string, fields ...string) *AuthReques
if err := arq.prepareQuery(ctx); err != nil {
return nil, err
}
return arq.sqlQuery(), nil
return arq.sqlQuery(ctx), nil
}
return group
}
@@ -334,7 +334,7 @@ func (arq *AuthRequestQuery) sqlCount(ctx context.Context) (int, error) {
func (arq *AuthRequestQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := arq.sqlCount(ctx)
if err != nil {
return false, fmt.Errorf("db: check existence: %v", err)
return false, fmt.Errorf("db: check existence: %w", err)
}
return n > 0, nil
}
@@ -384,7 +384,7 @@ func (arq *AuthRequestQuery) querySpec() *sqlgraph.QuerySpec {
return _spec
}
func (arq *AuthRequestQuery) sqlQuery() *sql.Selector {
func (arq *AuthRequestQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(arq.driver.Dialect())
t1 := builder.Table(authrequest.Table)
selector := builder.Select(t1.Columns(authrequest.Columns...)...).From(t1)
@@ -679,7 +679,7 @@ func (ars *AuthRequestSelect) Scan(ctx context.Context, v interface{}) error {
if err := ars.prepareQuery(ctx); err != nil {
return err
}
ars.sql = ars.AuthRequestQuery.sqlQuery()
ars.sql = ars.AuthRequestQuery.sqlQuery(ctx)
return ars.sqlScan(ctx, v)
}
+10 -3
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/dexidp/dex/storage/ent/db/authrequest"
"github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
"github.com/facebook/ent/dialect/sql/sqlgraph"
"github.com/facebook/ent/schema/field"
)
// AuthRequestUpdate is the builder for updating AuthRequest entities.
@@ -672,6 +672,13 @@ func (aruo *AuthRequestUpdateOne) sqlSave(ctx context.Context) (_node *AuthReque
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing AuthRequest.ID for update")}
}
_spec.Node.ID.Value = id
if ps := aruo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := aruo.mutation.ClientID(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
+13 -8
View File
@@ -20,8 +20,8 @@ import (
"github.com/dexidp/dex/storage/ent/db/password"
"github.com/dexidp/dex/storage/ent/db/refreshtoken"
"github.com/facebook/ent/dialect"
"github.com/facebook/ent/dialect/sql"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
)
// Client is the client that holds all ent builders.
@@ -98,9 +98,10 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
}
tx, err := newTx(ctx, c.driver)
if err != nil {
return nil, fmt.Errorf("db: starting a transaction: %v", err)
return nil, fmt.Errorf("db: 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,
@@ -122,11 +123,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,
AuthCode: NewAuthCodeClient(cfg),
@@ -153,7 +157,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
+2 -2
View File
@@ -3,8 +3,8 @@
package db
import (
"github.com/facebook/ent"
"github.com/facebook/ent/dialect"
"entgo.io/ent"
"entgo.io/ent/dialect"
)
// Option function to configure the client.
+1 -1
View File
@@ -6,8 +6,8 @@ import (
"fmt"
"strings"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/connector"
"github.com/facebook/ent/dialect/sql"
)
// Connector is the model entity for the Connector schema.
-1
View File
@@ -15,7 +15,6 @@ const (
FieldResourceVersion = "resource_version"
// FieldConfig holds the string denoting the config field in the database.
FieldConfig = "config"
// Table holds the table name of the connector in the database.
Table = "connectors"
)
+1 -1
View File
@@ -3,8 +3,8 @@
package connector
import (
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/predicate"
"github.com/facebook/ent/dialect/sql"
)
// ID filters vertices based on their ID field.

Some files were not shown because too many files have changed in this diff Show More