-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
kind_component.go
69 lines (52 loc) · 2.87 KB
/
kind_component.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
package backstage
import (
"context"
"net/http"
)
// KindComponent defines name for component kind.
const KindComponent = "Component"
// ComponentEntityV1alpha1 describes a software component. It is typically intimately linked to the source code that constitutes the
// component, and should be what a developer may regard a "unit of software", usually with a distinct deployable or linkable artifact.
// https://github.com/backstage/backstage/blob/master/packages/catalog-model/src/schema/kinds/Component.v1alpha1.schema.json
type ComponentEntityV1alpha1 struct {
Entity
// ApiVersion is always "backstage.io/v1alpha1".
ApiVersion string `json:"apiVersion" yaml:"apiVersion"`
// Kind is always "Component".
Kind string `json:"kind" yaml:"kind"`
// Spec is the specification data describing the component itself.
Spec *ComponentEntityV1alpha1Spec `json:"spec" yaml:"spec"`
}
// ComponentEntityV1alpha1Spec describes the specification data describing the component itself.
type ComponentEntityV1alpha1Spec struct {
// Type of component.
Type string `json:"type" yaml:"type"`
// Lifecycle state of the component.
Lifecycle string `json:"lifecycle" yaml:"lifecycle"`
// Owner is an entity reference to the owner of the component.
Owner string `json:"owner" yaml:"owner"`
// SubcomponentOf is an entity reference to another component of which the component is a part.
SubcomponentOf string `json:"subcomponentOf,omitempty" yaml:"subcomponentOf,omitempty"`
// ProvidesApis is an array of entity references to the APIs that are provided by the component.
ProvidesApis []string `json:"providesApis,omitempty" yaml:"providesApis,omitempty"`
// ConsumesApis is an array of entity references to the APIs that are consumed by the component.
ConsumesApis []string `json:"consumesApis,omitempty" yaml:"consumesApis,omitempty"`
// DependsOn is an array of entity references to the components and resources that the component depends on.
DependsOn []string `json:"dependsOn,omitempty" yaml:"dependsOn,omitempty"`
// System is an array of references to other entities that the component depends on to function.
System string `json:"system,omitempty" yaml:"system,omitempty"`
}
// componentService handles communication with the component related methods of the Backstage Catalog API.
type componentService typedEntityService[ComponentEntityV1alpha1]
// newComponentService returns a new instance of component-type entityService.
func newComponentService(s *entityService) *componentService {
return &componentService{
client: s.client,
apiPath: s.apiPath,
}
}
// Get returns a component entity identified by the name and the namespace ("default", if not specified) it belongs to.
func (s *componentService) Get(ctx context.Context, n string, ns string) (*ComponentEntityV1alpha1, *http.Response, error) {
cs := (typedEntityService[ComponentEntityV1alpha1])(*s)
return cs.get(ctx, KindComponent, n, ns)
}