Skip to content

Commit d59447a

Browse files
committed
[chore] unexport OperatorMetrics
1 parent a36367b commit d59447a

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

internal/operator-metrics/metrics.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,26 @@ var (
5050
openshiftInClusterMonitoringNamespace = "openshift-monitoring"
5151
)
5252

53-
var _ manager.Runnable = &OperatorMetrics{}
53+
var _ manager.Runnable = operatorMetrics{}
5454

55-
type OperatorMetrics struct {
55+
type operatorMetrics struct {
5656
kubeClient client.Client
5757
log logr.Logger
5858
}
5959

60-
func NewOperatorMetrics(config *rest.Config, scheme *runtime.Scheme, log logr.Logger) (OperatorMetrics, error) {
60+
func NewOperatorMetrics(config *rest.Config, scheme *runtime.Scheme, log logr.Logger) (manager.Runnable, error) {
6161
kubeClient, err := client.New(config, client.Options{Scheme: scheme})
6262
if err != nil {
63-
return OperatorMetrics{}, err
63+
return operatorMetrics{}, err
6464
}
6565

66-
return OperatorMetrics{
66+
return operatorMetrics{
6767
kubeClient: kubeClient,
6868
log: log,
6969
}, nil
7070
}
7171

72-
func (om OperatorMetrics) Start(ctx context.Context) error {
72+
func (om operatorMetrics) Start(ctx context.Context) error {
7373
err := om.createOperatorMetricsServiceMonitor(ctx)
7474
if err != nil {
7575
om.log.Error(err, "error creating Service Monitor for operator metrics")
@@ -78,19 +78,19 @@ func (om OperatorMetrics) Start(ctx context.Context) error {
7878
return nil
7979
}
8080

81-
func (om OperatorMetrics) NeedLeaderElection() bool {
81+
func (om operatorMetrics) NeedLeaderElection() bool {
8282
return true
8383
}
8484

85-
func (om OperatorMetrics) caConfigMapExists() bool {
85+
func (om operatorMetrics) caConfigMapExists() bool {
8686
return om.kubeClient.Get(context.Background(), client.ObjectKey{
8787
Name: caBundleConfigMap,
8888
Namespace: openshiftInClusterMonitoringNamespace,
8989
}, &corev1.ConfigMap{},
9090
) == nil
9191
}
9292

93-
func (om OperatorMetrics) getOwnerReferences(ctx context.Context, namespace string) (metav1.OwnerReference, error) {
93+
func (om operatorMetrics) getOwnerReferences(ctx context.Context, namespace string) (metav1.OwnerReference, error) {
9494
var deploymentList appsv1.DeploymentList
9595

9696
listOptions := []client.ListOption{
@@ -121,7 +121,7 @@ func (om OperatorMetrics) getOwnerReferences(ctx context.Context, namespace stri
121121
return ownerRef, nil
122122
}
123123

124-
func (om OperatorMetrics) createOperatorMetricsServiceMonitor(ctx context.Context) error {
124+
func (om operatorMetrics) createOperatorMetricsServiceMonitor(ctx context.Context) error {
125125
rawNamespace, err := os.ReadFile(namespaceFile)
126126
if err != nil {
127127
return fmt.Errorf("error reading namespace file: %w", err)

internal/operator-metrics/metrics_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestOperatorMetrics_Start(t *testing.T) {
6767
},
6868
).Build()
6969

70-
metrics := OperatorMetrics{kubeClient: client}
70+
metrics := operatorMetrics{kubeClient: client}
7171

7272
ctx, cancel := context.WithCancel(context.Background())
7373
errChan := make(chan error)
@@ -105,7 +105,7 @@ func TestOperatorMetrics_Start(t *testing.T) {
105105
}
106106

107107
func TestOperatorMetrics_NeedLeaderElection(t *testing.T) {
108-
metrics := OperatorMetrics{}
108+
metrics := operatorMetrics{}
109109
assert.True(t, metrics.NeedLeaderElection())
110110
}
111111

@@ -123,13 +123,13 @@ func TestOperatorMetrics_caConfigMapExists(t *testing.T) {
123123
},
124124
).Build()
125125

126-
metrics := OperatorMetrics{kubeClient: client}
126+
metrics := operatorMetrics{kubeClient: client}
127127

128128
assert.True(t, metrics.caConfigMapExists())
129129

130130
// Test when the ConfigMap doesn't exist
131131
clientWithoutConfigMap := fake.NewClientBuilder().WithScheme(scheme).Build()
132-
metricsWithoutConfigMap := OperatorMetrics{kubeClient: clientWithoutConfigMap}
132+
metricsWithoutConfigMap := operatorMetrics{kubeClient: clientWithoutConfigMap}
133133
assert.False(t, metricsWithoutConfigMap.caConfigMapExists())
134134
}
135135

@@ -183,7 +183,7 @@ func TestOperatorMetrics_getOwnerReferences(t *testing.T) {
183183
WithObjects(tt.objects...).
184184
Build()
185185

186-
om := OperatorMetrics{
186+
om := operatorMetrics{
187187
kubeClient: fakeClient,
188188
log: logr.Discard(),
189189
}

0 commit comments

Comments
 (0)