@@ -127,15 +127,15 @@ type MetricPoint struct {
127
127
// Label stores information about identity of resources (UIDs) described by metric.
128
128
type Label map [types.ResourceKind ][]apimachinery.UID
129
129
130
- // AddMetricLabel returns a unique combined Label of self and other resource.
130
+ // AddMetricLabel returns a unique combined Label of in and other resource.
131
131
// New label describes both resources.
132
- func (self Label ) AddMetricLabel (other Label ) Label {
132
+ func (in Label ) AddMetricLabel (other Label ) Label {
133
133
if other == nil {
134
- return self
134
+ return in
135
135
}
136
136
137
137
uniqueMap := map [apimachinery.UID ]bool {}
138
- for _ , v := range self {
138
+ for _ , v := range in {
139
139
for _ , t := range v {
140
140
uniqueMap [t ] = true
141
141
}
@@ -144,11 +144,11 @@ func (self Label) AddMetricLabel(other Label) Label {
144
144
for k , v := range other {
145
145
for _ , t := range v {
146
146
if _ , exists := uniqueMap [t ]; ! exists {
147
- self [k ] = append (self [k ], t )
147
+ in [k ] = append (in [k ], t )
148
148
}
149
149
}
150
150
}
151
- return self
151
+ return in
152
152
}
153
153
154
154
// Metric is a format of data used in this module. This is also the format of data that is being sent by backend client.
@@ -190,18 +190,18 @@ func (metric *SidecarMetric) AddMetricPoint(item MetricPoint) []MetricPoint {
190
190
return metric .MetricPoints
191
191
}
192
192
193
- func (metric * Metric ) AddMetricPoint (item MetricPoint ) []MetricPoint {
194
- metric .MetricPoints = append (metric .MetricPoints , item )
195
- return metric .MetricPoints
193
+ func (in * Metric ) AddMetricPoint (item MetricPoint ) []MetricPoint {
194
+ in .MetricPoints = append (in .MetricPoints , item )
195
+ return in .MetricPoints
196
196
}
197
197
198
198
// String implements stringer interface to allow easy printing
199
- func (self Metric ) String () string {
200
- return "{\n DataPoints: " + fmt .Sprintf ("%v" , self .DataPoints ) +
201
- "\n MetricPoints: " + fmt .Sprintf ("%v" , self .MetricPoints ) +
202
- "\n MetricName: " + self .MetricName +
203
- "\n Label: " + fmt .Sprintf ("%v" , self .Label ) +
204
- "\n Aggregate: " + fmt .Sprintf ("%v" , self .Aggregate )
199
+ func (in Metric ) String () string {
200
+ return "{\n DataPoints: " + fmt .Sprintf ("%v" , in .DataPoints ) +
201
+ "\n MetricPoints: " + fmt .Sprintf ("%v" , in .MetricPoints ) +
202
+ "\n MetricName: " + in .MetricName +
203
+ "\n Label: " + fmt .Sprintf ("%v" , in .Label ) +
204
+ "\n Aggregate: " + fmt .Sprintf ("%v" , in .Aggregate )
205
205
}
206
206
207
207
// MetricPromise is used for parallel data extraction. Contains len 1 channels for Metric and Error.
@@ -211,12 +211,12 @@ type MetricPromise struct {
211
211
}
212
212
213
213
// GetMetric returns pointer to received Metrics and forwarded error (if any)
214
- func (self MetricPromise ) GetMetric () (* Metric , error ) {
215
- err := <- self .Error
214
+ func (in MetricPromise ) GetMetric () (* Metric , error ) {
215
+ err := <- in .Error
216
216
if err != nil {
217
217
return nil , err
218
218
}
219
- return <- self .Metric , nil
219
+ return <- in .Metric , nil
220
220
}
221
221
222
222
// NewMetricPromise creates a MetricPromise structure with both channels of length 1.
@@ -231,10 +231,10 @@ type MetricPromises []MetricPromise
231
231
232
232
// GetMetrics returns all metrics from MetricPromises.
233
233
// In case of no metrics were downloaded it does not initialise []Metric and returns nil.
234
- func (self MetricPromises ) GetMetrics () ([]Metric , error ) {
234
+ func (in MetricPromises ) GetMetrics () ([]Metric , error ) {
235
235
result := make ([]Metric , 0 )
236
236
237
- for _ , metricPromise := range self {
237
+ for _ , metricPromise := range in {
238
238
metric , err := metricPromise .GetMetric ()
239
239
if err != nil {
240
240
// Do not fail when cannot resolve one of the metrics promises and return what can be resolved.
@@ -252,8 +252,8 @@ func (self MetricPromises) GetMetrics() ([]Metric, error) {
252
252
}
253
253
254
254
// PutMetrics forwards provided list of metrics to all channels. If provided err is not nil, error will be forwarded.
255
- func (self MetricPromises ) PutMetrics (metrics []Metric , err error ) {
256
- for i , metricPromise := range self {
255
+ func (in MetricPromises ) PutMetrics (metrics []Metric , err error ) {
256
+ for i , metricPromise := range in {
257
257
if err != nil {
258
258
metricPromise .Metric <- nil
259
259
} else {
0 commit comments