feat: health check for OnePasswordItem (#10690)

Signed-off-by: Chris Hoffman <cehoffman@gmail.com>

Signed-off-by: Chris Hoffman <cehoffman@gmail.com>
This commit is contained in:
Chris Hoffman 2022-09-30 18:27:01 -05:00 committed by GitHub
parent 4f043cc2eb
commit 0e068f5bcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1,21 @@
hs = {}
if obj.status ~= nil then
if obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" and condition.status == "True" then
hs.status = "Healthy"
hs.message = condition.message
return hs
end
if condition.type == "Ready" and condition.status == "False" then
hs.status = "Degraded"
hs.message = condition.message
return hs
end
end
end
end
hs.status = "Progressing"
hs.message = "Waiting for controller to report status"
return hs

View file

@ -0,0 +1,12 @@
tests:
- healthStatus:
status: Progressing
message: Waiting for controller to report status
inputPath: testdata/new.yaml
- healthStatus:
status: Degraded
message: Error
inputPath: testdata/degraded.yaml
- healthStatus:
status: Healthy
inputPath: testdata/healthy.yaml

View file

@ -0,0 +1,13 @@
apiVersion: onepassword.com/v1
kind: OnePasswordItem
metadata:
name: degraded-item
namespace: test-namespace
spec:
itemPath: vaults/Test Vault/items/Test Item
status:
conditions:
- lastTransitionTime: '2022-09-24T01:11:54Z'
message: Error
status: 'False'
type: Ready

View file

@ -0,0 +1,12 @@
apiVersion: onepassword.com/v1
kind: OnePasswordItem
metadata:
name: healthy-item
namespace: test-namespace
spec:
itemPath: vaults/Test Vault/items/Test Item
status:
conditions:
- lastTransitionTime: '2022-09-24T01:11:54Z'
status: 'True'
type: Ready

View file

@ -0,0 +1,7 @@
apiVersion: onepassword.com/v1
kind: OnePasswordItem
metadata:
name: new-item
namespace: test-namespace
spec:
itemPath: vaults/Test Vault/items/Test Item