2023-04-24 20:52:12 +02:00
|
|
|
package admin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"forge.cadoles.com/cadoles/bouncer/internal/config"
|
2024-03-27 17:47:39 +01:00
|
|
|
"forge.cadoles.com/cadoles/bouncer/internal/integration"
|
2023-04-24 20:52:12 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Option struct {
|
2024-03-26 17:28:38 +01:00
|
|
|
BootstrapConfig config.BootstrapConfig
|
|
|
|
ServerConfig config.AdminServerConfig
|
|
|
|
RedisConfig config.RedisConfig
|
2024-03-27 17:47:39 +01:00
|
|
|
Integrations []integration.Integration
|
2023-04-24 20:52:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type OptionFunc func(*Option)
|
|
|
|
|
|
|
|
func defaultOption() *Option {
|
|
|
|
return &Option{
|
|
|
|
ServerConfig: config.NewDefaultAdminServerConfig(),
|
|
|
|
RedisConfig: config.NewDefaultRedisConfig(),
|
2024-03-27 17:47:39 +01:00
|
|
|
Integrations: make([]integration.Integration, 0),
|
2023-04-24 20:52:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithServerConfig(conf config.AdminServerConfig) OptionFunc {
|
|
|
|
return func(opt *Option) {
|
|
|
|
opt.ServerConfig = conf
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithRedisConfig(conf config.RedisConfig) OptionFunc {
|
|
|
|
return func(opt *Option) {
|
|
|
|
opt.RedisConfig = conf
|
|
|
|
}
|
|
|
|
}
|
2024-03-26 17:28:38 +01:00
|
|
|
|
|
|
|
func WithBootstrapConfig(conf config.BootstrapConfig) OptionFunc {
|
|
|
|
return func(opt *Option) {
|
|
|
|
opt.BootstrapConfig = conf
|
|
|
|
}
|
|
|
|
}
|
2024-03-27 17:47:39 +01:00
|
|
|
|
|
|
|
func WithIntegrations(integrations ...integration.Integration) OptionFunc {
|
|
|
|
return func(opt *Option) {
|
|
|
|
opt.Integrations = integrations
|
|
|
|
}
|
|
|
|
}
|