Skip to content

Commit d5ec2ec

Browse files
authored
feat(releasechannel): add releasechannel ignore label (#98)
* feat: add releasechannel ignore label * Update internal/ocm/ocm.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refactor: pass context to GetOCMComponentsWithVersions and update logging * chore: bump version to v0.1.11
1 parent 4c05652 commit d5ec2ec

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.1.10-dev
1+
v0.1.11

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: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"ocm.software/ocm/api/tech/oci/identity"
1818
"ocm.software/ocm/api/utils/accessobj"
1919
"sigs.k8s.io/controller-runtime/pkg/client"
20+
"sigs.k8s.io/controller-runtime/pkg/log"
2021

2122
"github.com/openmcp-project/control-plane-operator/api/v1beta1"
2223
)
@@ -119,7 +120,9 @@ func GetOCMLocalRepo(ocmRegistry []byte, prefixFilter string) (ocm.Repository, [
119120
//
120121
// The prefixFilter must be specified as it will be cut off every componentName in the end
121122
// so the resulting Component names are without it.
122-
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+
123126
octx := ocm.DefaultContext()
124127

125128
var componentList = make([]v1beta1.Component, 0, len(components))
@@ -134,13 +137,28 @@ func GetOCMComponentsWithVersions(repo ocm.Repository, components []string, pref
134137
Versions: make([]v1beta1.ComponentVersion, 0),
135138
}
136139

140+
outer:
137141
for _, version := range versions {
138142
cva, err := component.LookupVersion(version)
139143
if err != nil {
140144
return nil, err
141145
}
142146

147+
if len(cva.GetDescriptor().Labels) > 0 {
148+
for _, label := range cva.GetDescriptor().Labels {
149+
valStr := strings.Trim(string(label.Value), "\"")
150+
if (label.Name == "openmcp.cloud/ignore") && valStr == "true" {
151+
continue outer
152+
}
153+
}
154+
}
155+
143156
resources := cva.GetResources()
157+
if len(resources) == 0 {
158+
log.Info("Skipping component version %s of %s: no resources found\n", version, componentName)
159+
continue // We skip releasechannel component versions which dont have any resources
160+
}
161+
144162
access, err := resources[0].Access()
145163
if err != nil {
146164
return nil, err

0 commit comments

Comments
 (0)