controller

package
v0.0.0-...-9983877 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 70 Imported by: 0

Documentation

Overview

Package controller provides deployment hooks for configuring TLS security profiles and proxy settings from OpenShift cluster configuration.

Package controller provides deployment hooks for configuring TLS security profiles and proxy settings from OpenShift cluster configuration.

Index

Constants

View Source
const (
	HTTPProxy  = "HTTP_PROXY"
	HTTPSProxy = "HTTPS_PROXY"
	NoProxy    = "NO_PROXY"
)

Proxy environment variable constants

Variables

This section is empty.

Functions

func GetMetricsServerTLSServingInfo

func GetMetricsServerTLSServingInfo(ctx context.Context, configClient configclient.Interface) (configv1.HTTPServingInfo, error)

GetMetricsServerTLSServingInfo reads the cluster TLS security profile from the APIServer config and returns a configv1.HTTPServingInfo populated with MinTLSVersion and CipherSuites. Returns an empty HTTPServingInfo (with no error) if the APIServer resource is not found.

func NewDynamicRequiredManifestController

func NewDynamicRequiredManifestController(name string, manifest []byte, key types.NamespacedName, gvr schema.GroupVersionResource, operatorClient *clients.OperatorClient, dynamicClient dynamic.Interface, resourceClient ResourceClient, recorder events.Recorder) factory.Controller

func NewFeatureGate

func NewFeatureGate(enabled, disabled []configv1.FeatureGateName) featuregates.FeatureGate

TODO: Remove the featureGate stuff to use the real thing

func NewIncompatibleOperatorController

func NewIncompatibleOperatorController(
	name string,
	currentOCPMinorVersion *semver.Version,
	kubeclient kubernetes.Interface,
	clusterExtensionClient *clients.ClusterExtensionClient,
	clusterObjectSetClient *clients.ClusterObjectSetClient,
	operatorClient v1helpers.OperatorClient,
	featureGate featuregates.FeatureGate,
	eventRecorder events.Recorder,
) factory.Controller

func NewProxyController

func NewProxyController(name string, proxyClient *clients.ProxyClient, operatorClient *clients.OperatorClient, eventRecorder events.Recorder) factory.Controller

func NewStaticUpgradeableConditionController

func NewStaticUpgradeableConditionController(name string, operatorClient *clients.OperatorClient, eventRecorder events.Recorder, prefixes []string) factory.Controller

func TLSCipherSuitesPath

func TLSCipherSuitesPath() []string

TLSCipherSuitesPath returns the path for the observed TLS cipher suites.

func TLSMinVersionPath

func TLSMinVersionPath() []string

TLSMinVersionPath returns the path for the observed minimum TLS version.

func TLSProfileFromObservedConfig

func TLSProfileFromObservedConfig(operatorSpec *operatorv1.OperatorSpec) (string, []string)

TLSProfileFromObservedConfig extracts the TLS minVersion and cipherSuites stored in the operator's observedConfig at the olmTLSSecurityProfile paths. Returns empty strings/nil if the observedConfig is absent or unparseable.

func TLSSecurityProfileConfigPath

func TLSSecurityProfileConfigPath() []string

TLSSecurityProfileConfigPath returns the path for the observed TLS security profile configuration.

func ToObjectReference

func ToObjectReference(o *unstructured.Unstructured, restMapper meta.RESTMapper, knownRESTMappings map[schema.GroupVersionKind]*meta.RESTMapping) (*configv1.ObjectReference, error)

ToObjectReference converts an unstructured Object into an ObjectReference with the provided restMapper. The Group/Resource mapping may be overridden by providing a mapping for the gvk in the knownRestMappings map.

func UpdateDeploymentObservedConfigHook

func UpdateDeploymentObservedConfigHook(_ *clients.OperatorClient) deploymentcontroller.DeploymentHookFunc

UpdateDeploymentObservedConfigHook creates a deployment hook that reads observedConfig from the olms.operator.openshift.io resource and extracts TLS configuration

func UpdateMetricsServerConfigFile

func UpdateMetricsServerConfigFile(path string, servingInfo configv1.HTTPServingInfo) error

UpdateMetricsServerConfigFile overwrites the config file at path with new TLS serving info. controllercmd's WithRestartOnChange watches the config file and triggers a graceful restart when its content changes, so the metrics server picks up the new TLS settings.

func UpdateProxyEnvironment

func UpdateProxyEnvironment(logger logr.Logger, pc clients.ProxyClientInterface) error

func WalkYAMLManifestsDir

func WalkYAMLManifestsDir(dir string, fn ...WalkManifestDirFunc) error

WalkYAMLManifestsDir parses all YAML manifests nested within the specified directory and calls fn on any non-empty, valid yaml manifests for kubernetes resources found. fn is called for each resource in a parsed file, and the aggregated list of errors is provided once the whole filetree rooted at dir is parsed. The files are parsed in lexical order, with the manifests within each file parsed in the order they have within the file.

func WriteMetricsServerConfigFile

func WriteMetricsServerConfigFile(servingInfo configv1.HTTPServingInfo) (string, error)

WriteMetricsServerConfigFile writes a GenericOperatorConfig JSON file containing the given serving info to a temp file and returns the file path. The caller is responsible for cleaning up the file when it is no longer needed.

Types

type Builder

type Builder struct {
	Assets            string
	Clients           *clients.Clients
	ControllerContext *controllercmd.ControllerContext
	KnownRESTMappings map[schema.GroupVersionKind]*meta.RESTMapping
	FeatureGate       configv1.FeatureGate
	Infrastructure    *configv1.Infrastructure
}

func (*Builder) BuildControllers

func (b *Builder) BuildControllers(subDirectories ...string) (map[string]factory.Controller, map[string]factory.Controller, map[string]factory.Controller, []configv1.ObjectReference, error)

func (*Builder) CurrentFeatureGates

func (b *Builder) CurrentFeatureGates() (featuregates.FeatureGate, error)

func (*Builder) HasEnabledDownstreamFeatureGates

func (b *Builder) HasEnabledDownstreamFeatureGates(clusterGatesConfig featuregates.FeatureGate) (bool, error)

HasEnabledDownstreamFeatureGates checks if any downstream feature gates that map to operator-controller or catalogd are enabled in the cluster. Returns true if at least one relevant feature gate is enabled.

Callers should combine this result with UseExperimentalFeatureSet() to determine if operator-controller should be deployed.

func (*Builder) UseExperimentalFeatureSet

func (b *Builder) UseExperimentalFeatureSet() bool

type DocumentInfo

type DocumentInfo struct {
	Resource K8sResource
	Text     string
	Order    int
}

type K8sResource

type K8sResource struct {
	APIVersion string `yaml:"apiVersion"`
	Kind       string `yaml:"kind"`
	Metadata   struct {
		Name      string `yaml:"name"`
		Namespace string `yaml:"namespace,omitempty"`
	} `yaml:"metadata"`
}

type OLMConfigObserverListers

type OLMConfigObserverListers struct {
	APIServerListerImpl configlistersv1.APIServerLister
	ResourceSync        resourcesynccontroller.ResourceSyncer
	PreRunCachesSynced  []cache.InformerSynced
}

OLMConfigObserverListers implements the configobserver.Listers interface and apiserver.APIServerLister for use with the library-go ObserveTLSSecurityProfile

func (OLMConfigObserverListers) APIServerLister

func (OLMConfigObserverListers) PreRunHasSynced

func (l OLMConfigObserverListers) PreRunHasSynced() []cache.InformerSynced

func (OLMConfigObserverListers) ResourceSyncer

type ResourceClient

type ResourceClient interface {
	Get(types.NamespacedName) (runtime.Object, error)
	Informer() cache.SharedIndexInformer
}

type TLSObserverController

type TLSObserverController struct {
	factory.Controller
}

TLSObserverController creates a config observer controller that observes TLS security profiles using the library-go ObserveTLSSecurityProfile function

func NewTLSObserverController

func NewTLSObserverController(
	name string,
	operatorClient v1helpers.OperatorClient,
	configInformers configinformers.SharedInformerFactory,
	eventRecorder events.Recorder,
) *TLSObserverController

NewTLSObserverController returns a new TLS observer controller using library-go patterns

type WalkManifestDirFunc

type WalkManifestDirFunc func(path string, manifest *unstructured.Unstructured, rawManifest []byte) error

Jump to

Keyboard shortcuts

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