Skip to content

Commit

Permalink
Fix scorecard tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swiatekm committed Nov 7, 2024
1 parent 1321611 commit ca042a2
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 2 deletions.
2 changes: 2 additions & 0 deletions apis/v1alpha1/targetallocator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func init() {
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Image",type="string",JSONPath=".status.image"
// +kubebuilder:printcolumn:name="Management",type="string",JSONPath=".spec.managementState",description="Management State"
// +operator-sdk:csv:customresourcedefinitions:displayName="Target Allocator"
// +operator-sdk:csv:customresourcedefinitions:resources={{Pod,v1},{Deployment,apps/v1},{ConfigMaps,v1},{Service,v1},{ServiceAccount,v1},{PodDisruptionBudget,policy/v1}}

// TargetAllocator is the Schema for the targetallocators API.
type TargetAllocator struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ metadata:
categories: Logging & Tracing,Monitoring
certified: "false"
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
createdAt: "2024-11-06T12:57:19Z"
createdAt: "2024-11-07T11:16:11Z"
description: Provides the OpenTelemetry components, including the Collector
operators.operatorframework.io/builder: operator-sdk-v1.29.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down Expand Up @@ -245,6 +245,25 @@ spec:
displayName: Target Allocator
kind: TargetAllocator
name: targetallocators.opentelemetry.io
resources:
- kind: ConfigMaps
name: ""
version: v1
- kind: Deployment
name: ""
version: apps/v1
- kind: Pod
name: ""
version: v1
- kind: PodDisruptionBudget
name: ""
version: policy/v1
- kind: Service
name: ""
version: v1
- kind: ServiceAccount
name: ""
version: v1
specDescriptors:
- description: ObservabilitySpec defines how telemetry data gets handled.
displayName: Observability
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ metadata:
categories: Logging & Tracing,Monitoring
certified: "false"
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
createdAt: "2024-11-06T12:57:20Z"
createdAt: "2024-11-07T11:16:11Z"
description: Provides the OpenTelemetry components, including the Collector
operators.operatorframework.io/builder: operator-sdk-v1.29.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down Expand Up @@ -245,6 +245,25 @@ spec:
displayName: Target Allocator
kind: TargetAllocator
name: targetallocators.opentelemetry.io
resources:
- kind: ConfigMaps
name: ""
version: v1
- kind: Deployment
name: ""
version: apps/v1
- kind: Pod
name: ""
version: v1
- kind: PodDisruptionBudget
name: ""
version: policy/v1
- kind: Service
name: ""
version: v1
- kind: ServiceAccount
name: ""
version: v1
specDescriptors:
- description: ObservabilitySpec defines how telemetry data gets handled.
displayName: Observability
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,25 @@ spec:
displayName: Target Allocator
kind: TargetAllocator
name: targetallocators.opentelemetry.io
resources:
- kind: ConfigMaps
name: ""
version: v1
- kind: Deployment
name: ""
version: apps/v1
- kind: Pod
name: ""
version: v1
- kind: PodDisruptionBudget
name: ""
version: policy/v1
- kind: Service
name: ""
version: v1
- kind: ServiceAccount
name: ""
version: v1
specDescriptors:
- description: ObservabilitySpec defines how telemetry data gets handled.
displayName: Observability
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,25 @@ spec:
displayName: Target Allocator
kind: TargetAllocator
name: targetallocators.opentelemetry.io
resources:
- kind: ConfigMaps
name: ""
version: v1
- kind: Deployment
name: ""
version: apps/v1
- kind: Pod
name: ""
version: v1
- kind: PodDisruptionBudget
name: ""
version: policy/v1
- kind: Service
name: ""
version: v1
- kind: ServiceAccount
name: ""
version: v1
specDescriptors:
- description: ObservabilitySpec defines how telemetry data gets handled.
displayName: Observability
Expand Down
7 changes: 7 additions & 0 deletions controllers/targetallocator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ func (r *TargetAllocatorReconciler) getParams(ctx context.Context, instance v1al
return p, nil
}

// getCollector finds the OpenTelemetryCollector for the given TargetAllocator. We have the following possibilities:
// - Collector is the owner of the TargetAllocator
// - Collector is annotated with the TargetAllocator's name
// - No collector
func (r *TargetAllocatorReconciler) getCollector(ctx context.Context, instance v1alpha1.TargetAllocator) (*v1beta1.OpenTelemetryCollector, error) {
var collector v1beta1.OpenTelemetryCollector

// check if a collactor is the owner of this Target Allocator
ownerReferences := instance.GetOwnerReferences()
collectorIndex := slices.IndexFunc(ownerReferences, func(reference metav1.OwnerReference) bool {
return reference.Kind == "OpenTelemetryCollector"
Expand All @@ -99,6 +105,7 @@ func (r *TargetAllocatorReconciler) getCollector(ctx context.Context, instance v
return &collector, nil
}

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

0 comments on commit ca042a2

Please sign in to comment.