2022-11-18 15:21:15 +01:00
|
|
|
package internal
|
|
|
|
|
2022-11-24 20:57:01 +01:00
|
|
|
import "flag"
|
|
|
|
|
2022-11-18 15:21:15 +01:00
|
|
|
type Configuration interface {
|
|
|
|
UsesTracing() bool
|
|
|
|
UsesProfiling() bool
|
2022-11-22 10:10:07 +01:00
|
|
|
UsesKubeconfig() bool
|
2022-11-24 20:57:01 +01:00
|
|
|
FlagSets() []*flag.FlagSet
|
2022-11-18 15:21:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewConfiguration(options ...ConfigurationOption) Configuration {
|
|
|
|
c := &configuration{}
|
|
|
|
for _, option := range options {
|
|
|
|
option(c)
|
|
|
|
}
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
|
|
|
type ConfigurationOption func(c *configuration)
|
|
|
|
|
|
|
|
func WithTracing() ConfigurationOption {
|
|
|
|
return func(c *configuration) {
|
|
|
|
c.usesTracing = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithProfiling() ConfigurationOption {
|
|
|
|
return func(c *configuration) {
|
|
|
|
c.usesProfiling = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-22 10:10:07 +01:00
|
|
|
func WithKubeconfig() ConfigurationOption {
|
|
|
|
return func(c *configuration) {
|
|
|
|
c.usesKubeconfig = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-24 20:57:01 +01:00
|
|
|
func WithFlagSets(flagsets ...*flag.FlagSet) ConfigurationOption {
|
|
|
|
return func(c *configuration) {
|
|
|
|
c.flagSets = append(c.flagSets, flagsets...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-18 15:21:15 +01:00
|
|
|
type configuration struct {
|
2022-11-22 10:10:07 +01:00
|
|
|
usesTracing bool
|
|
|
|
usesProfiling bool
|
|
|
|
usesKubeconfig bool
|
2022-11-24 20:57:01 +01:00
|
|
|
flagSets []*flag.FlagSet
|
2022-11-18 15:21:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configuration) UsesTracing() bool {
|
|
|
|
return c.usesTracing
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *configuration) UsesProfiling() bool {
|
|
|
|
return c.usesProfiling
|
|
|
|
}
|
2022-11-22 10:10:07 +01:00
|
|
|
|
|
|
|
func (c *configuration) UsesKubeconfig() bool {
|
|
|
|
return c.usesKubeconfig
|
|
|
|
}
|
2022-11-24 20:57:01 +01:00
|
|
|
|
|
|
|
func (c *configuration) FlagSets() []*flag.FlagSet {
|
|
|
|
return c.flagSets
|
|
|
|
}
|