assets

package
v0.86.1-rhobs1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RefTracker

type RefTracker map[string]struct{}

RefTracker is a set-based struct which records the references to secrets and configmaps.

func (RefTracker) Has

func (r RefTracker) Has(obj runtime.Object) bool

Has returns true if the tracker knows about the given object.

type StoreBuilder

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

StoreBuilder is a store that fetches and caches TLS materials, bearer tokens and auth credentials from configmaps and secrets.

Data can be referenced directly from a Prometheus object or indirectly (for instance via ServiceMonitor). In practice a new store is created and used by each reconciliation loop.

StoreBuilder doesn't support concurrent access.

func NewStoreBuilder

func NewStoreBuilder(cmClient corev1client.ConfigMapsGetter, sClient corev1client.SecretsGetter) *StoreBuilder

NewStoreBuilder returns an object that can fetch data from ConfigMaps and Secrets.

func NewTestStoreBuilder

func NewTestStoreBuilder(objects ...any) *StoreBuilder

NewTestStoreBuilder returns a *StoreBuilder already initialized with the provided objects. It is only used in tests.

func (*StoreBuilder) AddAuthorizationCredentials

func (s *StoreBuilder) AddAuthorizationCredentials(ctx context.Context, namespace string, auth *monitoringv1.Authorization) error

func (*StoreBuilder) AddAzureOAuth

func (s *StoreBuilder) AddAzureOAuth(ctx context.Context, ns string, azureAD *monitoringv1.AzureAD) error

AddAzureOAuth processes the AzureOAuth SecretKeySelectors and adds the AzureOAuth data to the store.

func (*StoreBuilder) AddBasicAuth

func (s *StoreBuilder) AddBasicAuth(ctx context.Context, ns string, ba *monitoringv1.BasicAuth) error

AddBasicAuth processes the given *BasicAuth and adds the referenced credentials to the store.

func (*StoreBuilder) AddOAuth2

func (s *StoreBuilder) AddOAuth2(ctx context.Context, ns string, oauth2 *monitoringv1.OAuth2) error

AddOAuth2 processes the given *OAuth2 and adds the referenced credentials to the store.

func (*StoreBuilder) AddObject

func (s *StoreBuilder) AddObject(obj any) error

AddObject adds an object to the underlying store. This method is only used by external clients of the assets package such as the OpenTelemetry collector operator.

func (*StoreBuilder) AddProxyConfig

func (s *StoreBuilder) AddProxyConfig(ctx context.Context, namespace string, pc monitoringv1.ProxyConfig) error

AddProxyConfig processes the given *ProxyConfig and adds the referenced credentials to the store.

func (*StoreBuilder) AddSafeAuthorizationCredentials

func (s *StoreBuilder) AddSafeAuthorizationCredentials(ctx context.Context, namespace string, auth *monitoringv1.SafeAuthorization) error

func (*StoreBuilder) AddSafeTLSConfig

func (s *StoreBuilder) AddSafeTLSConfig(ctx context.Context, ns string, tlsConfig *monitoringv1.SafeTLSConfig) error

AddSafeTLSConfig validates the given SafeTLSConfig and adds it to the store.

func (*StoreBuilder) AddSigV4

func (s *StoreBuilder) AddSigV4(ctx context.Context, ns string, sigv4 *monitoringv1.Sigv4) error

AddSigV4 processes the SigV4 SecretKeySelectors and adds the SigV4 data to the store.

func (*StoreBuilder) AddTLSConfig

func (s *StoreBuilder) AddTLSConfig(ctx context.Context, ns string, tlsConfig *monitoringv1.TLSConfig) error

AddTLSConfig validates the given TLSConfig and adds it to the store.

func (*StoreBuilder) DeleteObject

func (s *StoreBuilder) DeleteObject(obj any) error

DeleteObject deletes the object in the underlying store. This method is only used by external clients of the assets package such as the OpenTelemetry collector operator.

func (*StoreBuilder) ForNamespace

func (s *StoreBuilder) ForNamespace(namespace string) StoreGetter

ForNamespace returns a StoreGetter scoped to the given namespace. It reads data only from the cache which needs to be populated beforehand. The namespace argument can't be empty.

func (*StoreBuilder) GetConfigMapKey

func (s *StoreBuilder) GetConfigMapKey(ctx context.Context, namespace string, sel v1.ConfigMapKeySelector) (string, error)

GetConfigMapKey processes the given ConfigMapKeySelector and returns the referenced data.

func (*StoreBuilder) GetKey

func (s *StoreBuilder) GetKey(ctx context.Context, namespace string, sel monitoringv1.SecretOrConfigMap) (string, error)

GetKey processes the given SecretOrConfigMap selector and returns the referenced data.

func (*StoreBuilder) GetObject

func (s *StoreBuilder) GetObject(obj any) (any, bool, error)

GetObject retrieves an object from the underlying store. This method is only used by external clients of the assets package such as the OpenTelemetry collector operator.

func (*StoreBuilder) GetSecretClient

func (s *StoreBuilder) GetSecretClient() corev1client.SecretsGetter

GetSecretClient returns the store's secret client. This method is only used by external clients of the assets package such as the OpenTelemetry collector operator. Example usage - Update asset store on a watch event requires the secret client to fetch the latest secrets.

func (*StoreBuilder) GetSecretKey

func (s *StoreBuilder) GetSecretKey(ctx context.Context, namespace string, sel v1.SecretKeySelector) (string, error)

GetSecretKey processes the given SecretKeySelector and returns the referenced data.

func (*StoreBuilder) RefTracker

func (s *StoreBuilder) RefTracker() RefTracker

RefTracker returns a RefTracker for the items loaded in the store. It is safe to use after the StoreBuilder has been deleted.

func (*StoreBuilder) TLSAssets

func (s *StoreBuilder) TLSAssets() map[string][]byte

TLSAssets returns a map of TLS assets (certificates and keys) which have been added to the store by AddTLSConfig() and AddSafeTLSConfig().

func (*StoreBuilder) UpdateObject

func (s *StoreBuilder) UpdateObject(obj any) error

UpdateObject updates the object in the underlying store. This method is only used by external clients of the assets package such as the OpenTelemetry collector operator.

type StoreGetter

type StoreGetter interface {
	GetSecretOrConfigMapKey(key monitoringv1.SecretOrConfigMap) (string, error)
	GetConfigMapKey(key v1.ConfigMapKeySelector) (string, error)
	GetSecretKey(key v1.SecretKeySelector) ([]byte, error)
	TLSAsset(key any) string
}

StoreGetter can get data from ConfigMap/Secret objects via key selectors. It will return an error if the key selector didn't match.

Jump to

Keyboard shortcuts

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