Skip to content

Commit a4317aa

Browse files
committed
refactor: pass context to GetOCMComponentsWithVersions and update logging
1 parent 011515a commit a4317aa

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

internal/controller/releasechannel_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (r *ReleaseChannelReconciler) Reconcile(ctx context.Context, req ctrl.Reque
9393
}, fmt.Errorf("either 'OcmRegistryUrl' or 'OcmRegistrySecretRef & OcmRegistrySecretKey' must be set")
9494
}
9595

96-
components, err := ocm.GetOCMComponentsWithVersions(repo, componentNames, releasechannel.Spec.PrefixFilter)
96+
components, err := ocm.GetOCMComponentsWithVersions(ctx, repo, componentNames, releasechannel.Spec.PrefixFilter)
9797
if err != nil {
9898
log.Error(err, "unable to get components from OCM")
9999
return ctrl.Result{

internal/ocm/ocm.go

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

10-
"log"
11-
1210
corev1 "k8s.io/api/core/v1"
1311
"ocm.software/ocm/api/ocm"
1412
"ocm.software/ocm/api/ocm/extensions/accessmethods/helm"
@@ -19,6 +17,7 @@ import (
1917
"ocm.software/ocm/api/tech/oci/identity"
2018
"ocm.software/ocm/api/utils/accessobj"
2119
"sigs.k8s.io/controller-runtime/pkg/client"
20+
"sigs.k8s.io/controller-runtime/pkg/log"
2221

2322
"github.com/openmcp-project/control-plane-operator/api/v1beta1"
2423
)
@@ -121,7 +120,9 @@ func GetOCMLocalRepo(ocmRegistry []byte, prefixFilter string) (ocm.Repository, [
121120
//
122121
// The prefixFilter must be specified as it will be cut off every componentName in the end
123122
// so the resulting Component names are without it.
124-
func GetOCMComponentsWithVersions(repo ocm.Repository, components []string, prefixFilter string) ([]v1beta1.Component, error) {
123+
func GetOCMComponentsWithVersions(ctx context.Context, repo ocm.Repository, components []string, prefixFilter string) ([]v1beta1.Component, error) {
124+
log := log.FromContext(ctx)
125+
125126
octx := ocm.DefaultContext()
126127

127128
var componentList = make([]v1beta1.Component, 0, len(components))
@@ -154,7 +155,7 @@ func GetOCMComponentsWithVersions(repo ocm.Repository, components []string, pref
154155

155156
resources := cva.GetResources()
156157
if len(resources) == 0 {
157-
log.Printf("Skipping component version %s of %s: no resources found\n", version, componentName)
158+
log.Info("Skipping component version %s of %s: no resources found\n", version, componentName)
158159
continue // We skip releasechannel component versions which dont have any resources
159160
}
160161

0 commit comments

Comments
 (0)