Commit 84f5aaa7 authored by Alessio Caiazza's avatar Alessio Caiazza

WIP: mock cluster apps status API

parent 6d462cea
......@@ -3,4 +3,16 @@ class ClusterEntity < Grape::Entity
expose :status_name, as: :status
expose :status_reason
expose :applications do |cluster, options|
if cluster.created?
{
helm: { status: 'installed' },
ingress: { status: 'error', status_reason: 'Missing namespace' },
runner: { status: 'installing' },
prometheus: { status: 'installable' }
}
else
{}
end
end
end
......@@ -2,6 +2,6 @@ class ClusterSerializer < BaseSerializer
entity ClusterEntity
def represent_status(resource)
represent(resource, { only: [:status, :status_reason] })
represent(resource, { only: [:status, :status_reason, :applications] })
end
end
......@@ -5,7 +5,38 @@
],
"properties" : {
"status": { "type": "string" },
"status_reason": { "type": ["string", "null"] }
"status_reason": { "type": ["string", "null"] },
"applications": { "$ref": "#/definitions/applications" }
},
"additionalProperties": false
"additionalProperties": false,
"definitions": {
"applications": {
"type": "object",
"additionalProperties": false,
"properties" : {
"helm": { "$ref": "#/definitions/app_status" },
"runner": { "$ref": "#/definitions/app_status" },
"ingress": { "$ref": "#/definitions/app_status" },
"prometheus": { "$ref": "#/definitions/app_status" }
}
},
"app_status": {
"type": "object",
"additionalProperties": false,
"properties" : {
"status": {
"type": {
"enum": [
"installable",
"installing",
"installed",
"error"
]
}
},
"status_reason": { "type": ["string", "null"] }
},
"required" : [ "status" ]
}
}
}
......@@ -18,5 +18,9 @@ describe ClusterEntity do
it 'contains status reason' do
expect(subject[:status_reason]).to eq('general error')
end
it 'contains applications' do
expect(subject[:applications]).to eq({})
end
end
end
......@@ -12,7 +12,7 @@ describe ClusterSerializer do
let(:resource) { create(:gcp_cluster, :errored) }
it 'serializes only status' do
expect(subject.keys).to contain_exactly(:status, :status_reason)
expect(subject.keys).to contain_exactly(:status, :status_reason, :applications)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment