Provisioning: Add metrics for repo controller (#111450)

This commit is contained in:
Stephanie Hingtgen
2025-09-22 20:14:03 +00:00
committed by GitHub
parent a2d09490ae
commit 8b1caccc72
17 changed files with 187 additions and 66 deletions
+1 -1
View File
@@ -11,7 +11,6 @@ require (
github.com/grafana/grafana/pkg/apimachinery v0.0.0-20250804150913-990f1c69ecc2
github.com/grafana/nanogit v0.0.0-20250723104447-68f58f5ecec0
github.com/migueleliasweb/go-github-mock v1.1.0
github.com/prometheus/client_golang v1.23.2
github.com/stretchr/testify v1.11.1
golang.org/x/oauth2 v0.30.0
k8s.io/apimachinery v0.34.1
@@ -54,6 +53,7 @@ require (
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
+3 -6
View File
@@ -7,20 +7,17 @@ import (
provisioning "github.com/grafana/grafana/apps/provisioning/pkg/apis/provisioning/v0alpha1"
client "github.com/grafana/grafana/apps/provisioning/pkg/generated/clientset/versioned/typed/provisioning/v0alpha1"
"github.com/prometheus/client_golang/prometheus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)
type RepositoryStatusPatcher struct {
client client.ProvisioningV0alpha1Interface
registry prometheus.Registerer
client client.ProvisioningV0alpha1Interface
}
func NewRepositoryStatusPatcher(client client.ProvisioningV0alpha1Interface, registry prometheus.Registerer) *RepositoryStatusPatcher {
func NewRepositoryStatusPatcher(client client.ProvisioningV0alpha1Interface) *RepositoryStatusPatcher {
return &RepositoryStatusPatcher{
client: client,
registry: registry,
client: client,
}
}
@@ -8,7 +8,6 @@ import (
provisioning "github.com/grafana/grafana/apps/provisioning/pkg/apis/provisioning/v0alpha1"
"github.com/grafana/grafana/apps/provisioning/pkg/generated/clientset/versioned/typed/provisioning/v0alpha1/fake"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
@@ -17,7 +16,7 @@ import (
func TestNewRepositoryStatusPatcher(t *testing.T) {
client := &fake.FakeProvisioningV0alpha1{}
patcher := NewRepositoryStatusPatcher(client, prometheus.DefaultRegisterer)
patcher := NewRepositoryStatusPatcher(client)
require.NotNil(t, patcher)
require.Equal(t, client, patcher.client)
}
@@ -104,7 +103,7 @@ func TestRepositoryStatusPatcher_Patch(t *testing.T) {
client.AddReactor("patch", "repositories", tt.reactorFunc)
}
patcher := NewRepositoryStatusPatcher(&client, prometheus.DefaultRegisterer)
patcher := NewRepositoryStatusPatcher(&client)
err := patcher.Patch(context.Background(), tt.repo, tt.patchOperations...)
if tt.expectedError != "" {