From 201244b60c74b40096cbc1f44c864aba3363a921 Mon Sep 17 00:00:00 2001 From: everettraven Date: Thu, 11 Jan 2024 14:44:31 -0500 Subject: [PATCH] better early return conditional comment Signed-off-by: everettraven --- .../controllers/clusterextension_controller.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/controllers/clusterextension_controller.go b/internal/controllers/clusterextension_controller.go index 2c4cf69ed..0a0ac5233 100644 --- a/internal/controllers/clusterextension_controller.go +++ b/internal/controllers/clusterextension_controller.go @@ -306,11 +306,15 @@ func SetDeprecationStatus(ext *ocv1alpha1.ClusterExtension, bundle *catalogmetad }) } - // Even if the bundle is not deprecated, there may be channel - // deprecations associated with this bundle. If there are we need - // verify if it matches the channel specified in the ClusterExtension. - // if the bundle is not deprecated and there is no channel specified - // in the ClusterExtension there is no deprecations to be applied. + // There are two early return scenarios here: + // 1) The bundle is not deprecated (i.e no package or bundle deprecations) + // AND there are no other deprecations associated with the bundle + // 2) The bundle is not deprecated, there are deprecations associated + // with the bundle (i.e at least one channel the bundle is present in is deprecated), + // and the ClusterExtension does not specify a channel. This is because the channel deprecations + // are a loose deprecation coupling on the bundle. A ClusterExtension installation is only + // considered deprecated by a channel deprecation when a deprecated channel is specified via + // the spec.channel field. if (!bundle.IsDeprecated() && !bundle.HasDeprecation()) || (!bundle.IsDeprecated() && ext.Spec.Channel == "") { return }