From b7bdeef490b4cac92b2cb237ee8826c10e48fecb Mon Sep 17 00:00:00 2001 From: grzegorz-ciezkowski Date: Fri, 7 Feb 2025 11:38:02 +0100 Subject: [PATCH] feat(plugins) Add helm diff to status (#858) --- charts/manager/crds/greenhouse.sap_plugins.yaml | 4 ++++ e2e/plugin/e2e_test.go | 8 ++++++++ pkg/apis/greenhouse/v1alpha1/plugin_types.go | 2 ++ pkg/controllers/plugin/plugin_controller.go | 1 + 4 files changed, 15 insertions(+) diff --git a/charts/manager/crds/greenhouse.sap_plugins.yaml b/charts/manager/crds/greenhouse.sap_plugins.yaml index f58f9a1c5..e12c835e2 100644 --- a/charts/manager/crds/greenhouse.sap_plugins.yaml +++ b/charts/manager/crds/greenhouse.sap_plugins.yaml @@ -185,6 +185,10 @@ spec: HelmReleaseStatus reflects the status of the latest HelmChart release. This is only configured if the pluginDefinition is backed by HelmChart. properties: + diff: + description: Diff contains the difference between the deployed + helm chart and the helm chart in the last reconciliation + type: string firstDeployed: description: FirstDeployed is the timestamp of the first deployment of the release. diff --git a/e2e/plugin/e2e_test.go b/e2e/plugin/e2e_test.go index c80e4dcb2..ac1f4062e 100644 --- a/e2e/plugin/e2e_test.go +++ b/e2e/plugin/e2e_test.go @@ -140,6 +140,14 @@ var _ = Describe("Plugin E2E", Ordered, func() { g.Expect(err).NotTo(HaveOccurred()) }).Should(Succeed()) + By("Check the diff status") + Eventually(func(g Gomega) { + err = adminClient.Get(ctx, client.ObjectKey{Name: testPlugin.Name, Namespace: env.TestNamespace}, testPlugin) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(testPlugin.Status.HelmReleaseStatus).ToNot(BeNil()) + g.Expect(len(testPlugin.Status.HelmReleaseStatus.Diff) > 0).To(BeTrue()) + }).Should(Succeed()) + By("Check replicas in deployment list") Eventually(func(g Gomega) { err = remoteClient.List(ctx, deploymentList, client.InNamespace(env.TestNamespace)) diff --git a/pkg/apis/greenhouse/v1alpha1/plugin_types.go b/pkg/apis/greenhouse/v1alpha1/plugin_types.go index 3a38e8cc7..5b27053cd 100644 --- a/pkg/apis/greenhouse/v1alpha1/plugin_types.go +++ b/pkg/apis/greenhouse/v1alpha1/plugin_types.go @@ -128,6 +128,8 @@ type HelmReleaseStatus struct { LastDeployed metav1.Time `json:"lastDeployed,omitempty"` // PluginOptionChecksum is the checksum of plugin option values. PluginOptionChecksum string `json:"pluginOptionChecksum,omitempty"` + // Diff contains the difference between the deployed helm chart and the helm chart in the last reconciliation + Diff string `json:"diff,omitempty"` } //+kubebuilder:object:root=true diff --git a/pkg/controllers/plugin/plugin_controller.go b/pkg/controllers/plugin/plugin_controller.go index a4aa64144..a22005cb8 100644 --- a/pkg/controllers/plugin/plugin_controller.go +++ b/pkg/controllers/plugin/plugin_controller.go @@ -303,6 +303,7 @@ func (r *PluginReconciler) reconcileStatus(ctx context.Context, Status: "unknown", FirstDeployed: metav1.Time{}, LastDeployed: metav1.Time{}, + Diff: pluginStatus.HelmReleaseStatus.Diff, } )