storage

package
v1.14.6 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: Apache-2.0, Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package storage contains the plumbing to setup the etcd storage of the apiserver.

Index

Constants

View Source
const AllResources = "*"

Variables

This section is empty.

Functions

func NewStorageCodec

func NewStorageCodec(opts StorageCodecConfig) (runtime.Codec, runtime.GroupVersioner, error)

NewStorageCodec assembles a storage codec for the provided storage media type, the provided serializer, and the requested storage and memory versions.

Types

type APIResourceConfigSource

type APIResourceConfigSource interface {
	VersionEnabled(version schema.GroupVersion) bool
	ResourceEnabled(resource schema.GroupVersionResource) bool
	AnyVersionForGroupEnabled(group string) bool
}

APIResourceConfigSource is the interface to determine which groups and versions are enabled

type Backend added in v1.7.0

type Backend struct {
	// the url of storage backend like: https://etcd.domain:2379
	Server string
	// the required tls config
	TLSConfig *tls.Config
}

Backend describes the storage servers, the information here should be enough for health validations.

type DefaultResourceEncodingConfig

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

func NewDefaultResourceEncodingConfig

func NewDefaultResourceEncodingConfig(scheme *runtime.Scheme) *DefaultResourceEncodingConfig

func (*DefaultResourceEncodingConfig) InMemoryEncodingFor

func (o *DefaultResourceEncodingConfig) InMemoryEncodingFor(resource schema.GroupResource) (schema.GroupVersion, error)

func (*DefaultResourceEncodingConfig) SetResourceEncoding

func (o *DefaultResourceEncodingConfig) SetResourceEncoding(resourceBeingStored schema.GroupResource, externalEncodingVersion, internalVersion schema.GroupVersion)

func (*DefaultResourceEncodingConfig) StorageEncodingFor

func (o *DefaultResourceEncodingConfig) StorageEncodingFor(resource schema.GroupResource) (schema.GroupVersion, error)

type DefaultStorageFactory

type DefaultStorageFactory struct {
	// StorageConfig describes how to create a storage backend in general.
	// Its authentication information will be used for every storage.Interface returned.
	StorageConfig storagebackend.Config

	Overrides map[schema.GroupResource]groupResourceOverrides

	DefaultResourcePrefixes map[schema.GroupResource]string

	// DefaultMediaType is the media type used to store resources. If it is not set, "application/json" is used.
	DefaultMediaType string

	// DefaultSerializer is used to create encoders and decoders for the storage.Interface.
	DefaultSerializer runtime.StorageSerializer

	// ResourceEncodingConfig describes how to encode a particular GroupVersionResource
	ResourceEncodingConfig ResourceEncodingConfig

	// APIResourceConfigSource indicates whether the *storage* is enabled, NOT the API
	// This is discrete from resource enablement because those are separate concerns.  How this source is configured
	// is left to the caller.
	APIResourceConfigSource APIResourceConfigSource
	// contains filtered or unexported fields
}

DefaultStorageFactory takes a GroupResource and returns back its storage interface. This result includes: 1. Merged etcd config, including: auth, server locations, prefixes 2. Resource encodings for storage: group,version,kind to store as 3. Cohabitating default: some resources like hpa are exposed through multiple APIs. They must agree on 1 and 2

func NewDefaultStorageFactory

func NewDefaultStorageFactory(
	config storagebackend.Config,
	defaultMediaType string,
	defaultSerializer runtime.StorageSerializer,
	resourceEncodingConfig ResourceEncodingConfig,
	resourceConfig APIResourceConfigSource,
	specialDefaultResourcePrefixes map[schema.GroupResource]string,
) *DefaultStorageFactory

func (*DefaultStorageFactory) AddCohabitatingResources

func (s *DefaultStorageFactory) AddCohabitatingResources(groupResources ...schema.GroupResource)

AddCohabitatingResources links resources together the order of the slice matters! its the priority order of lookup for finding a storage location

func (*DefaultStorageFactory) AddSerializationChains

func (s *DefaultStorageFactory) AddSerializationChains(encoderDecoratorFn func(runtime.Encoder) runtime.Encoder, decoderDecoratorFn func([]runtime.Decoder) []runtime.Decoder, groupResources ...schema.GroupResource)

func (*DefaultStorageFactory) Backends

func (s *DefaultStorageFactory) Backends() []Backend

Backends returns all backends for all registered storage destinations. Used for getting all instances for health validations.

func (*DefaultStorageFactory) NewConfig

func (s *DefaultStorageFactory) NewConfig(groupResource schema.GroupResource) (*storagebackend.Config, error)

New finds the storage destination for the given group and resource. It will return an error if the group has no storage destination configured.

func (*DefaultStorageFactory) ResourcePrefix

func (s *DefaultStorageFactory) ResourcePrefix(groupResource schema.GroupResource) string

func (*DefaultStorageFactory) SetDisableAPIListChunking added in v1.8.0

func (s *DefaultStorageFactory) SetDisableAPIListChunking(groupResource schema.GroupResource)

SetDisableAPIListChunking allows a specific resource to disable paging at the storage layer, to prevent exposure of key names in continuations. This may be overridden by feature gates.

func (*DefaultStorageFactory) SetEtcdLocation

func (s *DefaultStorageFactory) SetEtcdLocation(groupResource schema.GroupResource, location []string)

func (*DefaultStorageFactory) SetEtcdPrefix

func (s *DefaultStorageFactory) SetEtcdPrefix(groupResource schema.GroupResource, prefix string)

func (*DefaultStorageFactory) SetResourceEtcdPrefix

func (s *DefaultStorageFactory) SetResourceEtcdPrefix(groupResource schema.GroupResource, prefix string)

SetResourceEtcdPrefix sets the prefix for a resource, but not the base-dir. You'll end up in `etcdPrefix/resourceEtcdPrefix`.

func (*DefaultStorageFactory) SetSerializer

func (s *DefaultStorageFactory) SetSerializer(groupResource schema.GroupResource, mediaType string, serializer runtime.StorageSerializer)

func (*DefaultStorageFactory) SetTransformer added in v1.7.0

func (s *DefaultStorageFactory) SetTransformer(groupResource schema.GroupResource, transformer value.Transformer)

type OverridingResourceEncoding added in v1.14.0

type OverridingResourceEncoding struct {
	ExternalResourceEncoding schema.GroupVersion
	InternalResourceEncoding schema.GroupVersion
}

type ResourceConfig

type ResourceConfig struct {
	GroupVersionConfigs map[schema.GroupVersion]bool
	ResourceConfigs     map[schema.GroupVersionResource]bool
}

func NewResourceConfig

func NewResourceConfig() *ResourceConfig

func (*ResourceConfig) AnyVersionForGroupEnabled added in v1.10.0

func (o *ResourceConfig) AnyVersionForGroupEnabled(group string) bool

func (*ResourceConfig) DisableAll added in v1.11.0

func (o *ResourceConfig) DisableAll()

DisableAll disables all group/versions. It does not modify individual resource enablement/disablement.

func (*ResourceConfig) DisableResources

func (o *ResourceConfig) DisableResources(resources ...schema.GroupVersionResource)

func (*ResourceConfig) DisableVersions

func (o *ResourceConfig) DisableVersions(versions ...schema.GroupVersion)

DisableVersions disables the versions entirely.

func (*ResourceConfig) EnableAll added in v1.11.0

func (o *ResourceConfig) EnableAll()

EnableAll enables all group/versions. It does not modify individual resource enablement/disablement.

func (*ResourceConfig) EnableResources

func (o *ResourceConfig) EnableResources(resources ...schema.GroupVersionResource)

func (*ResourceConfig) EnableVersions

func (o *ResourceConfig) EnableVersions(versions ...schema.GroupVersion)

func (*ResourceConfig) ResourceEnabled

func (o *ResourceConfig) ResourceEnabled(resource schema.GroupVersionResource) bool

func (*ResourceConfig) VersionEnabled added in v1.10.0

func (o *ResourceConfig) VersionEnabled(version schema.GroupVersion) bool

type ResourceEncodingConfig

type ResourceEncodingConfig interface {
	// StorageEncoding returns the serialization format for the resource.
	// TODO this should actually return a GroupVersionKind since you can logically have multiple "matching" Kinds
	// For now, it returns just the GroupVersion for consistency with old behavior
	StorageEncodingFor(schema.GroupResource) (schema.GroupVersion, error)

	// InMemoryEncodingFor returns the groupVersion for the in memory representation the storage should convert to.
	InMemoryEncodingFor(schema.GroupResource) (schema.GroupVersion, error)
}

type StorageCodecConfig

type StorageCodecConfig struct {
	StorageMediaType  string
	StorageSerializer runtime.StorageSerializer
	StorageVersion    schema.GroupVersion
	MemoryVersion     schema.GroupVersion
	Config            storagebackend.Config

	EncoderDecoratorFn func(runtime.Encoder) runtime.Encoder
	DecoderDecoratorFn func([]runtime.Decoder) []runtime.Decoder
}

StorageCodecConfig are the arguments passed to newStorageCodecFn

type StorageFactory

type StorageFactory interface {
	// New finds the storage destination for the given group and resource. It will
	// return an error if the group has no storage destination configured.
	NewConfig(groupResource schema.GroupResource) (*storagebackend.Config, error)

	// ResourcePrefix returns the overridden resource prefix for the GroupResource
	// This allows for cohabitation of resources with different native types and provides
	// centralized control over the shape of etcd directories
	ResourcePrefix(groupResource schema.GroupResource) string

	// Backends gets all backends for all registered storage destinations.
	// Used for getting all instances for health validations.
	Backends() []Backend
}

StorageFactory is the interface to locate the storage for a given GroupResource

Jump to

Keyboard shortcuts

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