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



    View Source
    const AllResources = "*"


    This section is empty.


    func NewStorageCodec

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

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


      type APIResourceConfigSource

      type APIResourceConfigSource interface {
      	AnyVersionOfResourceEnabled(resource schema.GroupResource) bool
      	ResourceEnabled(resource schema.GroupVersionResource) bool
      	AllResourcesForVersionEnabled(version schema.GroupVersion) bool
      	AnyResourcesForVersionEnabled(version schema.GroupVersion) bool
      	AnyResourcesForGroupEnabled(group string) bool

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

        type Backend

        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 (*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) SetVersionEncoding

          func (o *DefaultResourceEncodingConfig) SetVersionEncoding(group string, 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) *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) 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

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

                    type GroupResourceEncodingConfig

                    type GroupResourceEncodingConfig struct {
                    	DefaultExternalEncoding   schema.GroupVersion
                    	ExternalResourceEncodings map[string]schema.GroupVersion
                    	DefaultInternalEncoding   schema.GroupVersion
                    	InternalResourceEncodings map[string]schema.GroupVersion

                    type GroupVersionResourceConfig

                    type GroupVersionResourceConfig struct {
                    	// Whether to enable or disable this entire group version.  This dominates any enablement check.
                    	// Enable=true means the group version is enabled, and EnabledResources/DisabledResources are considered.
                    	// Enable=false means the group version is disabled, and EnabledResources/DisabledResources are not considered.
                    	Enable bool
                    	// DisabledResources lists the resources that are specifically disabled for a group/version
                    	// DisabledResources trumps EnabledResources
                    	DisabledResources sets.String
                    	// EnabledResources lists the resources that should be enabled by default.  This is a little
                    	// unusual, but we need it for compatibility with old code for now.  An empty set means
                    	// enable all, a non-empty set means that all other resources are disabled.
                    	EnabledResources sets.String

                      Specifies the overrides for various API group versions. This can be used to enable/disable entire group versions or specific resources.

                      func NewGroupVersionResourceConfig

                      func NewGroupVersionResourceConfig() *GroupVersionResourceConfig

                      type ResourceConfig

                      type ResourceConfig struct {
                      	GroupVersionResourceConfigs map[schema.GroupVersion]*GroupVersionResourceConfig

                      func NewResourceConfig

                      func NewResourceConfig() *ResourceConfig

                      func (*ResourceConfig) AllResourcesForVersionEnabled

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

                      func (*ResourceConfig) AnyResourcesForGroupEnabled

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

                      func (*ResourceConfig) AnyResourcesForVersionEnabled

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

                      func (*ResourceConfig) AnyVersionOfResourceEnabled

                      func (o *ResourceConfig) AnyVersionOfResourceEnabled(resource schema.GroupResource) bool

                        AnyResourcesForVersionEnabled only considers matches based on exactly group/resource lexical matching. This means that resource renames across versions are NOT considered to be the same resource by this method. You'll need to manually check using the ResourceEnabled function.

                        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. No resources (even those whitelisted in EnabledResources) will be enabled

                          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

                          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