diff --git a/resource_customizations/rabbitmq.com/Binding/health.lua b/resource_customizations/rabbitmq.com/Binding/health.lua new file mode 100644 index 0000000000000..b2b96e8c8bbe5 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Binding/health.lua @@ -0,0 +1,22 @@ +local hs = {} +if obj.status ~= nil and obj.status.conditions ~= nil then + for i, condition in ipairs(obj.status.conditions) do + if condition.type == "Ready" then + if condition.status == "True" and condition.reason == "SuccessfulCreateOrUpdate" then + hs.status = "Healthy" + hs.message = "RabbitMQ binding ready" + return hs + end + + if condition.status == "False" and condition.reason == "FailedCreateOrUpdate" then + hs.status = "Degraded" + hs.message = "RabbitMQ binding failed to be created or updated" + return hs + end + end + end +end + +hs.status = "Unknown" +hs.message = "RabbitMQ binding status is unknown" +return hs \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Binding/health_test.yaml b/resource_customizations/rabbitmq.com/Binding/health_test.yaml new file mode 100644 index 0000000000000..b1481c95f2a6c --- /dev/null +++ b/resource_customizations/rabbitmq.com/Binding/health_test.yaml @@ -0,0 +1,13 @@ +tests: +- healthStatus: + status: Degraded + message: RabbitMQ binding failed to be created or updated + inputPath: testdata/degraded.yaml +- healthStatus: + status: Unknown + message: RabbitMQ binding status is unknown + inputPath: testdata/unknown.yaml +- healthStatus: + status: Healthy + message: RabbitMQ binding ready + inputPath: testdata/healthy.yaml \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Binding/testdata/degraded.yaml b/resource_customizations/rabbitmq.com/Binding/testdata/degraded.yaml new file mode 100644 index 0000000000000..d462a7a670fb1 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Binding/testdata/degraded.yaml @@ -0,0 +1,22 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Binding +metadata: + labels: + app: example-rabbitmq + name: example-rabbitmq + namespace: example +spec: + destination: destination + destinationType: queue + rabbitmqClusterReference: + name: example-rabbitmq + routingKey: v1.example.request + source: operation-requests + vhost: / +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: FailedCreateOrUpdate + status: "False" + type: Ready + observedGeneration: 1 diff --git a/resource_customizations/rabbitmq.com/Binding/testdata/healthy.yaml b/resource_customizations/rabbitmq.com/Binding/testdata/healthy.yaml new file mode 100644 index 0000000000000..f3ec856dc401d --- /dev/null +++ b/resource_customizations/rabbitmq.com/Binding/testdata/healthy.yaml @@ -0,0 +1,22 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Binding +metadata: + labels: + app: example-rabbitmq + name: example-rabbitmq + namespace: example +spec: + destination: destination + destinationType: queue + rabbitmqClusterReference: + name: example-rabbitmq + routingKey: v1.example.request + source: operation-requests + vhost: / +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: SuccessfulCreateOrUpdate + status: "True" + type: Ready + observedGeneration: 1 diff --git a/resource_customizations/rabbitmq.com/Binding/testdata/unknown.yaml b/resource_customizations/rabbitmq.com/Binding/testdata/unknown.yaml new file mode 100644 index 0000000000000..463d6a20c8a4e --- /dev/null +++ b/resource_customizations/rabbitmq.com/Binding/testdata/unknown.yaml @@ -0,0 +1,16 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Binding +metadata: + labels: + app: example-rabbitmq + name: example-rabbitmq + namespace: example +spec: + destination: destination + destinationType: queue + rabbitmqClusterReference: + name: example-rabbitmq + routingKey: v1.example.request + source: operation-requests + vhost: / +status: {} diff --git a/resource_customizations/rabbitmq.com/Exchange/health.lua b/resource_customizations/rabbitmq.com/Exchange/health.lua new file mode 100644 index 0000000000000..54b9b1dae5633 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Exchange/health.lua @@ -0,0 +1,22 @@ +local hs = {} +if obj.status ~= nil and obj.status.conditions ~= nil then + for i, condition in ipairs(obj.status.conditions) do + if condition.type == "Ready" then + if condition.status == "True" and condition.reason == "SuccessfulCreateOrUpdate" then + hs.status = "Healthy" + hs.message = "RabbitMQ exchange ready" + return hs + end + + if condition.status == "False" and condition.reason == "FailedCreateOrUpdate" then + hs.status = "Degraded" + hs.message = "RabbitMQ exchange failed to be created or updated" + return hs + end + end + end +end + +hs.status = "Unknown" +hs.message = "RabbitMQ exchange status is unknown" +return hs \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Exchange/health_test.yaml b/resource_customizations/rabbitmq.com/Exchange/health_test.yaml new file mode 100644 index 0000000000000..45f0ffd6cbb3b --- /dev/null +++ b/resource_customizations/rabbitmq.com/Exchange/health_test.yaml @@ -0,0 +1,13 @@ +tests: +- healthStatus: + status: Degraded + message: RabbitMQ exchange failed to be created or updated + inputPath: testdata/degraded.yaml +- healthStatus: + status: Unknown + message: RabbitMQ exchange status is unknown + inputPath: testdata/unknown.yaml +- healthStatus: + status: Healthy + message: RabbitMQ exchange ready + inputPath: testdata/healthy.yaml \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Exchange/testdata/degraded.yaml b/resource_customizations/rabbitmq.com/Exchange/testdata/degraded.yaml new file mode 100644 index 0000000000000..c686453d111f7 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Exchange/testdata/degraded.yaml @@ -0,0 +1,21 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Exchange +metadata: + generation: 3 + name: example-rabbit + namespace: example-rabbit +spec: + autoDelete: false + durable: true + name: example-rabbit + rabbitmqClusterReference: + name: example-rabbit + type: topic + vhost: / +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: FailedCreateOrUpdate + status: "False" + type: Ready + observedGeneration: 1 diff --git a/resource_customizations/rabbitmq.com/Exchange/testdata/healthy.yaml b/resource_customizations/rabbitmq.com/Exchange/testdata/healthy.yaml new file mode 100644 index 0000000000000..bdcb7dcbb0fda --- /dev/null +++ b/resource_customizations/rabbitmq.com/Exchange/testdata/healthy.yaml @@ -0,0 +1,21 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Exchange +metadata: + generation: 3 + name: example-rabbit + namespace: example-rabbit +spec: + autoDelete: false + durable: true + name: example-rabbit + rabbitmqClusterReference: + name: example-rabbit + type: topic + vhost: / +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: SuccessfulCreateOrUpdate + status: "True" + type: Ready + observedGeneration: 1 diff --git a/resource_customizations/rabbitmq.com/Exchange/testdata/unknown.yaml b/resource_customizations/rabbitmq.com/Exchange/testdata/unknown.yaml new file mode 100644 index 0000000000000..d9a255f21431a --- /dev/null +++ b/resource_customizations/rabbitmq.com/Exchange/testdata/unknown.yaml @@ -0,0 +1,15 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Exchange +metadata: + generation: 3 + name: example-rabbit + namespace: example-rabbit +spec: + autoDelete: false + durable: true + name: example-rabbit + rabbitmqClusterReference: + name: example-rabbit + type: topic + vhost: / +status: {} \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Permission/health.lua b/resource_customizations/rabbitmq.com/Permission/health.lua new file mode 100644 index 0000000000000..f4e8beda5836c --- /dev/null +++ b/resource_customizations/rabbitmq.com/Permission/health.lua @@ -0,0 +1,22 @@ +local hs = {} +if obj.status ~= nil and obj.status.conditions ~= nil then + for i, condition in ipairs(obj.status.conditions) do + if condition.type == "Ready" then + if condition.status == "True" and condition.reason == "SuccessfulCreateOrUpdate" then + hs.status = "Healthy" + hs.message = "RabbitMQ permission ready" + return hs + end + + if condition.status == "False" and condition.reason == "FailedCreateOrUpdate" then + hs.status = "Degraded" + hs.message = "RabbitMQ permission failed to be created or updated" + return hs + end + end + end +end + +hs.status = "Unknown" +hs.message = "RabbitMQ permission status is unknown" +return hs \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Permission/health_test.yaml b/resource_customizations/rabbitmq.com/Permission/health_test.yaml new file mode 100644 index 0000000000000..e0d9d24c5024a --- /dev/null +++ b/resource_customizations/rabbitmq.com/Permission/health_test.yaml @@ -0,0 +1,13 @@ +tests: +- healthStatus: + status: Degraded + message: RabbitMQ permission failed to be created or updated + inputPath: testdata/degraded.yaml +- healthStatus: + status: Unknown + message: RabbitMQ permission status is unknown + inputPath: testdata/unknown.yaml +- healthStatus: + status: Healthy + message: RabbitMQ permission ready + inputPath: testdata/healthy.yaml \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Permission/testdata/degraded.yaml b/resource_customizations/rabbitmq.com/Permission/testdata/degraded.yaml new file mode 100644 index 0000000000000..b64446c3d9919 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Permission/testdata/degraded.yaml @@ -0,0 +1,23 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Permission +metadata: + generation: 1 + name: example-rabbit + namespace: example-rabbit +spec: + permissions: + configure: .* + read: .* + write: .* + rabbitmqClusterReference: + name: example-rabbit + namespace: exmple-rabbit + user: example_user + vhost: / +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: FailedCreateOrUpdate + status: "False" + type: Ready + observedGeneration: 1 diff --git a/resource_customizations/rabbitmq.com/Permission/testdata/healthy.yaml b/resource_customizations/rabbitmq.com/Permission/testdata/healthy.yaml new file mode 100644 index 0000000000000..495132db5e3ab --- /dev/null +++ b/resource_customizations/rabbitmq.com/Permission/testdata/healthy.yaml @@ -0,0 +1,23 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Permission +metadata: + generation: 1 + name: example-rabbit + namespace: example-rabbit +spec: + permissions: + configure: .* + read: .* + write: .* + rabbitmqClusterReference: + name: example-rabbit + namespace: exmple-rabbit + user: example_user + vhost: / +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: SuccessfulCreateOrUpdate + status: "True" + type: Ready + observedGeneration: 1 diff --git a/resource_customizations/rabbitmq.com/Permission/testdata/unknown.yaml b/resource_customizations/rabbitmq.com/Permission/testdata/unknown.yaml new file mode 100644 index 0000000000000..a6294492b24fa --- /dev/null +++ b/resource_customizations/rabbitmq.com/Permission/testdata/unknown.yaml @@ -0,0 +1,17 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Permission +metadata: + generation: 1 + name: example-rabbit + namespace: example-rabbit +spec: + permissions: + configure: .* + read: .* + write: .* + rabbitmqClusterReference: + name: example-rabbit + namespace: exmple-rabbit + user: example_user + vhost: / +status: {} \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Policy/health.lua b/resource_customizations/rabbitmq.com/Policy/health.lua new file mode 100644 index 0000000000000..f44b5432265ba --- /dev/null +++ b/resource_customizations/rabbitmq.com/Policy/health.lua @@ -0,0 +1,22 @@ +local hs = {} +if obj.status ~= nil and obj.status.conditions ~= nil then + for i, condition in ipairs(obj.status.conditions) do + if condition.type == "Ready" then + if condition.status == "True" and condition.reason == "SuccessfulCreateOrUpdate" then + hs.status = "Healthy" + hs.message = "RabbitMQ policy ready" + return hs + end + + if condition.status == "False" and condition.reason == "FailedCreateOrUpdate" then + hs.status = "Degraded" + hs.message = "RabbitMQ policy failed to be created or updated" + return hs + end + end + end +end + +hs.status = "Unknown" +hs.message = "RabbitMQ policy status is unknown" +return hs \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Policy/health_test.yaml b/resource_customizations/rabbitmq.com/Policy/health_test.yaml new file mode 100644 index 0000000000000..238f9522976bf --- /dev/null +++ b/resource_customizations/rabbitmq.com/Policy/health_test.yaml @@ -0,0 +1,13 @@ +tests: +- healthStatus: + status: Degraded + message: RabbitMQ policy failed to be created or updated + inputPath: testdata/degraded.yaml +- healthStatus: + status: Unknown + message: RabbitMQ policy status is unknown + inputPath: testdata/unknown.yaml +- healthStatus: + status: Healthy + message: RabbitMQ policy ready + inputPath: testdata/healthy.yaml \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Policy/testdata/degraded.yaml b/resource_customizations/rabbitmq.com/Policy/testdata/degraded.yaml new file mode 100644 index 0000000000000..f6b5466d60071 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Policy/testdata/degraded.yaml @@ -0,0 +1,21 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Policy +metadata: + namespace: example-rabbit + name: example-rabbit +spec: + name: example-rabbit + vhost: example-rabbit + pattern: .* + applyTo: queues + definition: {} + rabbitmqClusterReference: + name: example-rabbit + namespace: example-rabbit +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: FailedCreateOrUpdate + status: "False" + type: Ready + observedGeneration: 1 diff --git a/resource_customizations/rabbitmq.com/Policy/testdata/healthy.yaml b/resource_customizations/rabbitmq.com/Policy/testdata/healthy.yaml new file mode 100644 index 0000000000000..7ce4962a27d1a --- /dev/null +++ b/resource_customizations/rabbitmq.com/Policy/testdata/healthy.yaml @@ -0,0 +1,21 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Policy +metadata: + namespace: example-rabbit + name: example-rabbit +spec: + name: example-rabbit + vhost: example-rabbit + pattern: .* + applyTo: queues + definition: {} + rabbitmqClusterReference: + name: example-rabbit + namespace: example-rabbit +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: SuccessfulCreateOrUpdate + status: "True" + type: Ready + observedGeneration: 1 diff --git a/resource_customizations/rabbitmq.com/Policy/testdata/unknown.yaml b/resource_customizations/rabbitmq.com/Policy/testdata/unknown.yaml new file mode 100644 index 0000000000000..e66dec82ca025 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Policy/testdata/unknown.yaml @@ -0,0 +1,15 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Policy +metadata: + namespace: example-rabbit + name: example-rabbit +spec: + name: example-rabbit + vhost: example-rabbit + pattern: .* + applyTo: queues + definition: {} + rabbitmqClusterReference: + name: example-rabbit + namespace: example-rabbit +status: {} \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Queue/health.lua b/resource_customizations/rabbitmq.com/Queue/health.lua new file mode 100644 index 0000000000000..80e4c4ab94273 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Queue/health.lua @@ -0,0 +1,22 @@ +local hs = {} +if obj.status ~= nil and obj.status.conditions ~= nil then + for i, condition in ipairs(obj.status.conditions) do + if condition.type == "Ready" then + if condition.status == "True" and condition.reason == "SuccessfulCreateOrUpdate" then + hs.status = "Healthy" + hs.message = "RabbitMQ queue ready" + return hs + end + + if condition.status == "False" and condition.reason == "FailedCreateOrUpdate" then + hs.status = "Degraded" + hs.message = "RabbitMQ queue failed to be created or updated" + return hs + end + end + end +end + +hs.status = "Unknown" +hs.message = "RabbitMQ queue status is unknown" +return hs \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Queue/health_test.yaml b/resource_customizations/rabbitmq.com/Queue/health_test.yaml new file mode 100644 index 0000000000000..c756cb5f38ec0 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Queue/health_test.yaml @@ -0,0 +1,13 @@ +tests: +- healthStatus: + status: Degraded + message: RabbitMQ queue failed to be created or updated + inputPath: testdata/degraded.yaml +- healthStatus: + status: Unknown + message: RabbitMQ queue status is unknown + inputPath: testdata/unknown.yaml +- healthStatus: + status: Healthy + message: RabbitMQ queue ready + inputPath: testdata/healthy.yaml \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Queue/testdata/degraded.yaml b/resource_customizations/rabbitmq.com/Queue/testdata/degraded.yaml new file mode 100644 index 0000000000000..fd67dbb252cff --- /dev/null +++ b/resource_customizations/rabbitmq.com/Queue/testdata/degraded.yaml @@ -0,0 +1,21 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Queue +metadata: + generation: 3 + name: example-rabbit + namespace: example-rabbit +spec: + autoDelete: false + durable: true + name: example-rabbit + rabbitmqClusterReference: + name: example-rabbit + type: quorum + vhost: / +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: FailedCreateOrUpdate + status: "False" + type: Ready + observedGeneration: 3 diff --git a/resource_customizations/rabbitmq.com/Queue/testdata/healthy.yaml b/resource_customizations/rabbitmq.com/Queue/testdata/healthy.yaml new file mode 100644 index 0000000000000..dda57ec06dd65 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Queue/testdata/healthy.yaml @@ -0,0 +1,21 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Queue +metadata: + generation: 3 + name: example-rabbit + namespace: example-rabbit +spec: + autoDelete: false + durable: true + name: example-rabbit + rabbitmqClusterReference: + name: example-rabbit + type: quorum + vhost: / +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: SuccessfulCreateOrUpdate + status: "True" + type: Ready + observedGeneration: 3 diff --git a/resource_customizations/rabbitmq.com/Queue/testdata/unknown.yaml b/resource_customizations/rabbitmq.com/Queue/testdata/unknown.yaml new file mode 100644 index 0000000000000..50fb3e0457ee6 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Queue/testdata/unknown.yaml @@ -0,0 +1,15 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Queue +metadata: + generation: 3 + name: example-rabbit + namespace: example-rabbit +spec: + autoDelete: false + durable: true + name: example-rabbit + rabbitmqClusterReference: + name: example-rabbit + type: quorum + vhost: / +status: {} \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Shovel/health.lua b/resource_customizations/rabbitmq.com/Shovel/health.lua new file mode 100644 index 0000000000000..6aa365909e8e3 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Shovel/health.lua @@ -0,0 +1,22 @@ +local hs = {} +if obj.status ~= nil and obj.status.conditions ~= nil then + for i, condition in ipairs(obj.status.conditions) do + if condition.type == "Ready" then + if condition.status == "True" and condition.reason == "SuccessfulCreateOrUpdate" then + hs.status = "Healthy" + hs.message = "RabbitMQ shovel ready" + return hs + end + + if condition.status == "False" and condition.reason == "FailedCreateOrUpdate" then + hs.status = "Degraded" + hs.message = "RabbitMQ shovel failed to be created or updated" + return hs + end + end + end +end + +hs.status = "Unknown" +hs.message = "RabbitMQ shovel status is unknown" +return hs \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Shovel/health_test.yaml b/resource_customizations/rabbitmq.com/Shovel/health_test.yaml new file mode 100644 index 0000000000000..74fdef335af34 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Shovel/health_test.yaml @@ -0,0 +1,13 @@ +tests: +- healthStatus: + status: Degraded + message: RabbitMQ shovel failed to be created or updated + inputPath: testdata/degraded.yaml +- healthStatus: + status: Unknown + message: RabbitMQ shovel status is unknown + inputPath: testdata/unknown.yaml +- healthStatus: + status: Healthy + message: RabbitMQ shovel ready + inputPath: testdata/healthy.yaml \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Shovel/testdata/degraded.yaml b/resource_customizations/rabbitmq.com/Shovel/testdata/degraded.yaml new file mode 100644 index 0000000000000..3d32863590004 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Shovel/testdata/degraded.yaml @@ -0,0 +1,15 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Shovel +metadata: + namespace: example-rabbit + name: example-rabbit +spec: + name: example-rabbit + vhost: example-rabbit +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: FailedCreateOrUpdate + status: "False" + type: Ready + observedGeneration: 1 diff --git a/resource_customizations/rabbitmq.com/Shovel/testdata/healthy.yaml b/resource_customizations/rabbitmq.com/Shovel/testdata/healthy.yaml new file mode 100644 index 0000000000000..d4e78ec7557d8 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Shovel/testdata/healthy.yaml @@ -0,0 +1,15 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Shovel +metadata: + namespace: example-rabbit + name: example-rabbit +spec: + name: example-rabbit + vhost: example-rabbit +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: SuccessfulCreateOrUpdate + status: "True" + type: Ready + observedGeneration: 1 diff --git a/resource_customizations/rabbitmq.com/Shovel/testdata/unknown.yaml b/resource_customizations/rabbitmq.com/Shovel/testdata/unknown.yaml new file mode 100644 index 0000000000000..41e7c9608e3de --- /dev/null +++ b/resource_customizations/rabbitmq.com/Shovel/testdata/unknown.yaml @@ -0,0 +1,9 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Shovel +metadata: + namespace: example-rabbit + name: example-rabbit +spec: + name: example-rabbit + vhost: example-rabbit +status: {} \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/User/health.lua b/resource_customizations/rabbitmq.com/User/health.lua new file mode 100644 index 0000000000000..77f69b1a5a527 --- /dev/null +++ b/resource_customizations/rabbitmq.com/User/health.lua @@ -0,0 +1,22 @@ +local hs = {} +if obj.status ~= nil and obj.status.conditions ~= nil then + for i, condition in ipairs(obj.status.conditions) do + if condition.type == "Ready" then + if condition.status == "True" and condition.reason == "SuccessfulCreateOrUpdate" then + hs.status = "Healthy" + hs.message = "RabbitMQ user ready" + return hs + end + + if condition.status == "False" and condition.reason == "FailedCreateOrUpdate" then + hs.status = "Degraded" + hs.message = "RabbitMQ user failed to be created or updated" + return hs + end + end + end +end + +hs.status = "Unknown" +hs.message = "RabbitMQ user status is unknown" +return hs \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/User/health_test.yaml b/resource_customizations/rabbitmq.com/User/health_test.yaml new file mode 100644 index 0000000000000..9769a57e5217b --- /dev/null +++ b/resource_customizations/rabbitmq.com/User/health_test.yaml @@ -0,0 +1,13 @@ +tests: +- healthStatus: + status: Degraded + message: RabbitMQ user failed to be created or updated + inputPath: testdata/degraded.yaml +- healthStatus: + status: Unknown + message: RabbitMQ user status is unknown + inputPath: testdata/unknown.yaml +- healthStatus: + status: Healthy + message: RabbitMQ user ready + inputPath: testdata/healthy.yaml \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/User/testdata/degraded.yaml b/resource_customizations/rabbitmq.com/User/testdata/degraded.yaml new file mode 100644 index 0000000000000..869b334389235 --- /dev/null +++ b/resource_customizations/rabbitmq.com/User/testdata/degraded.yaml @@ -0,0 +1,24 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: User +metadata: + generation: 1 + name: example-rabbit + namespace: exmple-rabbit +spec: + importCredentialsSecret: + name: example-rabbit + rabbitmqClusterReference: + name: example-rabbit + namespace: exmple-rabbit + tags: + - administrator +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: FailedCreateOrUpdate + status: "False" + type: Ready + credentials: + name: example-rabbit-user-credentials + observedGeneration: 1 + username: example_user diff --git a/resource_customizations/rabbitmq.com/User/testdata/healthy.yaml b/resource_customizations/rabbitmq.com/User/testdata/healthy.yaml new file mode 100644 index 0000000000000..416f01e73f58f --- /dev/null +++ b/resource_customizations/rabbitmq.com/User/testdata/healthy.yaml @@ -0,0 +1,24 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: User +metadata: + generation: 1 + name: example-rabbit + namespace: exmple-rabbit +spec: + importCredentialsSecret: + name: example-rabbit + rabbitmqClusterReference: + name: example-rabbit + namespace: exmple-rabbit + tags: + - administrator +status: + conditions: + - lastTransitionTime: 2025-01-10T20:48:01Z + reason: SuccessfulCreateOrUpdate + status: "True" + type: Ready + credentials: + name: example-rabbit-user-credentials + observedGeneration: 1 + username: example_user \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/User/testdata/unknown.yaml b/resource_customizations/rabbitmq.com/User/testdata/unknown.yaml new file mode 100644 index 0000000000000..0614ec1790220 --- /dev/null +++ b/resource_customizations/rabbitmq.com/User/testdata/unknown.yaml @@ -0,0 +1,25 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: User +metadata: + generation: 1 + name: example-rabbit + namespace: exmple-rabbit +spec: + importCredentialsSecret: + name: example-rabbit + rabbitmqClusterReference: + name: example-rabbit + namespace: exmple-rabbit + tags: + - administrator +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: FailedCreateOrUpdate + status: "False" + type: Ready + credentials: + name: example-rabbit-user-credentials + observedGeneration: 1 + username: example_user +status: {} \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Vhost/health.lua b/resource_customizations/rabbitmq.com/Vhost/health.lua new file mode 100644 index 0000000000000..70d05ff351d3f --- /dev/null +++ b/resource_customizations/rabbitmq.com/Vhost/health.lua @@ -0,0 +1,22 @@ +local hs = {} +if obj.status ~= nil and obj.status.conditions ~= nil then + for i, condition in ipairs(obj.status.conditions) do + if condition.type == "Ready" then + if condition.status == "True" and condition.reason == "SuccessfulCreateOrUpdate" then + hs.status = "Healthy" + hs.message = "RabbitMQ vhost ready" + return hs + end + + if condition.status == "False" and condition.reason == "FailedCreateOrUpdate" then + hs.status = "Degraded" + hs.message = "RabbitMQ vhost failed to be created or updated" + return hs + end + end + end +end + +hs.status = "Unknown" +hs.message = "RabbitMQ vhost status is unknown" +return hs \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Vhost/health_test.yaml b/resource_customizations/rabbitmq.com/Vhost/health_test.yaml new file mode 100644 index 0000000000000..ed713d59ff8a4 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Vhost/health_test.yaml @@ -0,0 +1,13 @@ +tests: +- healthStatus: + status: Degraded + message: RabbitMQ vhost failed to be created or updated + inputPath: testdata/degraded.yaml +- healthStatus: + status: Unknown + message: RabbitMQ vhost status is unknown + inputPath: testdata/unknown.yaml +- healthStatus: + status: Healthy + message: RabbitMQ vhost ready + inputPath: testdata/healthy.yaml \ No newline at end of file diff --git a/resource_customizations/rabbitmq.com/Vhost/testdata/degraded.yaml b/resource_customizations/rabbitmq.com/Vhost/testdata/degraded.yaml new file mode 100644 index 0000000000000..68bc6e3fa1628 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Vhost/testdata/degraded.yaml @@ -0,0 +1,19 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Vhost +metadata: + generation: 1 + name: example-rabbit + namespace: example-rabbit +spec: + defaultQueueType: quorum + name: example-rabbit + rabbitmqClusterReference: + name: example-rabbit + namespace: example-rabbit +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: FailedCreateOrUpdate + status: "False" + type: Ready + observedGeneration: 1 diff --git a/resource_customizations/rabbitmq.com/Vhost/testdata/healthy.yaml b/resource_customizations/rabbitmq.com/Vhost/testdata/healthy.yaml new file mode 100644 index 0000000000000..d2e82c8fdc08f --- /dev/null +++ b/resource_customizations/rabbitmq.com/Vhost/testdata/healthy.yaml @@ -0,0 +1,19 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Vhost +metadata: + generation: 1 + name: example-rabbit + namespace: example-rabbit +spec: + defaultQueueType: quorum + name: example-rabbit + rabbitmqClusterReference: + name: example-rabbit + namespace: example-rabbit +status: + conditions: + - lastTransitionTime: 2025-02-24T17:51:10Z + reason: SuccessfulCreateOrUpdate + status: "True" + type: Ready + observedGeneration: 1 diff --git a/resource_customizations/rabbitmq.com/Vhost/testdata/unknown.yaml b/resource_customizations/rabbitmq.com/Vhost/testdata/unknown.yaml new file mode 100644 index 0000000000000..adc5ca7f09b44 --- /dev/null +++ b/resource_customizations/rabbitmq.com/Vhost/testdata/unknown.yaml @@ -0,0 +1,13 @@ +apiVersion: rabbitmq.com/v1beta1 +kind: Vhost +metadata: + generation: 1 + name: example-rabbit + namespace: example-rabbit +spec: + defaultQueueType: quorum + name: example-rabbit + rabbitmqClusterReference: + name: example-rabbit + namespace: example-rabbit +status: {} \ No newline at end of file