65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package admin
|
|
|
|
import (
|
|
"forge.cadoles.com/cadoles/bouncer/internal/config"
|
|
"forge.cadoles.com/cadoles/bouncer/internal/integration"
|
|
"forge.cadoles.com/cadoles/bouncer/internal/lock"
|
|
"forge.cadoles.com/cadoles/bouncer/internal/store"
|
|
)
|
|
|
|
type Option struct {
|
|
BootstrapConfig config.BootstrapConfig
|
|
ServerConfig config.AdminServerConfig
|
|
Integrations []integration.Integration
|
|
|
|
ProxyRepository store.ProxyRepository
|
|
LayerRepository store.LayerRepository
|
|
|
|
Locker lock.Locker
|
|
}
|
|
|
|
type OptionFunc func(*Option)
|
|
|
|
func defaultOption() *Option {
|
|
return &Option{
|
|
ServerConfig: config.NewDefaultAdminServerConfig(),
|
|
Integrations: make([]integration.Integration, 0),
|
|
}
|
|
}
|
|
|
|
func WithServerConfig(conf config.AdminServerConfig) OptionFunc {
|
|
return func(opt *Option) {
|
|
opt.ServerConfig = conf
|
|
}
|
|
}
|
|
|
|
func WithBootstrapConfig(conf config.BootstrapConfig) OptionFunc {
|
|
return func(opt *Option) {
|
|
opt.BootstrapConfig = conf
|
|
}
|
|
}
|
|
|
|
func WithIntegrations(integrations ...integration.Integration) OptionFunc {
|
|
return func(opt *Option) {
|
|
opt.Integrations = integrations
|
|
}
|
|
}
|
|
|
|
func WithLayerRepository(layerRepository store.LayerRepository) OptionFunc {
|
|
return func(opt *Option) {
|
|
opt.LayerRepository = layerRepository
|
|
}
|
|
}
|
|
|
|
func WithProxyRepository(proxyRepository store.ProxyRepository) OptionFunc {
|
|
return func(opt *Option) {
|
|
opt.ProxyRepository = proxyRepository
|
|
}
|
|
}
|
|
|
|
func WithLocker(locker lock.Locker) OptionFunc {
|
|
return func(opt *Option) {
|
|
opt.Locker = locker
|
|
}
|
|
}
|