configobserver

package
v0.0.0-...-6859b4a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 28 Imported by: 68

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurvePreferencesToTLSGroups

func CurvePreferencesToTLSGroups[T int64 | string](
	config map[string]interface{},
	sourcePath []string,
	targetPath []string,
) ([]tls.CurveID, error)

CurvePreferencesToTLSGroups reads curve preference IDs from sourcePath in config, converts them to TLS group names using the reverse mapping, and writes them to targetPath. Returns a list of unrecognized curve IDs that were skipped during conversion. Returns error if source path contains invalid data or target path cannot be set.

func NewConfigObserver

func NewConfigObserver(
	name string,
	operatorClient v1helpers.OperatorClient,
	eventRecorder events.Recorder,
	listers Listers,
	informers []factory.Informer,
	observers ...ObserveConfigFunc,
) factory.Controller

func NewNestedConfigObserver

func NewNestedConfigObserver(
	name string,
	operatorClient v1helpers.OperatorClient,
	eventRecorder events.Recorder,
	listers Listers,
	informers []factory.Informer,
	nestedConfigPath []string,
	degradedConditionPrefix string,
	observers ...ObserveConfigFunc,
) factory.Controller

NewNestedConfigObserver creates a config observer that watches changes to a nested field (nestedConfigPath) in the config. Useful when the config is shared across multiple controllers in the same process.

Example:

Given the following configuration, you could run two separate controllers and point each to its own section. The first controller would be responsible for "oauthAPIServer" and the second for "oauthServer" section.

"observedConfig": {
  "oauthAPIServer": {
    "apiServerArguments": {"tls-min-version": "VersionTLS12"}
  },
  "oauthServer": {
    "corsAllowedOrigins": [ "//127\\.0\\.0\\.1(:|$)","//localhost(:|$)"]
  }
}

oauthAPIController := NewNestedConfigObserver(..., []string{"oauthAPIServer"} oauthServerController := NewNestedConfigObserver(..., []string{"oauthServer"}

func Pruned

func Pruned(obj map[string]interface{}, pths ...[]string) map[string]interface{}

Pruned returns the unstructured filtered by the given paths, i.e. everything outside of them will be dropped. The returned data structure might overlap with the input, but the input is not mutated. In case of error for a path, that path is dropped.

func TLSGroupsToCurvePreferences

func TLSGroupsToCurvePreferences[T int64 | string](
	config map[string]interface{},
	sourcePath []string,
	targetPath []string,
) ([]configv1.TLSGroup, error)

TLSGroupsToCurvePreferences reads TLS group names from sourcePath in config, converts them to curve preference IDs, and writes them to targetPath. Returns a list of unrecognized group names that were skipped during conversion. Returns error if paths cannot be accessed.

Types

type ConfigObserver

type ConfigObserver struct {
	// contains filtered or unexported fields
}

type Listers

type Listers interface {
	// ResourceSyncer can be used to copy content from one namespace to another
	ResourceSyncer() resourcesynccontroller.ResourceSyncer
	PreRunHasSynced() []cache.InformerSynced
}

Listers is an interface which will be passed to the config observer funcs. It is expected to be hard-cast to the "correct" type

type ObserveConfigFunc

type ObserveConfigFunc func(listers Listers, recorder events.Recorder, existingConfig map[string]interface{}) (observedConfig map[string]interface{}, errs []error)

ObserveConfigFunc observes configuration and returns the observedConfig. This function should not return an observedConfig that would cause the service being managed by the operator to crash. For example, if a required configuration key cannot be observed, consider reusing the configuration key's previous value. Errors that occur while attempting to generate the observedConfig should be returned in the errs slice.

func WithPrefix

func WithPrefix(observer ObserveConfigFunc, prefix ...string) ObserveConfigFunc

WithPrefix adds a prefix to the path the input observer would otherwise observe into

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL