Skip to content

Commit ca042a2

Browse files
committed
Fix scorecard tests
1 parent 1321611 commit ca042a2

6 files changed

+87
-2
lines changed

apis/v1alpha1/targetallocator_types.go

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ func init() {
2929
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
3030
// +kubebuilder:printcolumn:name="Image",type="string",JSONPath=".status.image"
3131
// +kubebuilder:printcolumn:name="Management",type="string",JSONPath=".spec.managementState",description="Management State"
32+
// +operator-sdk:csv:customresourcedefinitions:displayName="Target Allocator"
33+
// +operator-sdk:csv:customresourcedefinitions:resources={{Pod,v1},{Deployment,apps/v1},{ConfigMaps,v1},{Service,v1},{ServiceAccount,v1},{PodDisruptionBudget,policy/v1}}
3234

3335
// TargetAllocator is the Schema for the targetallocators API.
3436
type TargetAllocator struct {

bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml

+20-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ metadata:
9999
categories: Logging & Tracing,Monitoring
100100
certified: "false"
101101
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
102-
createdAt: "2024-11-06T12:57:19Z"
102+
createdAt: "2024-11-07T11:16:11Z"
103103
description: Provides the OpenTelemetry components, including the Collector
104104
operators.operatorframework.io/builder: operator-sdk-v1.29.0
105105
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
@@ -245,6 +245,25 @@ spec:
245245
displayName: Target Allocator
246246
kind: TargetAllocator
247247
name: targetallocators.opentelemetry.io
248+
resources:
249+
- kind: ConfigMaps
250+
name: ""
251+
version: v1
252+
- kind: Deployment
253+
name: ""
254+
version: apps/v1
255+
- kind: Pod
256+
name: ""
257+
version: v1
258+
- kind: PodDisruptionBudget
259+
name: ""
260+
version: policy/v1
261+
- kind: Service
262+
name: ""
263+
version: v1
264+
- kind: ServiceAccount
265+
name: ""
266+
version: v1
248267
specDescriptors:
249268
- description: ObservabilitySpec defines how telemetry data gets handled.
250269
displayName: Observability

bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml

+20-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ metadata:
9999
categories: Logging & Tracing,Monitoring
100100
certified: "false"
101101
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
102-
createdAt: "2024-11-06T12:57:20Z"
102+
createdAt: "2024-11-07T11:16:11Z"
103103
description: Provides the OpenTelemetry components, including the Collector
104104
operators.operatorframework.io/builder: operator-sdk-v1.29.0
105105
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
@@ -245,6 +245,25 @@ spec:
245245
displayName: Target Allocator
246246
kind: TargetAllocator
247247
name: targetallocators.opentelemetry.io
248+
resources:
249+
- kind: ConfigMaps
250+
name: ""
251+
version: v1
252+
- kind: Deployment
253+
name: ""
254+
version: apps/v1
255+
- kind: Pod
256+
name: ""
257+
version: v1
258+
- kind: PodDisruptionBudget
259+
name: ""
260+
version: policy/v1
261+
- kind: Service
262+
name: ""
263+
version: v1
264+
- kind: ServiceAccount
265+
name: ""
266+
version: v1
248267
specDescriptors:
249268
- description: ObservabilitySpec defines how telemetry data gets handled.
250269
displayName: Observability

config/manifests/community/bases/opentelemetry-operator.clusterserviceversion.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,25 @@ spec:
157157
displayName: Target Allocator
158158
kind: TargetAllocator
159159
name: targetallocators.opentelemetry.io
160+
resources:
161+
- kind: ConfigMaps
162+
name: ""
163+
version: v1
164+
- kind: Deployment
165+
name: ""
166+
version: apps/v1
167+
- kind: Pod
168+
name: ""
169+
version: v1
170+
- kind: PodDisruptionBudget
171+
name: ""
172+
version: policy/v1
173+
- kind: Service
174+
name: ""
175+
version: v1
176+
- kind: ServiceAccount
177+
name: ""
178+
version: v1
160179
specDescriptors:
161180
- description: ObservabilitySpec defines how telemetry data gets handled.
162181
displayName: Observability

config/manifests/openshift/bases/opentelemetry-operator.clusterserviceversion.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,25 @@ spec:
157157
displayName: Target Allocator
158158
kind: TargetAllocator
159159
name: targetallocators.opentelemetry.io
160+
resources:
161+
- kind: ConfigMaps
162+
name: ""
163+
version: v1
164+
- kind: Deployment
165+
name: ""
166+
version: apps/v1
167+
- kind: Pod
168+
name: ""
169+
version: v1
170+
- kind: PodDisruptionBudget
171+
name: ""
172+
version: policy/v1
173+
- kind: Service
174+
name: ""
175+
version: v1
176+
- kind: ServiceAccount
177+
name: ""
178+
version: v1
160179
specDescriptors:
161180
- description: ObservabilitySpec defines how telemetry data gets handled.
162181
displayName: Observability

controllers/targetallocator_controller.go

+7
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,14 @@ func (r *TargetAllocatorReconciler) getParams(ctx context.Context, instance v1al
8282
return p, nil
8383
}
8484

85+
// getCollector finds the OpenTelemetryCollector for the given TargetAllocator. We have the following possibilities:
86+
// - Collector is the owner of the TargetAllocator
87+
// - Collector is annotated with the TargetAllocator's name
88+
// - No collector
8589
func (r *TargetAllocatorReconciler) getCollector(ctx context.Context, instance v1alpha1.TargetAllocator) (*v1beta1.OpenTelemetryCollector, error) {
8690
var collector v1beta1.OpenTelemetryCollector
91+
92+
// check if a collactor is the owner of this Target Allocator
8793
ownerReferences := instance.GetOwnerReferences()
8894
collectorIndex := slices.IndexFunc(ownerReferences, func(reference metav1.OwnerReference) bool {
8995
return reference.Kind == "OpenTelemetryCollector"
@@ -99,6 +105,7 @@ func (r *TargetAllocatorReconciler) getCollector(ctx context.Context, instance v
99105
return &collector, nil
100106
}
101107

108+
// check if there are Collectors annotated with this Target Allocator's name
102109
var collectors v1beta1.OpenTelemetryCollectorList
103110
listOpts := []client.ListOption{
104111
client.InNamespace(instance.GetNamespace()),

0 commit comments

Comments
 (0)