mirror of
https://github.com/netbirdio/dex.git
synced 2026-05-22 18:43:53 -07:00
Add ent autogenerated code
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
This commit is contained in:
@@ -7,7 +7,7 @@ require (
|
||||
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.3
|
||||
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
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/dexidp/dex/storage/ent/db/authcode"
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// AuthCode is the model entity for the AuthCode schema.
|
||||
type AuthCode struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID string `json:"id,omitempty"`
|
||||
// ClientID holds the value of the "client_id" field.
|
||||
ClientID string `json:"client_id,omitempty"`
|
||||
// Scopes holds the value of the "scopes" field.
|
||||
Scopes []string `json:"scopes,omitempty"`
|
||||
// Nonce holds the value of the "nonce" field.
|
||||
Nonce string `json:"nonce,omitempty"`
|
||||
// RedirectURI holds the value of the "redirect_uri" field.
|
||||
RedirectURI string `json:"redirect_uri,omitempty"`
|
||||
// ClaimsUserID holds the value of the "claims_user_id" field.
|
||||
ClaimsUserID string `json:"claims_user_id,omitempty"`
|
||||
// ClaimsUsername holds the value of the "claims_username" field.
|
||||
ClaimsUsername string `json:"claims_username,omitempty"`
|
||||
// ClaimsEmail holds the value of the "claims_email" field.
|
||||
ClaimsEmail string `json:"claims_email,omitempty"`
|
||||
// ClaimsEmailVerified holds the value of the "claims_email_verified" field.
|
||||
ClaimsEmailVerified bool `json:"claims_email_verified,omitempty"`
|
||||
// ClaimsGroups holds the value of the "claims_groups" field.
|
||||
ClaimsGroups []string `json:"claims_groups,omitempty"`
|
||||
// ClaimsPreferredUsername holds the value of the "claims_preferred_username" field.
|
||||
ClaimsPreferredUsername string `json:"claims_preferred_username,omitempty"`
|
||||
// ConnectorID holds the value of the "connector_id" field.
|
||||
ConnectorID string `json:"connector_id,omitempty"`
|
||||
// ConnectorData holds the value of the "connector_data" field.
|
||||
ConnectorData *[]byte `json:"connector_data,omitempty"`
|
||||
// Expiry holds the value of the "expiry" field.
|
||||
Expiry time.Time `json:"expiry,omitempty"`
|
||||
// CodeChallenge holds the value of the "code_challenge" field.
|
||||
CodeChallenge string `json:"code_challenge,omitempty"`
|
||||
// CodeChallengeMethod holds the value of the "code_challenge_method" field.
|
||||
CodeChallengeMethod string `json:"code_challenge_method,omitempty"`
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*AuthCode) scanValues(columns []string) ([]interface{}, error) {
|
||||
values := make([]interface{}, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case authcode.FieldScopes, authcode.FieldClaimsGroups, authcode.FieldConnectorData:
|
||||
values[i] = &[]byte{}
|
||||
case authcode.FieldClaimsEmailVerified:
|
||||
values[i] = &sql.NullBool{}
|
||||
case authcode.FieldID, authcode.FieldClientID, authcode.FieldNonce, authcode.FieldRedirectURI, authcode.FieldClaimsUserID, authcode.FieldClaimsUsername, authcode.FieldClaimsEmail, authcode.FieldClaimsPreferredUsername, authcode.FieldConnectorID, authcode.FieldCodeChallenge, authcode.FieldCodeChallengeMethod:
|
||||
values[i] = &sql.NullString{}
|
||||
case authcode.FieldExpiry:
|
||||
values[i] = &sql.NullTime{}
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected column %q for type AuthCode", columns[i])
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the AuthCode fields.
|
||||
func (ac *AuthCode) assignValues(columns []string, values []interface{}) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case authcode.FieldID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value.Valid {
|
||||
ac.ID = value.String
|
||||
}
|
||||
case authcode.FieldClientID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field client_id", values[i])
|
||||
} else if value.Valid {
|
||||
ac.ClientID = value.String
|
||||
}
|
||||
case authcode.FieldScopes:
|
||||
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
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)
|
||||
}
|
||||
}
|
||||
case authcode.FieldNonce:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field nonce", values[i])
|
||||
} else if value.Valid {
|
||||
ac.Nonce = value.String
|
||||
}
|
||||
case authcode.FieldRedirectURI:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field redirect_uri", values[i])
|
||||
} else if value.Valid {
|
||||
ac.RedirectURI = value.String
|
||||
}
|
||||
case authcode.FieldClaimsUserID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field claims_user_id", values[i])
|
||||
} else if value.Valid {
|
||||
ac.ClaimsUserID = value.String
|
||||
}
|
||||
case authcode.FieldClaimsUsername:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field claims_username", values[i])
|
||||
} else if value.Valid {
|
||||
ac.ClaimsUsername = value.String
|
||||
}
|
||||
case authcode.FieldClaimsEmail:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field claims_email", values[i])
|
||||
} else if value.Valid {
|
||||
ac.ClaimsEmail = value.String
|
||||
}
|
||||
case authcode.FieldClaimsEmailVerified:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field claims_email_verified", values[i])
|
||||
} else if value.Valid {
|
||||
ac.ClaimsEmailVerified = value.Bool
|
||||
}
|
||||
case authcode.FieldClaimsGroups:
|
||||
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
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)
|
||||
}
|
||||
}
|
||||
case authcode.FieldClaimsPreferredUsername:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field claims_preferred_username", values[i])
|
||||
} else if value.Valid {
|
||||
ac.ClaimsPreferredUsername = value.String
|
||||
}
|
||||
case authcode.FieldConnectorID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field connector_id", values[i])
|
||||
} else if value.Valid {
|
||||
ac.ConnectorID = value.String
|
||||
}
|
||||
case authcode.FieldConnectorData:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field connector_data", values[i])
|
||||
} else if value != nil {
|
||||
ac.ConnectorData = value
|
||||
}
|
||||
case authcode.FieldExpiry:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field expiry", values[i])
|
||||
} else if value.Valid {
|
||||
ac.Expiry = value.Time
|
||||
}
|
||||
case authcode.FieldCodeChallenge:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field code_challenge", values[i])
|
||||
} else if value.Valid {
|
||||
ac.CodeChallenge = value.String
|
||||
}
|
||||
case authcode.FieldCodeChallengeMethod:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field code_challenge_method", values[i])
|
||||
} else if value.Valid {
|
||||
ac.CodeChallengeMethod = value.String
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this AuthCode.
|
||||
// Note that you need to call AuthCode.Unwrap() before calling this method if this AuthCode
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (ac *AuthCode) Update() *AuthCodeUpdateOne {
|
||||
return (&AuthCodeClient{config: ac.config}).UpdateOne(ac)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the AuthCode entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (ac *AuthCode) Unwrap() *AuthCode {
|
||||
tx, ok := ac.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("db: AuthCode is not a transactional entity")
|
||||
}
|
||||
ac.config.driver = tx.drv
|
||||
return ac
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (ac *AuthCode) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("AuthCode(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v", ac.ID))
|
||||
builder.WriteString(", client_id=")
|
||||
builder.WriteString(ac.ClientID)
|
||||
builder.WriteString(", scopes=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ac.Scopes))
|
||||
builder.WriteString(", nonce=")
|
||||
builder.WriteString(ac.Nonce)
|
||||
builder.WriteString(", redirect_uri=")
|
||||
builder.WriteString(ac.RedirectURI)
|
||||
builder.WriteString(", claims_user_id=")
|
||||
builder.WriteString(ac.ClaimsUserID)
|
||||
builder.WriteString(", claims_username=")
|
||||
builder.WriteString(ac.ClaimsUsername)
|
||||
builder.WriteString(", claims_email=")
|
||||
builder.WriteString(ac.ClaimsEmail)
|
||||
builder.WriteString(", claims_email_verified=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ac.ClaimsEmailVerified))
|
||||
builder.WriteString(", claims_groups=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ac.ClaimsGroups))
|
||||
builder.WriteString(", claims_preferred_username=")
|
||||
builder.WriteString(ac.ClaimsPreferredUsername)
|
||||
builder.WriteString(", connector_id=")
|
||||
builder.WriteString(ac.ConnectorID)
|
||||
if v := ac.ConnectorData; v != nil {
|
||||
builder.WriteString(", connector_data=")
|
||||
builder.WriteString(fmt.Sprintf("%v", *v))
|
||||
}
|
||||
builder.WriteString(", expiry=")
|
||||
builder.WriteString(ac.Expiry.Format(time.ANSIC))
|
||||
builder.WriteString(", code_challenge=")
|
||||
builder.WriteString(ac.CodeChallenge)
|
||||
builder.WriteString(", code_challenge_method=")
|
||||
builder.WriteString(ac.CodeChallengeMethod)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// AuthCodes is a parsable slice of AuthCode.
|
||||
type AuthCodes []*AuthCode
|
||||
|
||||
func (ac AuthCodes) config(cfg config) {
|
||||
for _i := range ac {
|
||||
ac[_i].config = cfg
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package authcode
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the authcode type in the database.
|
||||
Label = "auth_code"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldClientID holds the string denoting the client_id field in the database.
|
||||
FieldClientID = "client_id"
|
||||
// FieldScopes holds the string denoting the scopes field in the database.
|
||||
FieldScopes = "scopes"
|
||||
// FieldNonce holds the string denoting the nonce field in the database.
|
||||
FieldNonce = "nonce"
|
||||
// FieldRedirectURI holds the string denoting the redirect_uri field in the database.
|
||||
FieldRedirectURI = "redirect_uri"
|
||||
// FieldClaimsUserID holds the string denoting the claims_user_id field in the database.
|
||||
FieldClaimsUserID = "claims_user_id"
|
||||
// FieldClaimsUsername holds the string denoting the claims_username field in the database.
|
||||
FieldClaimsUsername = "claims_username"
|
||||
// FieldClaimsEmail holds the string denoting the claims_email field in the database.
|
||||
FieldClaimsEmail = "claims_email"
|
||||
// FieldClaimsEmailVerified holds the string denoting the claims_email_verified field in the database.
|
||||
FieldClaimsEmailVerified = "claims_email_verified"
|
||||
// FieldClaimsGroups holds the string denoting the claims_groups field in the database.
|
||||
FieldClaimsGroups = "claims_groups"
|
||||
// FieldClaimsPreferredUsername holds the string denoting the claims_preferred_username field in the database.
|
||||
FieldClaimsPreferredUsername = "claims_preferred_username"
|
||||
// FieldConnectorID holds the string denoting the connector_id field in the database.
|
||||
FieldConnectorID = "connector_id"
|
||||
// FieldConnectorData holds the string denoting the connector_data field in the database.
|
||||
FieldConnectorData = "connector_data"
|
||||
// FieldExpiry holds the string denoting the expiry field in the database.
|
||||
FieldExpiry = "expiry"
|
||||
// FieldCodeChallenge holds the string denoting the code_challenge field in the database.
|
||||
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"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for authcode fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldClientID,
|
||||
FieldScopes,
|
||||
FieldNonce,
|
||||
FieldRedirectURI,
|
||||
FieldClaimsUserID,
|
||||
FieldClaimsUsername,
|
||||
FieldClaimsEmail,
|
||||
FieldClaimsEmailVerified,
|
||||
FieldClaimsGroups,
|
||||
FieldClaimsPreferredUsername,
|
||||
FieldConnectorID,
|
||||
FieldConnectorData,
|
||||
FieldExpiry,
|
||||
FieldCodeChallenge,
|
||||
FieldCodeChallengeMethod,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// ClientIDValidator is a validator for the "client_id" field. It is called by the builders before save.
|
||||
ClientIDValidator func(string) error
|
||||
// NonceValidator is a validator for the "nonce" field. It is called by the builders before save.
|
||||
NonceValidator func(string) error
|
||||
// RedirectURIValidator is a validator for the "redirect_uri" field. It is called by the builders before save.
|
||||
RedirectURIValidator func(string) error
|
||||
// ClaimsUserIDValidator is a validator for the "claims_user_id" field. It is called by the builders before save.
|
||||
ClaimsUserIDValidator func(string) error
|
||||
// ClaimsUsernameValidator is a validator for the "claims_username" field. It is called by the builders before save.
|
||||
ClaimsUsernameValidator func(string) error
|
||||
// ClaimsEmailValidator is a validator for the "claims_email" field. It is called by the builders before save.
|
||||
ClaimsEmailValidator func(string) error
|
||||
// DefaultClaimsPreferredUsername holds the default value on creation for the "claims_preferred_username" field.
|
||||
DefaultClaimsPreferredUsername string
|
||||
// ConnectorIDValidator is a validator for the "connector_id" field. It is called by the builders before save.
|
||||
ConnectorIDValidator func(string) error
|
||||
// DefaultCodeChallenge holds the default value on creation for the "code_challenge" field.
|
||||
DefaultCodeChallenge string
|
||||
// DefaultCodeChallengeMethod holds the default value on creation for the "code_challenge_method" field.
|
||||
DefaultCodeChallengeMethod string
|
||||
// IDValidator is a validator for the "id" field. It is called by the builders before save.
|
||||
IDValidator func(string) error
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,108 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"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.
|
||||
type AuthCodeDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *AuthCodeMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the AuthCodeDelete builder.
|
||||
func (acd *AuthCodeDelete) Where(ps ...predicate.AuthCode) *AuthCodeDelete {
|
||||
acd.mutation.predicates = append(acd.mutation.predicates, ps...)
|
||||
return acd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (acd *AuthCodeDelete) Exec(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(acd.hooks) == 0 {
|
||||
affected, err = acd.sqlExec(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*AuthCodeMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
acd.mutation = mutation
|
||||
affected, err = acd.sqlExec(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(acd.hooks) - 1; i >= 0; i-- {
|
||||
mut = acd.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, acd.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (acd *AuthCodeDelete) ExecX(ctx context.Context) int {
|
||||
n, err := acd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (acd *AuthCodeDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := &sqlgraph.DeleteSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: authcode.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: authcode.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := acd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sqlgraph.DeleteNodes(ctx, acd.driver, _spec)
|
||||
}
|
||||
|
||||
// AuthCodeDeleteOne is the builder for deleting a single AuthCode entity.
|
||||
type AuthCodeDeleteOne struct {
|
||||
acd *AuthCodeDelete
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (acdo *AuthCodeDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := acdo.acd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{authcode.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (acdo *AuthCodeDeleteOne) ExecX(ctx context.Context) {
|
||||
acdo.acd.ExecX(ctx)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,296 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/dexidp/dex/storage/ent/db/authrequest"
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// AuthRequest is the model entity for the AuthRequest schema.
|
||||
type AuthRequest struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID string `json:"id,omitempty"`
|
||||
// ClientID holds the value of the "client_id" field.
|
||||
ClientID string `json:"client_id,omitempty"`
|
||||
// Scopes holds the value of the "scopes" field.
|
||||
Scopes []string `json:"scopes,omitempty"`
|
||||
// ResponseTypes holds the value of the "response_types" field.
|
||||
ResponseTypes []string `json:"response_types,omitempty"`
|
||||
// RedirectURI holds the value of the "redirect_uri" field.
|
||||
RedirectURI string `json:"redirect_uri,omitempty"`
|
||||
// Nonce holds the value of the "nonce" field.
|
||||
Nonce string `json:"nonce,omitempty"`
|
||||
// State holds the value of the "state" field.
|
||||
State string `json:"state,omitempty"`
|
||||
// ForceApprovalPrompt holds the value of the "force_approval_prompt" field.
|
||||
ForceApprovalPrompt bool `json:"force_approval_prompt,omitempty"`
|
||||
// LoggedIn holds the value of the "logged_in" field.
|
||||
LoggedIn bool `json:"logged_in,omitempty"`
|
||||
// ClaimsUserID holds the value of the "claims_user_id" field.
|
||||
ClaimsUserID string `json:"claims_user_id,omitempty"`
|
||||
// ClaimsUsername holds the value of the "claims_username" field.
|
||||
ClaimsUsername string `json:"claims_username,omitempty"`
|
||||
// ClaimsEmail holds the value of the "claims_email" field.
|
||||
ClaimsEmail string `json:"claims_email,omitempty"`
|
||||
// ClaimsEmailVerified holds the value of the "claims_email_verified" field.
|
||||
ClaimsEmailVerified bool `json:"claims_email_verified,omitempty"`
|
||||
// ClaimsGroups holds the value of the "claims_groups" field.
|
||||
ClaimsGroups []string `json:"claims_groups,omitempty"`
|
||||
// ClaimsPreferredUsername holds the value of the "claims_preferred_username" field.
|
||||
ClaimsPreferredUsername string `json:"claims_preferred_username,omitempty"`
|
||||
// ConnectorID holds the value of the "connector_id" field.
|
||||
ConnectorID string `json:"connector_id,omitempty"`
|
||||
// ConnectorData holds the value of the "connector_data" field.
|
||||
ConnectorData *[]byte `json:"connector_data,omitempty"`
|
||||
// Expiry holds the value of the "expiry" field.
|
||||
Expiry time.Time `json:"expiry,omitempty"`
|
||||
// CodeChallenge holds the value of the "code_challenge" field.
|
||||
CodeChallenge string `json:"code_challenge,omitempty"`
|
||||
// CodeChallengeMethod holds the value of the "code_challenge_method" field.
|
||||
CodeChallengeMethod string `json:"code_challenge_method,omitempty"`
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*AuthRequest) scanValues(columns []string) ([]interface{}, error) {
|
||||
values := make([]interface{}, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case authrequest.FieldScopes, authrequest.FieldResponseTypes, authrequest.FieldClaimsGroups, authrequest.FieldConnectorData:
|
||||
values[i] = &[]byte{}
|
||||
case authrequest.FieldForceApprovalPrompt, authrequest.FieldLoggedIn, authrequest.FieldClaimsEmailVerified:
|
||||
values[i] = &sql.NullBool{}
|
||||
case authrequest.FieldID, authrequest.FieldClientID, authrequest.FieldRedirectURI, authrequest.FieldNonce, authrequest.FieldState, authrequest.FieldClaimsUserID, authrequest.FieldClaimsUsername, authrequest.FieldClaimsEmail, authrequest.FieldClaimsPreferredUsername, authrequest.FieldConnectorID, authrequest.FieldCodeChallenge, authrequest.FieldCodeChallengeMethod:
|
||||
values[i] = &sql.NullString{}
|
||||
case authrequest.FieldExpiry:
|
||||
values[i] = &sql.NullTime{}
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected column %q for type AuthRequest", columns[i])
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the AuthRequest fields.
|
||||
func (ar *AuthRequest) assignValues(columns []string, values []interface{}) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case authrequest.FieldID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value.Valid {
|
||||
ar.ID = value.String
|
||||
}
|
||||
case authrequest.FieldClientID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field client_id", values[i])
|
||||
} else if value.Valid {
|
||||
ar.ClientID = value.String
|
||||
}
|
||||
case authrequest.FieldScopes:
|
||||
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
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)
|
||||
}
|
||||
}
|
||||
case authrequest.FieldResponseTypes:
|
||||
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
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)
|
||||
}
|
||||
}
|
||||
case authrequest.FieldRedirectURI:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field redirect_uri", values[i])
|
||||
} else if value.Valid {
|
||||
ar.RedirectURI = value.String
|
||||
}
|
||||
case authrequest.FieldNonce:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field nonce", values[i])
|
||||
} else if value.Valid {
|
||||
ar.Nonce = value.String
|
||||
}
|
||||
case authrequest.FieldState:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field state", values[i])
|
||||
} else if value.Valid {
|
||||
ar.State = value.String
|
||||
}
|
||||
case authrequest.FieldForceApprovalPrompt:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field force_approval_prompt", values[i])
|
||||
} else if value.Valid {
|
||||
ar.ForceApprovalPrompt = value.Bool
|
||||
}
|
||||
case authrequest.FieldLoggedIn:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field logged_in", values[i])
|
||||
} else if value.Valid {
|
||||
ar.LoggedIn = value.Bool
|
||||
}
|
||||
case authrequest.FieldClaimsUserID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field claims_user_id", values[i])
|
||||
} else if value.Valid {
|
||||
ar.ClaimsUserID = value.String
|
||||
}
|
||||
case authrequest.FieldClaimsUsername:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field claims_username", values[i])
|
||||
} else if value.Valid {
|
||||
ar.ClaimsUsername = value.String
|
||||
}
|
||||
case authrequest.FieldClaimsEmail:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field claims_email", values[i])
|
||||
} else if value.Valid {
|
||||
ar.ClaimsEmail = value.String
|
||||
}
|
||||
case authrequest.FieldClaimsEmailVerified:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field claims_email_verified", values[i])
|
||||
} else if value.Valid {
|
||||
ar.ClaimsEmailVerified = value.Bool
|
||||
}
|
||||
case authrequest.FieldClaimsGroups:
|
||||
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
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)
|
||||
}
|
||||
}
|
||||
case authrequest.FieldClaimsPreferredUsername:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field claims_preferred_username", values[i])
|
||||
} else if value.Valid {
|
||||
ar.ClaimsPreferredUsername = value.String
|
||||
}
|
||||
case authrequest.FieldConnectorID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field connector_id", values[i])
|
||||
} else if value.Valid {
|
||||
ar.ConnectorID = value.String
|
||||
}
|
||||
case authrequest.FieldConnectorData:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field connector_data", values[i])
|
||||
} else if value != nil {
|
||||
ar.ConnectorData = value
|
||||
}
|
||||
case authrequest.FieldExpiry:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field expiry", values[i])
|
||||
} else if value.Valid {
|
||||
ar.Expiry = value.Time
|
||||
}
|
||||
case authrequest.FieldCodeChallenge:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field code_challenge", values[i])
|
||||
} else if value.Valid {
|
||||
ar.CodeChallenge = value.String
|
||||
}
|
||||
case authrequest.FieldCodeChallengeMethod:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field code_challenge_method", values[i])
|
||||
} else if value.Valid {
|
||||
ar.CodeChallengeMethod = value.String
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this AuthRequest.
|
||||
// Note that you need to call AuthRequest.Unwrap() before calling this method if this AuthRequest
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (ar *AuthRequest) Update() *AuthRequestUpdateOne {
|
||||
return (&AuthRequestClient{config: ar.config}).UpdateOne(ar)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the AuthRequest entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (ar *AuthRequest) Unwrap() *AuthRequest {
|
||||
tx, ok := ar.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("db: AuthRequest is not a transactional entity")
|
||||
}
|
||||
ar.config.driver = tx.drv
|
||||
return ar
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (ar *AuthRequest) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("AuthRequest(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v", ar.ID))
|
||||
builder.WriteString(", client_id=")
|
||||
builder.WriteString(ar.ClientID)
|
||||
builder.WriteString(", scopes=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ar.Scopes))
|
||||
builder.WriteString(", response_types=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ar.ResponseTypes))
|
||||
builder.WriteString(", redirect_uri=")
|
||||
builder.WriteString(ar.RedirectURI)
|
||||
builder.WriteString(", nonce=")
|
||||
builder.WriteString(ar.Nonce)
|
||||
builder.WriteString(", state=")
|
||||
builder.WriteString(ar.State)
|
||||
builder.WriteString(", force_approval_prompt=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ar.ForceApprovalPrompt))
|
||||
builder.WriteString(", logged_in=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ar.LoggedIn))
|
||||
builder.WriteString(", claims_user_id=")
|
||||
builder.WriteString(ar.ClaimsUserID)
|
||||
builder.WriteString(", claims_username=")
|
||||
builder.WriteString(ar.ClaimsUsername)
|
||||
builder.WriteString(", claims_email=")
|
||||
builder.WriteString(ar.ClaimsEmail)
|
||||
builder.WriteString(", claims_email_verified=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ar.ClaimsEmailVerified))
|
||||
builder.WriteString(", claims_groups=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ar.ClaimsGroups))
|
||||
builder.WriteString(", claims_preferred_username=")
|
||||
builder.WriteString(ar.ClaimsPreferredUsername)
|
||||
builder.WriteString(", connector_id=")
|
||||
builder.WriteString(ar.ConnectorID)
|
||||
if v := ar.ConnectorData; v != nil {
|
||||
builder.WriteString(", connector_data=")
|
||||
builder.WriteString(fmt.Sprintf("%v", *v))
|
||||
}
|
||||
builder.WriteString(", expiry=")
|
||||
builder.WriteString(ar.Expiry.Format(time.ANSIC))
|
||||
builder.WriteString(", code_challenge=")
|
||||
builder.WriteString(ar.CodeChallenge)
|
||||
builder.WriteString(", code_challenge_method=")
|
||||
builder.WriteString(ar.CodeChallengeMethod)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// AuthRequests is a parsable slice of AuthRequest.
|
||||
type AuthRequests []*AuthRequest
|
||||
|
||||
func (ar AuthRequests) config(cfg config) {
|
||||
for _i := range ar {
|
||||
ar[_i].config = cfg
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package authrequest
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the authrequest type in the database.
|
||||
Label = "auth_request"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldClientID holds the string denoting the client_id field in the database.
|
||||
FieldClientID = "client_id"
|
||||
// FieldScopes holds the string denoting the scopes field in the database.
|
||||
FieldScopes = "scopes"
|
||||
// FieldResponseTypes holds the string denoting the response_types field in the database.
|
||||
FieldResponseTypes = "response_types"
|
||||
// FieldRedirectURI holds the string denoting the redirect_uri field in the database.
|
||||
FieldRedirectURI = "redirect_uri"
|
||||
// FieldNonce holds the string denoting the nonce field in the database.
|
||||
FieldNonce = "nonce"
|
||||
// FieldState holds the string denoting the state field in the database.
|
||||
FieldState = "state"
|
||||
// FieldForceApprovalPrompt holds the string denoting the force_approval_prompt field in the database.
|
||||
FieldForceApprovalPrompt = "force_approval_prompt"
|
||||
// FieldLoggedIn holds the string denoting the logged_in field in the database.
|
||||
FieldLoggedIn = "logged_in"
|
||||
// FieldClaimsUserID holds the string denoting the claims_user_id field in the database.
|
||||
FieldClaimsUserID = "claims_user_id"
|
||||
// FieldClaimsUsername holds the string denoting the claims_username field in the database.
|
||||
FieldClaimsUsername = "claims_username"
|
||||
// FieldClaimsEmail holds the string denoting the claims_email field in the database.
|
||||
FieldClaimsEmail = "claims_email"
|
||||
// FieldClaimsEmailVerified holds the string denoting the claims_email_verified field in the database.
|
||||
FieldClaimsEmailVerified = "claims_email_verified"
|
||||
// FieldClaimsGroups holds the string denoting the claims_groups field in the database.
|
||||
FieldClaimsGroups = "claims_groups"
|
||||
// FieldClaimsPreferredUsername holds the string denoting the claims_preferred_username field in the database.
|
||||
FieldClaimsPreferredUsername = "claims_preferred_username"
|
||||
// FieldConnectorID holds the string denoting the connector_id field in the database.
|
||||
FieldConnectorID = "connector_id"
|
||||
// FieldConnectorData holds the string denoting the connector_data field in the database.
|
||||
FieldConnectorData = "connector_data"
|
||||
// FieldExpiry holds the string denoting the expiry field in the database.
|
||||
FieldExpiry = "expiry"
|
||||
// FieldCodeChallenge holds the string denoting the code_challenge field in the database.
|
||||
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"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for authrequest fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldClientID,
|
||||
FieldScopes,
|
||||
FieldResponseTypes,
|
||||
FieldRedirectURI,
|
||||
FieldNonce,
|
||||
FieldState,
|
||||
FieldForceApprovalPrompt,
|
||||
FieldLoggedIn,
|
||||
FieldClaimsUserID,
|
||||
FieldClaimsUsername,
|
||||
FieldClaimsEmail,
|
||||
FieldClaimsEmailVerified,
|
||||
FieldClaimsGroups,
|
||||
FieldClaimsPreferredUsername,
|
||||
FieldConnectorID,
|
||||
FieldConnectorData,
|
||||
FieldExpiry,
|
||||
FieldCodeChallenge,
|
||||
FieldCodeChallengeMethod,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultClaimsPreferredUsername holds the default value on creation for the "claims_preferred_username" field.
|
||||
DefaultClaimsPreferredUsername string
|
||||
// DefaultCodeChallenge holds the default value on creation for the "code_challenge" field.
|
||||
DefaultCodeChallenge string
|
||||
// DefaultCodeChallengeMethod holds the default value on creation for the "code_challenge_method" field.
|
||||
DefaultCodeChallengeMethod string
|
||||
// IDValidator is a validator for the "id" field. It is called by the builders before save.
|
||||
IDValidator func(string) error
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,108 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"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.
|
||||
type AuthRequestDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *AuthRequestMutation
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the AuthRequestDelete builder.
|
||||
func (ard *AuthRequestDelete) Where(ps ...predicate.AuthRequest) *AuthRequestDelete {
|
||||
ard.mutation.predicates = append(ard.mutation.predicates, ps...)
|
||||
return ard
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (ard *AuthRequestDelete) Exec(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(ard.hooks) == 0 {
|
||||
affected, err = ard.sqlExec(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*AuthRequestMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
ard.mutation = mutation
|
||||
affected, err = ard.sqlExec(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(ard.hooks) - 1; i >= 0; i-- {
|
||||
mut = ard.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, ard.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ard *AuthRequestDelete) ExecX(ctx context.Context) int {
|
||||
n, err := ard.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (ard *AuthRequestDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := &sqlgraph.DeleteSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: authrequest.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: authrequest.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := ard.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sqlgraph.DeleteNodes(ctx, ard.driver, _spec)
|
||||
}
|
||||
|
||||
// AuthRequestDeleteOne is the builder for deleting a single AuthRequest entity.
|
||||
type AuthRequestDeleteOne struct {
|
||||
ard *AuthRequestDelete
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (ardo *AuthRequestDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := ardo.ard.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{authrequest.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ardo *AuthRequestDeleteOne) ExecX(ctx context.Context) {
|
||||
ardo.ard.ExecX(ctx)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,68 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/dialect"
|
||||
)
|
||||
|
||||
// Option function to configure the client.
|
||||
type Option func(*config)
|
||||
|
||||
// Config is the configuration for the client and its builder.
|
||||
type config struct {
|
||||
// driver used for executing database requests.
|
||||
driver dialect.Driver
|
||||
// debug enable a debug logging.
|
||||
debug bool
|
||||
// log used for logging on debug mode.
|
||||
log func(...interface{})
|
||||
// hooks to execute on mutations.
|
||||
hooks *hooks
|
||||
}
|
||||
|
||||
// hooks per client, for fast access.
|
||||
type hooks struct {
|
||||
AuthCode []ent.Hook
|
||||
AuthRequest []ent.Hook
|
||||
Connector []ent.Hook
|
||||
DeviceRequest []ent.Hook
|
||||
DeviceToken []ent.Hook
|
||||
Keys []ent.Hook
|
||||
OAuth2Client []ent.Hook
|
||||
OfflineSession []ent.Hook
|
||||
Password []ent.Hook
|
||||
RefreshToken []ent.Hook
|
||||
}
|
||||
|
||||
// Options applies the options on the config object.
|
||||
func (c *config) options(opts ...Option) {
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
if c.debug {
|
||||
c.driver = dialect.Debug(c.driver, c.log)
|
||||
}
|
||||
}
|
||||
|
||||
// Debug enables debug logging on the ent.Driver.
|
||||
func Debug() Option {
|
||||
return func(c *config) {
|
||||
c.debug = true
|
||||
}
|
||||
}
|
||||
|
||||
// Log sets the logging function for debug mode.
|
||||
func Log(fn func(...interface{})) Option {
|
||||
return func(c *config) {
|
||||
c.log = fn
|
||||
}
|
||||
}
|
||||
|
||||
// Driver configures the client driver.
|
||||
func Driver(driver dialect.Driver) Option {
|
||||
return func(c *config) {
|
||||
c.driver = driver
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/dexidp/dex/storage/ent/db/connector"
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Connector is the model entity for the Connector schema.
|
||||
type Connector struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID string `json:"id,omitempty"`
|
||||
// Type holds the value of the "type" field.
|
||||
Type string `json:"type,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// ResourceVersion holds the value of the "resource_version" field.
|
||||
ResourceVersion string `json:"resource_version,omitempty"`
|
||||
// Config holds the value of the "config" field.
|
||||
Config []byte `json:"config,omitempty"`
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Connector) scanValues(columns []string) ([]interface{}, error) {
|
||||
values := make([]interface{}, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case connector.FieldConfig:
|
||||
values[i] = &[]byte{}
|
||||
case connector.FieldID, connector.FieldType, connector.FieldName, connector.FieldResourceVersion:
|
||||
values[i] = &sql.NullString{}
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected column %q for type Connector", columns[i])
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Connector fields.
|
||||
func (c *Connector) assignValues(columns []string, values []interface{}) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case connector.FieldID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value.Valid {
|
||||
c.ID = value.String
|
||||
}
|
||||
case connector.FieldType:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field type", values[i])
|
||||
} else if value.Valid {
|
||||
c.Type = value.String
|
||||
}
|
||||
case connector.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
c.Name = value.String
|
||||
}
|
||||
case connector.FieldResourceVersion:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field resource_version", values[i])
|
||||
} else if value.Valid {
|
||||
c.ResourceVersion = value.String
|
||||
}
|
||||
case connector.FieldConfig:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field config", values[i])
|
||||
} else if value != nil {
|
||||
c.Config = *value
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Connector.
|
||||
// Note that you need to call Connector.Unwrap() before calling this method if this Connector
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (c *Connector) Update() *ConnectorUpdateOne {
|
||||
return (&ConnectorClient{config: c.config}).UpdateOne(c)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Connector entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (c *Connector) Unwrap() *Connector {
|
||||
tx, ok := c.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("db: Connector is not a transactional entity")
|
||||
}
|
||||
c.config.driver = tx.drv
|
||||
return c
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (c *Connector) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Connector(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v", c.ID))
|
||||
builder.WriteString(", type=")
|
||||
builder.WriteString(c.Type)
|
||||
builder.WriteString(", name=")
|
||||
builder.WriteString(c.Name)
|
||||
builder.WriteString(", resource_version=")
|
||||
builder.WriteString(c.ResourceVersion)
|
||||
builder.WriteString(", config=")
|
||||
builder.WriteString(fmt.Sprintf("%v", c.Config))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Connectors is a parsable slice of Connector.
|
||||
type Connectors []*Connector
|
||||
|
||||
func (c Connectors) config(cfg config) {
|
||||
for _i := range c {
|
||||
c[_i].config = cfg
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package connector
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the connector type in the database.
|
||||
Label = "connector"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldType holds the string denoting the type field in the database.
|
||||
FieldType = "type"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldResourceVersion holds the string denoting the resource_version field in the database.
|
||||
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"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for connector fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldType,
|
||||
FieldName,
|
||||
FieldResourceVersion,
|
||||
FieldConfig,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// TypeValidator is a validator for the "type" field. It is called by the builders before save.
|
||||
TypeValidator func(string) error
|
||||
// NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||
NameValidator func(string) error
|
||||
// IDValidator is a validator for the "id" field. It is called by the builders before save.
|
||||
IDValidator func(string) error
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user