Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local hs = {}
if obj.status ~= nil then
if obj.status.health ~= nil then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you consolidate in one if using and?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if obj.status.health == "green" then
hs.status = "Healthy"
hs.message = "Logstash status is Green"
return hs
elseif obj.status.health == "yellow" then
hs.status = "Progressing"
hs.message = "Logstash status is Yellow"
return hs
elseif obj.status.health == "red" then
hs.status = "Degraded"
hs.message = "Logstash status is Red"
return hs
end
end
end

hs.status = "Unknown"
hs.message = "Logstash status is unknown. Ensure your ArgoCD is current and then check for/file a bug report: https://github.com/argoproj/argo-cd/issues"
Copy link
Member

@agaudreault agaudreault May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, if the resource does not have the status populated yet, the default behavior is to be progressing and waiting for the controller to populate it.

I think you could have an unknown status if obj.status.health is of an unknown colour. Then the message can say which colour it is.

hs.status = "Progressing"
hs.message = "Waiting for Logstash"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

As per the source of Logstash, if health exist, then a colour will be defined, so I left the rest of the code as-is.

return hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Healthy
message: "Logstash status is Green"
inputPath: testdata/green.yaml
- healthStatus:
status: Progressing
message: "Logstash status is Yellow"
inputPath: testdata/yellow.yaml
- healthStatus:
status: Degraded
message: "Logstash status is Red"
inputPath: testdata/red.yaml
- healthStatus:
status: Unknown
message: "Logstash status is unknown. Ensure your ArgoCD is current and then check for/file a bug report: https://github.com/argoproj/argo-cd/issues"
inputPath: testdata/unknown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: logstash.k8s.elastic.co/v1alpha1
kind: Logstash
metadata:
name: quickstart
status:
health: green
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: logstash.k8s.elastic.co/v1alpha1
kind: Logstash
metadata:
name: quickstart
status:
health: red
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: logstash.k8s.elastic.co/v1alpha1
kind: Logstash
metadata:
name: quickstart
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: logstash.k8s.elastic.co/v1alpha1
kind: Logstash
metadata:
name: quickstart
status:
health: yellow
Loading