Skip to content

Commit ac853e2

Browse files
committed
add status structs
1 parent 0d69e40 commit ac853e2

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

backstage/entity.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ type Entity struct {
2626

2727
// Relations that this entity has with other entities.
2828
Relations []EntityRelation `json:"relations,omitempty"`
29+
30+
// The current status of the entity, as claimed by various sources.
31+
Status *EntityStatus `json:"status,omitempty"`
2932
}
3033

3134
// EntityMeta represents metadata fields common to all versions/kinds of entity.
@@ -108,6 +111,46 @@ type EntityRelationTarget struct {
108111
Namespace string `json:"namespace"`
109112
}
110113

114+
// EntityStatus informs current status of the entity, as claimed by various sources.
115+
// https://github.com/backstage/backstage/blob/master/packages/catalog-model/src/schema/shared/common.schema.json
116+
type EntityStatus struct {
117+
// A specific status item on a well known format.
118+
Items []EntityStatusItem `json:"items,omitempty"`
119+
}
120+
121+
// EntityStatusItem contains a specific status item on a well known format.
122+
// https://github.com/backstage/backstage/blob/master/packages/catalog-model/src/schema/shared/common.schema.json
123+
type EntityStatusItem struct {
124+
// The item type
125+
Type string `json:"type"`
126+
127+
// The status level / severity of the status item.
128+
// Either ["info", "warning", "error"]
129+
Level string `json:"level"`
130+
131+
// A brief message describing the status, intended for human consumption.
132+
Message string `json:"message"`
133+
134+
// An optional serialized error object related to the status.
135+
Error *EntityStatusItemError `json:"error"`
136+
}
137+
138+
// EntityStatusItemError has aA serialized error object.
139+
// https://github.com/backstage/backstage/blob/master/packages/catalog-model/src/schema/shared/common.schema.json
140+
type EntityStatusItemError struct {
141+
// The type name of the error"
142+
Name string `json:"name"`
143+
144+
// The message of the error
145+
Message string `json:"message"`
146+
147+
// An error code associated with the error
148+
Code *string `json:"code"`
149+
150+
// An error stack trace
151+
Stack *string `json:"stack"`
152+
}
153+
111154
// ListEntityOrder defines a condition that can be used to order entities.
112155
type ListEntityOrder struct {
113156
// Direction is the direction to order by.

backstage/testdata/entities.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,5 +421,44 @@
421421
"relations":[
422422

423423
]
424+
},
425+
{
426+
"metadata":{
427+
"namespace":"default",
428+
"annotations":{
429+
"backstage.io/managed-by-location":"file:/private/tmp/back/examples/org.yaml",
430+
"backstage.io/managed-by-origin-location":"file:/private/tmp/back/examples/org.yaml"
431+
},
432+
"name":"generated-aa156660b91ff3cfa0819c08e413581e6d4e4136",
433+
"uid":"f5e4edef-f547-430d-8fee-13f4919888b7",
434+
"etag":"d9b5d5f05fe7901d90c68b62a9b2d30b3f9f0f87"
435+
},
436+
"apiVersion":"backstage.io/v1alpha1",
437+
"kind":"Location",
438+
"spec":{
439+
"type":"file",
440+
"target":"/private/tmp/back/examples/org.yaml"
441+
},
442+
"relations":[
443+
444+
],
445+
"status": {
446+
"items": [
447+
{
448+
"type": "backstage.io/catalog-processing",
449+
"level": "error",
450+
"message": "SomeError: it broke",
451+
"error": {
452+
"name": "SomeError",
453+
"message": "Error message",
454+
"cause": {
455+
"name": "Error",
456+
"message": "error message",
457+
"stack": "stack trace"
458+
}
459+
}
460+
}
461+
]
462+
}
424463
}
425464
]

0 commit comments

Comments
 (0)