mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-07 10:17:51 +00:00
vendor dependencies
This commit is contained in:
parent
604208ef4f
commit
72abf135d6
1156 changed files with 78178 additions and 105799 deletions
2
vendor/k8s.io/apiserver/pkg/server/storage/doc.go
generated
vendored
2
vendor/k8s.io/apiserver/pkg/server/storage/doc.go
generated
vendored
|
|
@ -15,4 +15,4 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
// Package storage contains the plumbing to setup the etcd storage of the apiserver.
|
||||
package storage
|
||||
package storage // import "k8s.io/apiserver/pkg/server/storage"
|
||||
|
|
|
|||
29
vendor/k8s.io/apiserver/pkg/server/storage/resource_config.go
generated
vendored
29
vendor/k8s.io/apiserver/pkg/server/storage/resource_config.go
generated
vendored
|
|
@ -23,6 +23,7 @@ import (
|
|||
// APIResourceConfigSource is the interface to determine which groups and versions are enabled
|
||||
type APIResourceConfigSource interface {
|
||||
VersionEnabled(version schema.GroupVersion) bool
|
||||
ResourceEnabled(resource schema.GroupVersionResource) bool
|
||||
AnyVersionForGroupEnabled(group string) bool
|
||||
}
|
||||
|
||||
|
|
@ -30,18 +31,21 @@ var _ APIResourceConfigSource = &ResourceConfig{}
|
|||
|
||||
type ResourceConfig struct {
|
||||
GroupVersionConfigs map[schema.GroupVersion]bool
|
||||
ResourceConfigs map[schema.GroupVersionResource]bool
|
||||
}
|
||||
|
||||
func NewResourceConfig() *ResourceConfig {
|
||||
return &ResourceConfig{GroupVersionConfigs: map[schema.GroupVersion]bool{}}
|
||||
return &ResourceConfig{GroupVersionConfigs: map[schema.GroupVersion]bool{}, ResourceConfigs: map[schema.GroupVersionResource]bool{}}
|
||||
}
|
||||
|
||||
// DisableAll disables all group/versions. It does not modify individual resource enablement/disablement.
|
||||
func (o *ResourceConfig) DisableAll() {
|
||||
for k := range o.GroupVersionConfigs {
|
||||
o.GroupVersionConfigs[k] = false
|
||||
}
|
||||
}
|
||||
|
||||
// EnableAll enables all group/versions. It does not modify individual resource enablement/disablement.
|
||||
func (o *ResourceConfig) EnableAll() {
|
||||
for k := range o.GroupVersionConfigs {
|
||||
o.GroupVersionConfigs[k] = true
|
||||
|
|
@ -70,6 +74,29 @@ func (o *ResourceConfig) VersionEnabled(version schema.GroupVersion) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (o *ResourceConfig) DisableResources(resources ...schema.GroupVersionResource) {
|
||||
for _, resource := range resources {
|
||||
o.ResourceConfigs[resource] = false
|
||||
}
|
||||
}
|
||||
|
||||
func (o *ResourceConfig) EnableResources(resources ...schema.GroupVersionResource) {
|
||||
for _, resource := range resources {
|
||||
o.ResourceConfigs[resource] = true
|
||||
}
|
||||
}
|
||||
|
||||
func (o *ResourceConfig) ResourceEnabled(resource schema.GroupVersionResource) bool {
|
||||
if !o.VersionEnabled(resource.GroupVersion()) {
|
||||
return false
|
||||
}
|
||||
resourceEnabled, explicitlySet := o.ResourceConfigs[resource]
|
||||
if !explicitlySet {
|
||||
return true
|
||||
}
|
||||
return resourceEnabled
|
||||
}
|
||||
|
||||
func (o *ResourceConfig) AnyVersionForGroupEnabled(group string) bool {
|
||||
for version := range o.GroupVersionConfigs {
|
||||
if version.Group == group {
|
||||
|
|
|
|||
73
vendor/k8s.io/apiserver/pkg/server/storage/resource_encoding_config.go
generated
vendored
73
vendor/k8s.io/apiserver/pkg/server/storage/resource_encoding_config.go
generated
vendored
|
|
@ -34,50 +34,27 @@ type ResourceEncodingConfig interface {
|
|||
}
|
||||
|
||||
type DefaultResourceEncodingConfig struct {
|
||||
groups map[string]*GroupResourceEncodingConfig
|
||||
scheme *runtime.Scheme
|
||||
// resources records the overriding encoding configs for individual resources.
|
||||
resources map[schema.GroupResource]*OverridingResourceEncoding
|
||||
scheme *runtime.Scheme
|
||||
}
|
||||
|
||||
type GroupResourceEncodingConfig struct {
|
||||
DefaultExternalEncoding schema.GroupVersion
|
||||
ExternalResourceEncodings map[string]schema.GroupVersion
|
||||
|
||||
DefaultInternalEncoding schema.GroupVersion
|
||||
InternalResourceEncodings map[string]schema.GroupVersion
|
||||
type OverridingResourceEncoding struct {
|
||||
ExternalResourceEncoding schema.GroupVersion
|
||||
InternalResourceEncoding schema.GroupVersion
|
||||
}
|
||||
|
||||
var _ ResourceEncodingConfig = &DefaultResourceEncodingConfig{}
|
||||
|
||||
func NewDefaultResourceEncodingConfig(scheme *runtime.Scheme) *DefaultResourceEncodingConfig {
|
||||
return &DefaultResourceEncodingConfig{groups: map[string]*GroupResourceEncodingConfig{}, scheme: scheme}
|
||||
}
|
||||
|
||||
func newGroupResourceEncodingConfig(defaultEncoding, defaultInternalVersion schema.GroupVersion) *GroupResourceEncodingConfig {
|
||||
return &GroupResourceEncodingConfig{
|
||||
DefaultExternalEncoding: defaultEncoding, ExternalResourceEncodings: map[string]schema.GroupVersion{},
|
||||
DefaultInternalEncoding: defaultInternalVersion, InternalResourceEncodings: map[string]schema.GroupVersion{},
|
||||
}
|
||||
}
|
||||
|
||||
func (o *DefaultResourceEncodingConfig) SetVersionEncoding(group string, externalEncodingVersion, internalVersion schema.GroupVersion) {
|
||||
_, groupExists := o.groups[group]
|
||||
if !groupExists {
|
||||
o.groups[group] = newGroupResourceEncodingConfig(externalEncodingVersion, internalVersion)
|
||||
}
|
||||
|
||||
o.groups[group].DefaultExternalEncoding = externalEncodingVersion
|
||||
o.groups[group].DefaultInternalEncoding = internalVersion
|
||||
return &DefaultResourceEncodingConfig{resources: map[schema.GroupResource]*OverridingResourceEncoding{}, scheme: scheme}
|
||||
}
|
||||
|
||||
func (o *DefaultResourceEncodingConfig) SetResourceEncoding(resourceBeingStored schema.GroupResource, externalEncodingVersion, internalVersion schema.GroupVersion) {
|
||||
group := resourceBeingStored.Group
|
||||
_, groupExists := o.groups[group]
|
||||
if !groupExists {
|
||||
o.groups[group] = newGroupResourceEncodingConfig(externalEncodingVersion, internalVersion)
|
||||
o.resources[resourceBeingStored] = &OverridingResourceEncoding{
|
||||
ExternalResourceEncoding: externalEncodingVersion,
|
||||
InternalResourceEncoding: internalVersion,
|
||||
}
|
||||
|
||||
o.groups[group].ExternalResourceEncodings[resourceBeingStored.Resource] = externalEncodingVersion
|
||||
o.groups[group].InternalResourceEncodings[resourceBeingStored.Resource] = internalVersion
|
||||
}
|
||||
|
||||
func (o *DefaultResourceEncodingConfig) StorageEncodingFor(resource schema.GroupResource) (schema.GroupVersion, error) {
|
||||
|
|
@ -85,19 +62,13 @@ func (o *DefaultResourceEncodingConfig) StorageEncodingFor(resource schema.Group
|
|||
return schema.GroupVersion{}, fmt.Errorf("group %q is not registered in scheme", resource.Group)
|
||||
}
|
||||
|
||||
groupEncoding, groupExists := o.groups[resource.Group]
|
||||
|
||||
if !groupExists {
|
||||
// return the most preferred external version for the group
|
||||
return o.scheme.PrioritizedVersionsForGroup(resource.Group)[0], nil
|
||||
resourceOverride, resourceExists := o.resources[resource]
|
||||
if resourceExists {
|
||||
return resourceOverride.ExternalResourceEncoding, nil
|
||||
}
|
||||
|
||||
resourceOverride, resourceExists := groupEncoding.ExternalResourceEncodings[resource.Resource]
|
||||
if !resourceExists {
|
||||
return groupEncoding.DefaultExternalEncoding, nil
|
||||
}
|
||||
|
||||
return resourceOverride, nil
|
||||
// return the most preferred external version for the group
|
||||
return o.scheme.PrioritizedVersionsForGroup(resource.Group)[0], nil
|
||||
}
|
||||
|
||||
func (o *DefaultResourceEncodingConfig) InMemoryEncodingFor(resource schema.GroupResource) (schema.GroupVersion, error) {
|
||||
|
|
@ -105,15 +76,9 @@ func (o *DefaultResourceEncodingConfig) InMemoryEncodingFor(resource schema.Grou
|
|||
return schema.GroupVersion{}, fmt.Errorf("group %q is not registered in scheme", resource.Group)
|
||||
}
|
||||
|
||||
groupEncoding, groupExists := o.groups[resource.Group]
|
||||
if !groupExists {
|
||||
return schema.GroupVersion{Group: resource.Group, Version: runtime.APIVersionInternal}, nil
|
||||
resourceOverride, resourceExists := o.resources[resource]
|
||||
if resourceExists {
|
||||
return resourceOverride.InternalResourceEncoding, nil
|
||||
}
|
||||
|
||||
resourceOverride, resourceExists := groupEncoding.InternalResourceEncodings[resource.Resource]
|
||||
if !resourceExists {
|
||||
return groupEncoding.DefaultInternalEncoding, nil
|
||||
}
|
||||
|
||||
return resourceOverride, nil
|
||||
return schema.GroupVersion{Group: resource.Group, Version: runtime.APIVersionInternal}, nil
|
||||
}
|
||||
|
|
|
|||
34
vendor/k8s.io/apiserver/pkg/server/storage/storage_codec.go
generated
vendored
34
vendor/k8s.io/apiserver/pkg/server/storage/storage_codec.go
generated
vendored
|
|
@ -24,8 +24,6 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer/recognizer"
|
||||
"k8s.io/apiserver/pkg/storage/storagebackend"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
// StorageCodecConfig are the arguments passed to newStorageCodecFn
|
||||
|
|
@ -42,29 +40,19 @@ type StorageCodecConfig struct {
|
|||
|
||||
// NewStorageCodec assembles a storage codec for the provided storage media type, the provided serializer, and the requested
|
||||
// storage and memory versions.
|
||||
func NewStorageCodec(opts StorageCodecConfig) (runtime.Codec, error) {
|
||||
func NewStorageCodec(opts StorageCodecConfig) (runtime.Codec, runtime.GroupVersioner, error) {
|
||||
mediaType, _, err := mime.ParseMediaType(opts.StorageMediaType)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%q is not a valid mime-type", opts.StorageMediaType)
|
||||
}
|
||||
|
||||
if opts.Config.Type == storagebackend.StorageTypeETCD2 && mediaType != "application/json" {
|
||||
glog.Warningf(`storage type %q does not support media type %q, using "application/json"`, storagebackend.StorageTypeETCD2, mediaType)
|
||||
mediaType = "application/json"
|
||||
return nil, nil, fmt.Errorf("%q is not a valid mime-type", opts.StorageMediaType)
|
||||
}
|
||||
|
||||
serializer, ok := runtime.SerializerInfoForMediaType(opts.StorageSerializer.SupportedMediaTypes(), mediaType)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unable to find serializer for %q", mediaType)
|
||||
return nil, nil, fmt.Errorf("unable to find serializer for %q", mediaType)
|
||||
}
|
||||
|
||||
s := serializer.Serializer
|
||||
|
||||
// make sure the selected encoder supports string data
|
||||
if !serializer.EncodesAsText && opts.Config.Type == storagebackend.StorageTypeETCD2 {
|
||||
return nil, fmt.Errorf("storage type %q does not support binary media type %q", storagebackend.StorageTypeETCD2, mediaType)
|
||||
}
|
||||
|
||||
// Give callers the opportunity to wrap encoders and decoders. For decoders, each returned decoder will
|
||||
// be passed to the recognizer so that multiple decoders are available.
|
||||
var encoder runtime.Encoder = s
|
||||
|
|
@ -86,23 +74,25 @@ func NewStorageCodec(opts StorageCodecConfig) (runtime.Codec, error) {
|
|||
decoders = opts.DecoderDecoratorFn(decoders)
|
||||
}
|
||||
|
||||
encodeVersioner := runtime.NewMultiGroupVersioner(
|
||||
opts.StorageVersion,
|
||||
schema.GroupKind{Group: opts.StorageVersion.Group},
|
||||
schema.GroupKind{Group: opts.MemoryVersion.Group},
|
||||
)
|
||||
|
||||
// Ensure the storage receives the correct version.
|
||||
encoder = opts.StorageSerializer.EncoderForVersion(
|
||||
encoder,
|
||||
runtime.NewMultiGroupVersioner(
|
||||
opts.StorageVersion,
|
||||
schema.GroupKind{Group: opts.StorageVersion.Group},
|
||||
schema.GroupKind{Group: opts.MemoryVersion.Group},
|
||||
),
|
||||
encodeVersioner,
|
||||
)
|
||||
decoder := opts.StorageSerializer.DecoderToVersion(
|
||||
recognizer.NewDecoder(decoders...),
|
||||
runtime.NewMultiGroupVersioner(
|
||||
runtime.NewCoercingMultiGroupVersioner(
|
||||
opts.MemoryVersion,
|
||||
schema.GroupKind{Group: opts.MemoryVersion.Group},
|
||||
schema.GroupKind{Group: opts.StorageVersion.Group},
|
||||
),
|
||||
)
|
||||
|
||||
return runtime.NewCodec(encoder, decoder), nil
|
||||
return runtime.NewCodec(encoder, decoder), encodeVersioner, nil
|
||||
}
|
||||
|
|
|
|||
24
vendor/k8s.io/apiserver/pkg/server/storage/storage_factory.go
generated
vendored
24
vendor/k8s.io/apiserver/pkg/server/storage/storage_factory.go
generated
vendored
|
|
@ -22,7 +22,7 @@ import (
|
|||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
|
@ -86,7 +86,7 @@ type DefaultStorageFactory struct {
|
|||
APIResourceConfigSource APIResourceConfigSource
|
||||
|
||||
// newStorageCodecFn exists to be overwritten for unit testing.
|
||||
newStorageCodecFn func(opts StorageCodecConfig) (codec runtime.Codec, err error)
|
||||
newStorageCodecFn func(opts StorageCodecConfig) (codec runtime.Codec, encodeVersioner runtime.GroupVersioner, err error)
|
||||
}
|
||||
|
||||
type groupResourceOverrides struct {
|
||||
|
|
@ -121,7 +121,7 @@ type groupResourceOverrides struct {
|
|||
// Apply overrides the provided config and options if the override has a value in that position
|
||||
func (o groupResourceOverrides) Apply(config *storagebackend.Config, options *StorageCodecConfig) {
|
||||
if len(o.etcdLocation) > 0 {
|
||||
config.ServerList = o.etcdLocation
|
||||
config.Transport.ServerList = o.etcdLocation
|
||||
}
|
||||
if len(o.etcdPrefix) > 0 {
|
||||
config.Prefix = o.etcdPrefix
|
||||
|
|
@ -278,11 +278,11 @@ func (s *DefaultStorageFactory) NewConfig(groupResource schema.GroupResource) (*
|
|||
}
|
||||
codecConfig.Config = storageConfig
|
||||
|
||||
storageConfig.Codec, err = s.newStorageCodecFn(codecConfig)
|
||||
storageConfig.Codec, storageConfig.EncodeVersioner, err = s.newStorageCodecFn(codecConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
glog.V(3).Infof("storing %v in %v, reading as %v from %#v", groupResource, codecConfig.StorageVersion, codecConfig.MemoryVersion, codecConfig.Config)
|
||||
klog.V(3).Infof("storing %v in %v, reading as %v from %#v", groupResource, codecConfig.StorageVersion, codecConfig.MemoryVersion, codecConfig.Config)
|
||||
|
||||
return &storageConfig, nil
|
||||
}
|
||||
|
|
@ -290,7 +290,7 @@ func (s *DefaultStorageFactory) NewConfig(groupResource schema.GroupResource) (*
|
|||
// Backends returns all backends for all registered storage destinations.
|
||||
// Used for getting all instances for health validations.
|
||||
func (s *DefaultStorageFactory) Backends() []Backend {
|
||||
servers := sets.NewString(s.StorageConfig.ServerList...)
|
||||
servers := sets.NewString(s.StorageConfig.Transport.ServerList...)
|
||||
|
||||
for _, overrides := range s.Overrides {
|
||||
servers.Insert(overrides.etcdLocation...)
|
||||
|
|
@ -299,17 +299,17 @@ func (s *DefaultStorageFactory) Backends() []Backend {
|
|||
tlsConfig := &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
if len(s.StorageConfig.CertFile) > 0 && len(s.StorageConfig.KeyFile) > 0 {
|
||||
cert, err := tls.LoadX509KeyPair(s.StorageConfig.CertFile, s.StorageConfig.KeyFile)
|
||||
if len(s.StorageConfig.Transport.CertFile) > 0 && len(s.StorageConfig.Transport.KeyFile) > 0 {
|
||||
cert, err := tls.LoadX509KeyPair(s.StorageConfig.Transport.CertFile, s.StorageConfig.Transport.KeyFile)
|
||||
if err != nil {
|
||||
glog.Errorf("failed to load key pair while getting backends: %s", err)
|
||||
klog.Errorf("failed to load key pair while getting backends: %s", err)
|
||||
} else {
|
||||
tlsConfig.Certificates = []tls.Certificate{cert}
|
||||
}
|
||||
}
|
||||
if len(s.StorageConfig.CAFile) > 0 {
|
||||
if caCert, err := ioutil.ReadFile(s.StorageConfig.CAFile); err != nil {
|
||||
glog.Errorf("failed to read ca file while getting backends: %s", err)
|
||||
if len(s.StorageConfig.Transport.CAFile) > 0 {
|
||||
if caCert, err := ioutil.ReadFile(s.StorageConfig.Transport.CAFile); err != nil {
|
||||
klog.Errorf("failed to read ca file while getting backends: %s", err)
|
||||
} else {
|
||||
caPool := x509.NewCertPool()
|
||||
caPool.AppendCertsFromPEM(caCert)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue