-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity.go
95 lines (75 loc) · 3.48 KB
/
entity.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package backstage
import "encoding/json"
// entity represents a Backstage entity from the entities API endpoint.
//
// https://backstage.io/docs/features/software-catalog/descriptor-format#overall-shape-of-an-entity
type entity struct {
TypeMeta `json:",inline"`
Metadata Metadata `json:"metadata,omitempty"`
Relations []Relation `json:"relations,omitempty"`
Spec json.RawMessage
}
// Metadata is the metadata for Backstage entities.
//
// https://backstage.io/docs/features/software-catalog/descriptor-format#common-to-all-kinds-the-metadata
type Metadata struct {
// Name of the entity.
Name string `json:"name"`
// Namespace is optional ID of a namespace that the entity belongs to.
Namespace string `json:"namespace,omitempty"`
// Description is a human readable description of the entity, to be shown in Backstage.
Description string `json:"description,omitempty"`
// Title is the display name of the entity, to be presented in user interfaces instead of the name property above, when available.
Title string `json:"title,omitempty"`
// Labels are optional key/value pairs of that are attached to the entity, and their use is identical to Kubernetes object labels.
Labels map[string]string `json:"labels,omitempty"`
// Annotations are arbitrary non-identifying metadata attached to the entity, identical in use to Kubernetes object annotations.
Annotations map[string]string `json:"annotations,omitempty"`
// Tags are a list of single-valued strings, for example to classify catalog entities in various ways.
Tags []string `json:"tags,omitempty"`
// Links are a list of external hyperlinks related to the entity.
Links []Link `json:"links,omitempty"`
// UID is the unique ID assigned to this resource.
UID string `json:"uid"`
}
// Link can provide additional contextual information that may be located
// outside of Backstage itself.
//
// https://backstage.io/docs/features/software-catalog/descriptor-format#links-optional
type Link struct {
// URL is standard URI format.
URL string `json:"url"`
// Title is a user friendly display name for the link.
Title string `json:"title,omitempty"`
// Icon is a key representing a visual icon to be displayed in the UI.
Icon string `json:"icon,omitempty"`
// Type is an optional value to categorize links into specific groups.
Type string `json:"type,omitempty"`
}
// TypeMeta is the entity envelope.
//
// https://backstage.io/docs/features/software-catalog/descriptor-format#common-to-all-kinds-the-envelope
type TypeMeta struct {
// Kind is the high level entity type being described.
Kind string `json:"kind,omitempty"`
// APIVersion is the version of specification format for that particular entity that the specification is made against.
APIVersion string `json:"apiVersion,omitempty"`
}
// Relation is a relation from an entity to another entity.
//
// https://backstage.io/docs/features/software-catalog/descriptor-format#common-to-all-kinds-relations
type Relation struct {
// The type of relation FROM a source entity TO the target entity.
Type string `json:"type"`
// TargetRef is a string version of the Target.
TargetRef string `json:"targetRef,omitempty"`
// Target is a complete compound reference to the other end of the relation.
Target struct {
// Name is the name of the entity being referenced.
Name string `json:"name"`
// Namespace is the namespace of the entity being referenced.
Namespace string `json:"namespace"`
// Kind is the kind of entity being referenced.
Kind string `json:"kind"`
} `json:"target"`
}