mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-07 10:17:51 +00:00
Add vendor folder to git
This commit is contained in:
parent
66cf5eaafb
commit
183585f56f
6916 changed files with 2629581 additions and 1 deletions
77
vendor/github.com/directxman12/custom-metrics-boilerplate/pkg/provider/interfaces.go
generated
vendored
Normal file
77
vendor/github.com/directxman12/custom-metrics-boilerplate/pkg/provider/interfaces.go
generated
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
Copyright 2017 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package provider
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/metrics/pkg/apis/custom_metrics"
|
||||
)
|
||||
|
||||
// MetricInfo describes a metric for a particular
|
||||
// fully-qualified group resource.
|
||||
type MetricInfo struct {
|
||||
GroupResource schema.GroupResource
|
||||
Namespaced bool
|
||||
Metric string
|
||||
}
|
||||
|
||||
func (i MetricInfo) String() string {
|
||||
if i.Namespaced {
|
||||
return fmt.Sprintf("%s/%s(namespaced)", i.GroupResource.String(), i.Metric)
|
||||
} else {
|
||||
return fmt.Sprintf("%s/%s", i.GroupResource.String(), i.Metric)
|
||||
}
|
||||
}
|
||||
|
||||
// CustomMetricsProvider is a soruce of custom metrics
|
||||
// which is able to supply a list of available metrics,
|
||||
// as well as metric values themselves on demand.
|
||||
//
|
||||
// Note that group-resources are provided as GroupResources,
|
||||
// not GroupKinds. This is to allow flexibility on the part
|
||||
// of the implementor: implementors do not necessarily need
|
||||
// to be aware of all existing kinds and their corresponding
|
||||
// REST mappings in order to perform queries.
|
||||
//
|
||||
// For queries that use label selectors, it is up to the
|
||||
// implementor to decide how to make use of the label selector --
|
||||
// they may wish to query the main Kubernetes API server, or may
|
||||
// wish to simply make use of stored information in their TSDB.
|
||||
type CustomMetricsProvider interface {
|
||||
// GetRootScopedMetricByName fetches a particular metric for a particular root-scoped object.
|
||||
GetRootScopedMetricByName(groupResource schema.GroupResource, name string, metricName string) (*custom_metrics.MetricValue, error)
|
||||
|
||||
// GetRootScopedMetricByName fetches a particular metric for a set of root-scoped objects
|
||||
// matching the given label selector.
|
||||
GetRootScopedMetricBySelector(groupResource schema.GroupResource, selector labels.Selector, metricName string) (*custom_metrics.MetricValueList, error)
|
||||
|
||||
// GetNamespacedMetricByName fetches a particular metric for a particular namespaced object.
|
||||
GetNamespacedMetricByName(groupResource schema.GroupResource, namespace string, name string, metricName string) (*custom_metrics.MetricValue, error)
|
||||
|
||||
// GetNamespacedMetricByName fetches a particular metric for a set of namespaced objects
|
||||
// matching the given label selector.
|
||||
GetNamespacedMetricBySelector(groupResource schema.GroupResource, namespace string, selector labels.Selector, metricName string) (*custom_metrics.MetricValueList, error)
|
||||
|
||||
// ListAllMetrics provides a list of all available metrics at
|
||||
// the current time. Note that this is not allowed to return
|
||||
// an error, so it is reccomended that implementors cache and
|
||||
// periodically update this list, instead of querying every time.
|
||||
ListAllMetrics() []MetricInfo
|
||||
}
|
||||
48
vendor/github.com/directxman12/custom-metrics-boilerplate/pkg/provider/resource_lister.go
generated
vendored
Normal file
48
vendor/github.com/directxman12/custom-metrics-boilerplate/pkg/provider/resource_lister.go
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
Copyright 2017 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package provider
|
||||
|
||||
import (
|
||||
"k8s.io/apiserver/pkg/endpoints/discovery"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
type customMetricsResourceLister struct {
|
||||
provider CustomMetricsProvider
|
||||
}
|
||||
|
||||
func NewResourceLister(provider CustomMetricsProvider) discovery.APIResourceLister {
|
||||
return &customMetricsResourceLister{
|
||||
provider: provider,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *customMetricsResourceLister) ListAPIResources() []metav1.APIResource {
|
||||
metrics := l.provider.ListAllMetrics()
|
||||
resources := make([]metav1.APIResource, len(metrics))
|
||||
|
||||
for i, metric := range metrics {
|
||||
resources[i] = metav1.APIResource{
|
||||
Name: metric.GroupResource.String()+"/"+metric.Metric,
|
||||
Namespaced: metric.Namespaced,
|
||||
Kind: "MetricValueList",
|
||||
Verbs: metav1.Verbs{"get"}, // TODO: support "watch"
|
||||
}
|
||||
}
|
||||
|
||||
return resources
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue