Skip to content

Commit

Permalink
[v2.8] add health message for helm
Browse files Browse the repository at this point in the history
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
  • Loading branch information
chanwit committed Sep 4, 2023
1 parent cbcacd4 commit 3b228e6
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 0 deletions.
130 changes: 130 additions & 0 deletions patches-argo-cd-v2.8/20-add-health-message-for-helm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
add health message for helm

From: Chanwit Kaewkasi <chanwit@gmail.com>

Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
---
.../HelmRelease/actions/discovery.lua | 3 ++
.../HelmRelease/actions/reconcile/action.lua | 9 +++++++
.../helm.toolkit.fluxcd.io/HelmRelease/health.lua | 25 ++++++++++++++++++++
.../HelmRepository/actions/discovery.lua | 3 ++
.../HelmRepository/actions/reconcile/action.lua | 9 +++++++
.../HelmRepository/health.lua | 25 ++++++++++++++++++++
6 files changed, 74 insertions(+)
create mode 100644 resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/discovery.lua
create mode 100644 resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/reconcile/action.lua
create mode 100644 resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/health.lua
create mode 100644 resource_customizations/source.toolkit.fluxcd.io/HelmRepository/actions/discovery.lua
create mode 100644 resource_customizations/source.toolkit.fluxcd.io/HelmRepository/actions/reconcile/action.lua
create mode 100644 resource_customizations/source.toolkit.fluxcd.io/HelmRepository/health.lua

diff --git a/resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/discovery.lua b/resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/discovery.lua
new file mode 100644
index 000000000..c7f895ffb
--- /dev/null
+++ b/resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/discovery.lua
@@ -0,0 +1,3 @@
+actions = {}
+actions["reconcile"] = {}
+return actions
diff --git a/resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/reconcile/action.lua b/resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/reconcile/action.lua
new file mode 100644
index 000000000..f83651d3c
--- /dev/null
+++ b/resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/actions/reconcile/action.lua
@@ -0,0 +1,9 @@
+local os = require("os")
+if obj.metadata == nil then
+ obj.metadata = {}
+end
+if obj.metadata.annotations == nil then
+ obj.metadata.annotations = {}
+end
+obj.metadata.annotations["reconcile.fluxcd.io/requestedAt"] = os.date("!%Y-%m-%dT%XZ")
+return obj
diff --git a/resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/health.lua b/resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/health.lua
new file mode 100644
index 000000000..3c0bb1d04
--- /dev/null
+++ b/resource_customizations/helm.toolkit.fluxcd.io/HelmRelease/health.lua
@@ -0,0 +1,25 @@
+hs = {}
+if obj.status ~= nil then
+ if obj.status.conditions ~= nil then
+ ready_status = ""
+ for _, condition in ipairs(obj.status.conditions) do
+ if condition.type == "Ready" then
+ ready_status = condition.status
+ ready_message = condition.message
+ end
+ end
+ if ready_status == "True" then
+ hs.status = "Healthy"
+ elseif ready_status == "False" then
+ hs.status = "Degraded"
+ elseif ready_status == "Unknown" then
+ hs.status = "Progressing"
+ end
+ hs.message = ready_message
+ return hs
+ end
+end
+
+hs.status = "Progressing"
+hs.message = "Waiting for HelmRelease to reconcile ..."
+return hs
diff --git a/resource_customizations/source.toolkit.fluxcd.io/HelmRepository/actions/discovery.lua b/resource_customizations/source.toolkit.fluxcd.io/HelmRepository/actions/discovery.lua
new file mode 100644
index 000000000..c7f895ffb
--- /dev/null
+++ b/resource_customizations/source.toolkit.fluxcd.io/HelmRepository/actions/discovery.lua
@@ -0,0 +1,3 @@
+actions = {}
+actions["reconcile"] = {}
+return actions
diff --git a/resource_customizations/source.toolkit.fluxcd.io/HelmRepository/actions/reconcile/action.lua b/resource_customizations/source.toolkit.fluxcd.io/HelmRepository/actions/reconcile/action.lua
new file mode 100644
index 000000000..f83651d3c
--- /dev/null
+++ b/resource_customizations/source.toolkit.fluxcd.io/HelmRepository/actions/reconcile/action.lua
@@ -0,0 +1,9 @@
+local os = require("os")
+if obj.metadata == nil then
+ obj.metadata = {}
+end
+if obj.metadata.annotations == nil then
+ obj.metadata.annotations = {}
+end
+obj.metadata.annotations["reconcile.fluxcd.io/requestedAt"] = os.date("!%Y-%m-%dT%XZ")
+return obj
diff --git a/resource_customizations/source.toolkit.fluxcd.io/HelmRepository/health.lua b/resource_customizations/source.toolkit.fluxcd.io/HelmRepository/health.lua
new file mode 100644
index 000000000..f5bd9b0bc
--- /dev/null
+++ b/resource_customizations/source.toolkit.fluxcd.io/HelmRepository/health.lua
@@ -0,0 +1,25 @@
+hs = {}
+if obj.status ~= nil then
+ if obj.status.conditions ~= nil then
+ ready_status = ""
+ for _, condition in ipairs(obj.status.conditions) do
+ if condition.type == "Ready" then
+ ready_status = condition.status
+ ready_message = condition.message
+ end
+ end
+ if ready_status == "True" then
+ hs.status = "Healthy"
+ elseif ready_status == "False" then
+ hs.status = "Degraded"
+ elseif ready_status == "Unknown" then
+ hs.status = "Progressing"
+ end
+ hs.message = ready_message
+ return hs
+ end
+end
+
+hs.status = "Progressing"
+hs.message = "Waiting for HelmRepository to reconcile ..."
+return hs
1 change: 1 addition & 0 deletions patches-argo-cd-v2.8/series
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
17-add-tilt-dev-support.patch
18-add-oci-repository.patch
19-fix-special-supported-schemes.patch
20-add-health-message-for-helm.patch

0 comments on commit 3b228e6

Please sign in to comment.