mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-15 17:22:56 +02:00
databroker: remove unused serverConfig fields (#5314)
The databroker.serverConfig struct has a few fields which are written to but never read.
This commit is contained in:
parent
410354bc00
commit
6f6186a67d
2 changed files with 0 additions and 42 deletions
|
@ -57,7 +57,6 @@ func (srv *dataBrokerServer) getOptions(cfg *config.Config) ([]databroker.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
return []databroker.ServerOption{
|
return []databroker.ServerOption{
|
||||||
databroker.WithGetSharedKey(cfg.Options.GetSharedKey),
|
|
||||||
databroker.WithStorageType(cfg.Options.DataBrokerStorageType),
|
databroker.WithStorageType(cfg.Options.DataBrokerStorageType),
|
||||||
databroker.WithStorageConnectionString(dataBrokerStorageConnectionString),
|
databroker.WithStorageConnectionString(dataBrokerStorageConnectionString),
|
||||||
}, nil
|
}, nil
|
||||||
|
|
|
@ -2,37 +2,24 @@ package databroker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pomerium/pomerium/internal/log"
|
|
||||||
"github.com/pomerium/pomerium/pkg/cryptutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// DefaultDeletePermanentlyAfter is the default amount of time to wait before deleting
|
|
||||||
// a record permanently.
|
|
||||||
DefaultDeletePermanentlyAfter = time.Hour
|
|
||||||
// DefaultStorageType is the default storage type that Server use
|
// DefaultStorageType is the default storage type that Server use
|
||||||
DefaultStorageType = "memory"
|
DefaultStorageType = "memory"
|
||||||
// DefaultGetAllPageSize is the default page size for GetAll calls.
|
|
||||||
DefaultGetAllPageSize = 50
|
|
||||||
// DefaultRegistryTTL is the default registry time to live.
|
// DefaultRegistryTTL is the default registry time to live.
|
||||||
DefaultRegistryTTL = time.Minute
|
DefaultRegistryTTL = time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
type serverConfig struct {
|
type serverConfig struct {
|
||||||
deletePermanentlyAfter time.Duration
|
|
||||||
secret []byte
|
|
||||||
storageType string
|
storageType string
|
||||||
storageConnectionString string
|
storageConnectionString string
|
||||||
getAllPageSize int
|
|
||||||
registryTTL time.Duration
|
registryTTL time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func newServerConfig(options ...ServerOption) *serverConfig {
|
func newServerConfig(options ...ServerOption) *serverConfig {
|
||||||
cfg := new(serverConfig)
|
cfg := new(serverConfig)
|
||||||
WithDeletePermanentlyAfter(DefaultDeletePermanentlyAfter)(cfg)
|
|
||||||
WithStorageType(DefaultStorageType)(cfg)
|
WithStorageType(DefaultStorageType)(cfg)
|
||||||
WithGetAllPageSize(DefaultGetAllPageSize)(cfg)
|
|
||||||
WithRegistryTTL(DefaultRegistryTTL)(cfg)
|
WithRegistryTTL(DefaultRegistryTTL)(cfg)
|
||||||
for _, option := range options {
|
for _, option := range options {
|
||||||
option(cfg)
|
option(cfg)
|
||||||
|
@ -43,22 +30,6 @@ func newServerConfig(options ...ServerOption) *serverConfig {
|
||||||
// A ServerOption customizes the server.
|
// A ServerOption customizes the server.
|
||||||
type ServerOption func(*serverConfig)
|
type ServerOption func(*serverConfig)
|
||||||
|
|
||||||
// WithDeletePermanentlyAfter sets the deletePermanentlyAfter duration.
|
|
||||||
// If a record is deleted via Delete, it will be permanently deleted after
|
|
||||||
// the given duration.
|
|
||||||
func WithDeletePermanentlyAfter(dur time.Duration) ServerOption {
|
|
||||||
return func(cfg *serverConfig) {
|
|
||||||
cfg.deletePermanentlyAfter = dur
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithGetAllPageSize sets the page size for GetAll calls.
|
|
||||||
func WithGetAllPageSize(pageSize int) ServerOption {
|
|
||||||
return func(cfg *serverConfig) {
|
|
||||||
cfg.getAllPageSize = pageSize
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithRegistryTTL sets the registry time to live in the config.
|
// WithRegistryTTL sets the registry time to live in the config.
|
||||||
func WithRegistryTTL(ttl time.Duration) ServerOption {
|
func WithRegistryTTL(ttl time.Duration) ServerOption {
|
||||||
return func(cfg *serverConfig) {
|
return func(cfg *serverConfig) {
|
||||||
|
@ -66,18 +37,6 @@ func WithRegistryTTL(ttl time.Duration) ServerOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithGetSharedKey sets the secret in the config.
|
|
||||||
func WithGetSharedKey(getSharedKey func() ([]byte, error)) ServerOption {
|
|
||||||
return func(cfg *serverConfig) {
|
|
||||||
sharedKey, err := getSharedKey()
|
|
||||||
if err != nil {
|
|
||||||
log.Error().Err(err).Msgf("shared key is required and must be %d bytes long", cryptutil.DefaultKeySize)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
cfg.secret = sharedKey
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithStorageType sets the storage type.
|
// WithStorageType sets the storage type.
|
||||||
func WithStorageType(typ string) ServerOption {
|
func WithStorageType(typ string) ServerOption {
|
||||||
return func(cfg *serverConfig) {
|
return func(cfg *serverConfig) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue