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 ¶
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 ¶
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.
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.
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 (*Store) CloseIdleConnections ¶
func (s *Store) CloseIdleConnections()
CloseIdleConnections closes the idle connections of the transport of the client.
func (*Store) Format ¶
Format implements fmt.Formatter: every verb prints the ConfigMap and nothing of the setting.
func (*Store) Get ¶
func (s *Store) Get(ctx context.Context, req objectstore.GetRequest) (objectstore.Object, error)
Get implements objectstore.ObjectStore. See Store for the rules.