Debian Codegraph @

pkg/apis/custom_metrics/types.go

raw
1 /*
2 Copyright 2017 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package custom_metrics
18
19 import (
20 "k8s.io/apimachinery/pkg/api/resource"
21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22 "k8s.io/apimachinery/pkg/types"
23 )
24
25 type MetricIdentifier struct {
26 // name is the name of the given metric
27 Name string
28 // selector represents the label selector that could be used to select
29 // this metric, and will generally just be the selector passed in to
30 // the query used to fetch this metric.
31 // +optional
32 Selector *metav1.LabelSelector
33 }
34
35 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
36
37 // a list of values for a given metric for some set of objects
38 type MetricValueList struct {
39 metav1.TypeMeta `json:",inline"`
40 metav1.ListMeta `json:"metadata,omitempty"`
41
42 // the value of the metric across the described objects
43 Items []MetricValue `json:"items"`
44 }
45
46 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
47
48 // a metric value for some object
49 type MetricValue struct {
50 metav1.TypeMeta
51
52 // a reference to the described object
53 DescribedObject ObjectReference
54
55 Metric MetricIdentifier
56
57 // indicates the time at which the metrics were produced
58 Timestamp metav1.Time
59
60 // indicates the window ([Timestamp-Window, Timestamp]) from
61 // which these metrics were calculated, when returning rate
62 // metrics calculated from cumulative metrics (or zero for
63 // non-calculated instantaneous metrics).
64 WindowSeconds *int64
65
66 // the value of the metric for this
67 Value resource.Quantity
68 }
69
70 // allObjects is a wildcard used to select metrics
71 // for all objects matching the given label selector
72 const AllObjects = "*"
73
74 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
75
76 // MetricListOptions is used to select metrics by their label selectors
77 type MetricListOptions struct {
78 metav1.TypeMeta
79
80 // A selector to restrict the list of returned objects by their labels.
81 // Defaults to everything.
82 // +optional
83 LabelSelector string
84
85 // A selector to restrict the list of returned metrics by their labels
86 // +optional
87 MetricLabelSelector string
88 }
89
90 // NOTE: ObjectReference is copied from k8s.io/kubernetes/pkg/api/types.go. We
91 // cannot depend on k8s.io/kubernetes/pkg/api because that creates cyclic
92 // dependency between k8s.io/metrics and k8s.io/kubernetes. We cannot depend on
93 // k8s.io/client-go/pkg/api because the package is going to be deprecated soon.
94 // There is no need to keep it an exact copy. Each repo can define its own
95 // internal objects.
96
97 // ObjectReference contains enough information to let you inspect or modify the referred object.
98 type ObjectReference struct {
99 Kind string
100 Namespace string
101 Name string
102 UID types.UID
103 APIVersion string
104 ResourceVersion string
105 FieldPath string
106 }