configmapstore

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package configmapstore is the flag source of a Kubernetes ConfigMap: the keys of its data are the objects, read with one GET of the ConfigMap through client-go. It is the only package that imports client-go.

Index

Constants

View Source
const DefaultServiceAccountDir = "/var/run/secrets/kubernetes.io/serviceaccount"

DefaultServiceAccountDir is where a pod finds the credentials of its service account: the token, ca.crt and namespace files.

Variables

View Source
var (
	// ErrAccessMode is the cause of a token file or a CA bundle without an endpoint: the in-cluster access has its own.
	ErrAccessMode = fmt.Errorf(
		"%w: tokenFile and the CA bundle go with endpoint", objectstore.ErrInvalidConfig)
	// ErrNotInCluster is the cause of an in-cluster setting outside a cluster: the service address is not set.
	ErrNotInCluster = fmt.Errorf(
		"%w: not running in a cluster (%s and %s are not set): set endpoint",
		objectstore.ErrInvalidConfig, hostEnv, portEnv)
	// ErrServiceAccount is the cause of a service account directory without a readable token or CA file.
	ErrServiceAccount = fmt.Errorf(
		"%w: the service account token or CA file cannot be read", objectstore.ErrInvalidConfig)
	// ErrTLS is the cause of a TLS setting that cannot be used (a CA bundle that holds no certificate). The cause is
	// dropped: it may quote a key.
	ErrTLS = fmt.Errorf("%w: the TLS setting cannot be used", objectstore.ErrInvalidConfig)
)

The causes of a refused cluster access setting. None of them holds a path, an address or a credential.

View Source
var ErrNotConfigMap = errors.New("objectstore: the answer is not a ConfigMap")

ErrNotConfigMap is the cause of an answer that is no ConfigMap: something other than the API server answered.

View Source
var ErrTokenFile = errors.New("objectstore: the token file cannot be read")

ErrTokenFile is the cause of a request that could not read the token file: it is gone, or empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Tracing are the OpenTelemetry providers of the store: with them enabled every request has a client span and
	// carries the trace context and the baggage of the context of the call, from the stock HTTP instrumentation
	// (client-go takes it as the WrapTransport of its setting). The zero value instruments nothing.
	Tracing tracing.Providers
	// LookupEnv reads the service address of the cluster (KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT) for the
	// in-cluster access. Nil means [os.LookupEnv].
	LookupEnv func(string) (string, bool)
	// Namespace is the namespace of the ConfigMap.
	Namespace string
	// ConfigMap is the name of the ConfigMap: its data keys are the keys of the store.
	ConfigMap string
	// Endpoint is the address of the API server (https, or http for a loopback host). Empty means the service account
	// of the pod the relay runs in.
	Endpoint string
	// TokenFile is the file of the bearer token sent to Endpoint. It is read at every request, so that a rotated token
	// is picked up. Empty sends none.
	TokenFile string
	// ServiceAccountDir is where the in-cluster access reads token and ca.crt. Empty means
	// [DefaultServiceAccountDir].
	ServiceAccountDir string
	// CABundlePEM are the certificate authorities that sign the API server of Endpoint, instead of the system roots.
	CABundlePEM []byte
	// MinTLSVersion is the lowest TLS version; zero means TLS 1.2.
	MinTLSVersion uint16
	// RequestTimeout bounds one Get or List from the request to the last byte of the answer. Zero means
	// [storekit.DefaultCloudRequestTimeout].
	RequestTimeout time.Duration
}

Config is the setting of a Store.

type Store

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

Store is an objectstore.ObjectStore on the data of one Kubernetes ConfigMap. Every Get is one GET of the ConfigMap (`get` on that one ConfigMap is the permission it needs, never `list`): the keys of its data are the objects, and the key of a Get is the key of the data entry. The ETag, and the marker of a listing, is a hash of the value, so a write to another key of the ConfigMap changes nothing for this one. Kubernetes keeps no time for a single key: the modification time is the creation time of the ConfigMap.

A key of binaryData is read like one of data (a ConfigMap holds no key in both). The retries of client-go are off: the reader owns the retries and their budget, so a throttled answer is not waited for inside the call.

func New

func New(cfg *Config) (*Store, error)

New checks the setting and returns the store. It sends no request.

func (*Store) Close

func (s *Store) Close() error

Close releases the idle connections of the client.

func (*Store) CloseIdleConnections

func (s *Store) CloseIdleConnections()

CloseIdleConnections closes the idle connections of the transport of the client.

func (*Store) Format

func (s *Store) Format(f fmt.State, _ rune)

Format implements fmt.Formatter: every verb prints the ConfigMap and nothing of the setting.

func (*Store) Get

Get implements objectstore.ObjectStore. See Store for the rules.

Jump to

Keyboard shortcuts

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