From db4979532888bec64e5859a38aff4a3f920651a8 Mon Sep 17 00:00:00 2001 From: Zaggy21 Date: Tue, 16 Jun 2026 10:56:55 +0200 Subject: [PATCH 1/3] feat(pluginpresets): expose PluginDefinition version in PluginPreset status On-behalf-of: @SAP krzysztof.zagorski@sap.com Signed-off-by: Zaggy21 --- api/v1alpha1/pluginpreset_types.go | 3 +++ .../manager/crds/greenhouse.sap_pluginpresets.yaml | 7 +++++++ .../controller/plugin/pluginpreset_controller.go | 13 +++++++++++++ .../plugin/pluginpreset_controller_test.go | 1 + 4 files changed, 24 insertions(+) diff --git a/api/v1alpha1/pluginpreset_types.go b/api/v1alpha1/pluginpreset_types.go index 6bc515e00..b32b7e1db 100644 --- a/api/v1alpha1/pluginpreset_types.go +++ b/api/v1alpha1/pluginpreset_types.go @@ -137,6 +137,8 @@ type PluginPresetStatus struct { ReadyPlugins int `json:"readyPlugins,omitempty"` // FailedPlugins is the number of failed Plugins managed by the PluginPreset. FailedPlugins int `json:"failedPlugins,omitempty"` + // PluginDefinitionVersion is the version of the PluginDefinition referenced by this PluginPreset. + PluginDefinitionVersion string `json:"pluginDefinitionVersion,omitempty"` } // ManagedPluginStatus defines the Ready condition of a managed Plugin identified by its name. @@ -149,6 +151,7 @@ type ManagedPluginStatus struct { //+kubebuilder:subresource:status //+kubebuilder:resource:shortName=pp //+kubebuilder:printcolumn:name="Plugin Definition",type=string,JSONPath=`.spec.plugin.pluginDefinitionRef.name` +//+kubebuilder:printcolumn:name="Version",type=string,JSONPath=`.status.pluginDefinitionVersion` //+kubebuilder:printcolumn:name="Release Namespace",type=string,JSONPath=`.spec.plugin.releaseNamespace` //+kubebuilder:printcolumn:name="Ready",type="string",JSONPath=`.status.statusConditions.conditions[?(@.type == "Ready")].status` //+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" diff --git a/charts/manager/crds/greenhouse.sap_pluginpresets.yaml b/charts/manager/crds/greenhouse.sap_pluginpresets.yaml index bc9445a14..c5843ee03 100644 --- a/charts/manager/crds/greenhouse.sap_pluginpresets.yaml +++ b/charts/manager/crds/greenhouse.sap_pluginpresets.yaml @@ -23,6 +23,9 @@ spec: - jsonPath: .spec.plugin.pluginDefinitionRef.name name: Plugin Definition type: string + - jsonPath: .status.pluginDefinitionVersion + name: Version + type: string - jsonPath: .spec.plugin.releaseNamespace name: Release Namespace type: string @@ -498,6 +501,10 @@ spec: description: FailedPlugins is the number of failed Plugins managed by the PluginPreset. type: integer + pluginDefinitionVersion: + description: PluginDefinitionVersion is the version of the PluginDefinition + referenced by this PluginPreset. + type: string pluginStatuses: description: PluginStatuses contains statuses of Plugins managed by the PluginPreset. diff --git a/internal/controller/plugin/pluginpreset_controller.go b/internal/controller/plugin/pluginpreset_controller.go index 84c9a8579..552de6430 100644 --- a/internal/controller/plugin/pluginpreset_controller.go +++ b/internal/controller/plugin/pluginpreset_controller.go @@ -27,6 +27,7 @@ import ( greenhousemetav1alpha1 "github.com/cloudoperators/greenhouse/api/meta/v1alpha1" greenhousev1alpha1 "github.com/cloudoperators/greenhouse/api/v1alpha1" "github.com/cloudoperators/greenhouse/internal/clientutil" + "github.com/cloudoperators/greenhouse/internal/common" "github.com/cloudoperators/greenhouse/internal/util" "github.com/cloudoperators/greenhouse/pkg/lifecycle" ) @@ -126,6 +127,8 @@ func (r *PluginPresetReconciler) EnsureCreated(ctx context.Context, resource lif clusters = clientutil.FilterClustersBeingDeleted(clusters) + r.reconcilePluginDefinitionVersion(ctx, pluginPreset) + err = r.reconcilePluginPreset(ctx, pluginPreset, clusters) if err != nil { return ctrl.Result{}, lifecycle.Failed, err @@ -329,6 +332,16 @@ func (r *PluginPresetReconciler) reconcilePluginStatuses( return nil } +// reconcilePluginDefinitionVersion fetches the referenced PluginDefinition and updates the version in the preset's status. +func (r *PluginPresetReconciler) reconcilePluginDefinitionVersion(ctx context.Context, preset *greenhousev1alpha1.PluginPreset) { + pluginDefinitionSpec, err := common.GetPluginDefinitionSpec(ctx, r.Client, preset.Spec.Plugin.PluginDefinitionRef, preset.GetNamespace()) + if err != nil { + // Version is best-effort; errors are already surfaced via conditions. + return + } + preset.Status.PluginDefinitionVersion = pluginDefinitionSpec.Version +} + func isPluginManagedByPreset(plugin *greenhousev1alpha1.Plugin, presetName string) bool { return plugin.Labels[greenhouseapis.LabelKeyPluginPreset] == presetName } diff --git a/internal/controller/plugin/pluginpreset_controller_test.go b/internal/controller/plugin/pluginpreset_controller_test.go index 1cbaf0874..9ab55fbbd 100644 --- a/internal/controller/plugin/pluginpreset_controller_test.go +++ b/internal/controller/plugin/pluginpreset_controller_test.go @@ -435,6 +435,7 @@ var _ = Describe("PluginPreset Controller Lifecycle", Ordered, func() { g.Expect(managedPluginStatus.PluginName).To(Equal(expectedPluginName), "managed plugin status should have the correct PluginName set") // Note: ReadyCondition may not be true since Flux is not running, but Plugin should exist g.Expect(testPluginPreset.Status.TotalPlugins).To(Equal(1), "PluginPreset Status should show exactly one plugin in total") + g.Expect(testPluginPreset.Status.PluginDefinitionVersion).To(Equal(pluginPresetDefinition.Spec.Version), "PluginPreset status should expose the version of the referenced PluginDefinition") }).Should(Succeed()) By("verifying HelmRelease exists for the managed Plugin") From c17877b12e5db770b890d00366cbbea79a24140b Mon Sep 17 00:00:00 2001 From: "cloud-operator-bot[bot]" <224791424+cloud-operator-bot[bot]@users.noreply.github.com> Date: Tue, 16 Jun 2026 12:36:52 +0000 Subject: [PATCH 2/3] Automatic generation of CRD API Docs --- docs/reference/api/index.html | 11 +++++++++++ docs/reference/api/openapi.yaml | 3 +++ 2 files changed, 14 insertions(+) diff --git a/docs/reference/api/index.html b/docs/reference/api/index.html index 80e8e13b3..9ee57655c 100644 --- a/docs/reference/api/index.html +++ b/docs/reference/api/index.html @@ -3649,6 +3649,17 @@

PluginPresetStatus

FailedPlugins is the number of failed Plugins managed by the PluginPreset.

+ + +pluginDefinitionVersion
+ +string + + + +

PluginDefinitionVersion is the version of the PluginDefinition referenced by this PluginPreset.

+ + diff --git a/docs/reference/api/openapi.yaml b/docs/reference/api/openapi.yaml index 95a099a30..4ceb4992a 100755 --- a/docs/reference/api/openapi.yaml +++ b/docs/reference/api/openapi.yaml @@ -1504,6 +1504,9 @@ components: failedPlugins: description: FailedPlugins is the number of failed Plugins managed by the PluginPreset. type: integer + pluginDefinitionVersion: + description: PluginDefinitionVersion is the version of the PluginDefinition referenced by this PluginPreset. + type: string pluginStatuses: description: PluginStatuses contains statuses of Plugins managed by the PluginPreset. items: From 987fad6193e6ccb0c234252a4cde829e37a0d29f Mon Sep 17 00:00:00 2001 From: Krzysztof Zagorski Date: Tue, 16 Jun 2026 15:42:57 +0200 Subject: [PATCH 3/3] fix comment Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Krzysztof Zagorski --- internal/controller/plugin/pluginpreset_controller.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/controller/plugin/pluginpreset_controller.go b/internal/controller/plugin/pluginpreset_controller.go index 552de6430..9d1559c97 100644 --- a/internal/controller/plugin/pluginpreset_controller.go +++ b/internal/controller/plugin/pluginpreset_controller.go @@ -336,7 +336,8 @@ func (r *PluginPresetReconciler) reconcilePluginStatuses( func (r *PluginPresetReconciler) reconcilePluginDefinitionVersion(ctx context.Context, preset *greenhousev1alpha1.PluginPreset) { pluginDefinitionSpec, err := common.GetPluginDefinitionSpec(ctx, r.Client, preset.Spec.Plugin.PluginDefinitionRef, preset.GetNamespace()) if err != nil { - // Version is best-effort; errors are already surfaced via conditions. + // Best-effort: clear the field to avoid reporting a stale version when the referenced definition can't be resolved. + preset.Status.PluginDefinitionVersion = "" return } preset.Status.PluginDefinitionVersion = pluginDefinitionSpec.Version