Code refactoring for bpa operator
[icn.git] / cmd / bpa-operator / vendor / k8s.io / kube-state-metrics / pkg / collector / collector.go
1 /*
2 Copyright 2017 The Kubernetes Authors All rights reserved.
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 collector
18
19 import (
20         "io"
21 )
22
23 // Store represents a metrics store e.g.
24 // k8s.io/kube-state-metrics/pkg/metrics_store.
25 type Store interface {
26         WriteAll(io.Writer)
27 }
28
29 // Collector represents a kube-state-metrics metric collector. It is a stripped
30 // down version of the Prometheus client_golang collector.
31 type Collector struct {
32         Store Store
33 }
34
35 // NewCollector constructs a collector with the given Store.
36 func NewCollector(s Store) *Collector {
37         return &Collector{s}
38 }
39
40 // Collect returns all metrics of the underlying store of the collector.
41 func (c *Collector) Collect(w io.Writer) {
42         c.Store.WriteAll(w)
43 }