mirror of https://github.com/dexidp/dex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
1.8 KiB
84 lines
1.8 KiB
// Code generated by ent, DO NOT EDIT. |
|
|
|
package db |
|
|
|
import ( |
|
"entgo.io/ent" |
|
"entgo.io/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(...any) |
|
// hooks to execute on mutations. |
|
hooks *hooks |
|
// interceptors to execute on queries. |
|
inters *inters |
|
} |
|
|
|
// hooks and interceptors 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 |
|
} |
|
inters struct { |
|
AuthCode []ent.Interceptor |
|
AuthRequest []ent.Interceptor |
|
Connector []ent.Interceptor |
|
DeviceRequest []ent.Interceptor |
|
DeviceToken []ent.Interceptor |
|
Keys []ent.Interceptor |
|
OAuth2Client []ent.Interceptor |
|
OfflineSession []ent.Interceptor |
|
Password []ent.Interceptor |
|
RefreshToken []ent.Interceptor |
|
} |
|
) |
|
|
|
// 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(...any)) 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 |
|
} |
|
}
|
|
|