Documentation
¶
Overview ¶
Package config stores katanomi configuration manager which watch configmap and work immediately if configmap changed
Index ¶
- Constants
- func Name() string
- func WithKatanomiConfigManager(ctx context.Context, manager *Manager) context.Context
- type Config
- type FeatureFlags
- type FeatureValue
- type HasFeatureChangedFunc
- type ListByFeatureFlagChanged
- type Manager
- func (manager *Manager) AddWatcher(w Watcher)
- func (manager *Manager) GetConfig() *Config
- func (manager *Manager) GetFeatureFlag(flag string) FeatureValue
- func (manager *Manager) GetFeatureFlagByClient(ctx context.Context, flag string) FeatureValue
- func (manager *Manager) WatchFeatureFlagChanged(ctx context.Context, listFunc ListByFeatureFlagChanged, ...) (source.Source, handler.EventHandler, builder.WatchesOption)
- type ManagerInterface
- type WatchFunc
- type Watcher
Constants ¶
const ( // VersionEnabledFeatureKey indicates the configuration key of the version feature gate. // If the value is true, the feature is enabled cluster-wide. VersionEnabledFeatureKey = "version.enabled" // InitializeAllowLocalRequestsFeatureKey indicates the configuration key of. // If the value is true, the feature is enabled cluster-wide. InitializeAllowLocalRequestsFeatureKey = "plugin.gitlab.allow-local-requests" // PrunerDelayAfterCompletedFeatureKey represent taskRun delay configuration key PrunerDelayAfterCompletedFeatureKey = "taskRunPruner.delayAfterCompleted" // PrunerKeepFeatureKey represent taskRun keep configuration key PrunerKeepFeatureKey = "taskRunPruner.keep" // BuildMRCheckTimeoutKey represent build merge request status check timeout key BuildMRCheckTimeoutKey = "build.mergerequest.checkTimeout" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
Config store katanomi configuration
type FeatureFlags ¶
FeatureFlags holds the features configurations
func (*FeatureFlags) FeatureValue ¶
func (f *FeatureFlags) FeatureValue(flag string) FeatureValue
FeatureValue returns the value of the implemented feature flag, or the default if not found.
type FeatureValue ¶
type FeatureValue string
FeatureValue definition of FeatureValue feature value
const ( // DefaultVersionEnabled indicates the default value of the version feature gate. // If the corresponding key does not exist, the default value is returned. DefaultVersionEnabled FeatureValue = "false" // DefaultInitializeAllowLocalRequests indicates the configuration key of. // If the corresponding key does not exist, the default value is returned. DefaultInitializeAllowLocalRequests FeatureValue = "true" // DefaultPrunerDelayAfterCompleted represent default duration for delay taskRun // If the corresponding key does not exist, the default value is returned. DefaultPrunerDelayAfterCompleted FeatureValue = "time.Hour" // DefaultPrunerKeep represent default keep number for taskRun // If the corresponding key does not exist, the default value is returned. DefaultPrunerKeep FeatureValue = "10000" // DefaultMRCheckTimeout represent default timeout for merge request status check DefaultMRCheckTimeout FeatureValue = "10m" )
func (FeatureValue) AsBool ¶
func (f FeatureValue) AsBool() (bool, error)
AsBool returns as a Bool, or false if the conversion fails.
func (FeatureValue) AsDuration ¶
func (f FeatureValue) AsDuration() (time.Duration, error)
AsBool returns as a Duration, or 0 if the conversion fails.
func (FeatureValue) AsInt ¶
func (f FeatureValue) AsInt() (int, error)
AsInt returned as an integer, or -1 if the conversion fails.
type HasFeatureChangedFunc ¶
type HasFeatureChangedFunc func(new *FeatureFlags, old *FeatureFlags) bool
HasFeatureChangedFunc check whether the function switch of interest has changed.
type ListByFeatureFlagChanged ¶
ListByFeatureFlagChanged when the function switch is changed, get the object function that triggers reconile.
type Manager ¶
type Manager struct { Informer watcher.DefaultingWatcherWithOnChange Logger *zap.SugaredLogger *Config // contains filtered or unexported fields }
Manager will manage katanomi configuration and store in Config
func KatanomiConfigManager ¶
KatanomiConfigManager returns a Config Manager, returns nil if not found
func NewManager ¶
func NewManager(informer watcher.DefaultingWatcherWithOnChange, logger *zap.SugaredLogger, cmName string) *Manager
NewManager will instantiate a manager that watch configmap for core component configuration
func (*Manager) AddWatcher ¶
AddWatcher add a watcher to manager the watcher will be called when the configmap is changed
func (*Manager) GetFeatureFlag ¶
func (manager *Manager) GetFeatureFlag(flag string) FeatureValue
GetFeatureFlag get the function switch data, if the function switch is not set, return the default value of the switch.
func (*Manager) GetFeatureFlagByClient ¶
func (manager *Manager) GetFeatureFlagByClient(ctx context.Context, flag string) FeatureValue
GetFeatureFlagByClient get the config configuration by requesting configmap from the client. prioritize the use of GetFeatureFlag, and use the current function in scenarios that require high real-time data.
func (*Manager) WatchFeatureFlagChanged ¶
func (manager *Manager) WatchFeatureFlagChanged(ctx context.Context, listFunc ListByFeatureFlagChanged, featureChanged HasFeatureChangedFunc) (source.Source, handler.EventHandler, builder.WatchesOption)
WatchFeatureFlagChanged trigger reconcile when the function switch is changed.
type ManagerInterface ¶ added in v0.8.0
type ManagerInterface interface { GetConfig() *Config GetFeatureFlag(flag string) FeatureValue }
type Watcher ¶
type Watcher interface {
Watch(config *Config)
}
Watcher describes the interface for config watcher
func NewConfigWatcher ¶
NewConfigWatcher constructs a new config watcher please note that the callback should be processed quickly and should not block