Skip to content
This repository was archived by the owner on Jan 12, 2023. It is now read-only.

Commit 05a1030

Browse files
committed
Remove metrics for cli-tool
1 parent e06807a commit 05a1030

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

server/check.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99

1010
log "github.com/sirupsen/logrus"
11-
v1 "k8s.io/api/admission/v1"
11+
admissionv1 "k8s.io/api/admission/v1"
1212
)
1313

1414
func Check() {
@@ -28,8 +28,6 @@ func Check() {
2828
log.Fatal(err)
2929
}
3030

31-
registerMetrics()
32-
3331
loadedPlugins, err := loadPlugins(pluginsPathGlob, cfg)
3432
if err != nil {
3533
log.Fatal(err)
@@ -51,7 +49,7 @@ func Check() {
5149

5250
allowed := true
5351

54-
results := make(map[string][]v1.AdmissionReview)
52+
results := make(map[string][]admissionv1.AdmissionReview)
5553

5654
if stat.IsDir() {
5755
err := filepath.Walk(inputFile, func(path string, info fs.FileInfo, err error) error {

server/server.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ import (
2929
"github.com/cruise-automation/k-rail/v3/policies"
3030
"github.com/gertd/go-pluralize"
3131
"github.com/gorilla/mux"
32+
"github.com/prometheus/client_golang/prometheus"
3233
log "github.com/sirupsen/logrus"
3334
admissionv1 "k8s.io/api/admission/v1"
3435
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3536
"k8s.io/apimachinery/pkg/runtime"
3637
"k8s.io/apimachinery/pkg/util/json"
3738
"k8s.io/apimachinery/pkg/util/yaml"
3839

39-
"github.com/prometheus/client_golang/prometheus"
4040
"github.com/prometheus/client_golang/prometheus/promhttp"
4141
"github.com/slok/go-http-metrics/middleware/std"
4242
)
@@ -75,7 +75,9 @@ func Run(ctx context.Context) {
7575
log.Fatal(err)
7676
}
7777

78-
registerMetrics()
78+
prometheus.MustRegister(totalRegisteredPolicies)
79+
prometheus.MustRegister(policyViolations)
80+
prometheus.MustRegister(totalLoadedPlugins)
7981

8082
loadedPlugins, err := loadPlugins(pluginsPathGlob, cfg)
8183
if err != nil {
@@ -143,12 +145,6 @@ func Run(ctx context.Context) {
143145
log.Fatal(s.ListenAndServeTLS(cfg.TLS.Cert, cfg.TLS.Key))
144146
}
145147

146-
func registerMetrics() {
147-
prometheus.MustRegister(totalRegisteredPolicies)
148-
prometheus.MustRegister(policyViolations)
149-
prometheus.MustRegister(totalLoadedPlugins)
150-
}
151-
152148
func parseFlags() (string, string, string) {
153149
configPath := flag.String("config", "config.yml", "path to configuration file")
154150
exemptionsPathGlob := flag.String("exemptions-path-glob", "", "path glob that includes exemption configs")

0 commit comments

Comments
 (0)