Skip to content

Commit 86e6b76

Browse files
authored
Expose Spec types for kinds (#33)
Having the Spec types exposed for all kinds mind be beneficial for the users of the library.
2 parents 9cb2e82 + a9aaad1 commit 86e6b76

File tree

8 files changed

+145
-121
lines changed

8 files changed

+145
-121
lines changed

backstage/kind_api.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,25 @@ type ApiEntityV1alpha1 struct {
2121
Kind string `json:"kind"`
2222

2323
// Spec is the specification data describing the API itself.
24-
Spec struct {
25-
// Type of the API definition.
26-
Type string `json:"type"`
24+
Spec *ApiEntityV1alpha1Spec `json:"spec"`
25+
}
26+
27+
// ApiEntityV1alpha1Spec describes the specification data describing the API itself.
28+
type ApiEntityV1alpha1Spec struct {
29+
// Type of the API definition.
30+
Type string `json:"type"`
2731

28-
// Lifecycle state of the API.
29-
Lifecycle string `json:"lifecycle"`
32+
// Lifecycle state of the API.
33+
Lifecycle string `json:"lifecycle"`
3034

31-
// Owner is entity reference to the owner of the API.
32-
Owner string `json:"owner"`
35+
// Owner is entity reference to the owner of the API.
36+
Owner string `json:"owner"`
3337

34-
// Definition of the API, based on the format defined by the type.
35-
Definition string `json:"definition"`
38+
// Definition of the API, based on the format defined by the type.
39+
Definition string `json:"definition"`
3640

37-
// System is entity reference to the system that the API belongs to.
38-
System string `json:"system,omitempty"`
39-
} `json:"spec"`
41+
// System is entity reference to the system that the API belongs to.
42+
System string `json:"system,omitempty"`
4043
}
4144

4245
// apiService handles communication with the API related methods of the Backstage Catalog API.

backstage/kind_component.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,34 @@ type ComponentEntityV1alpha1 struct {
2121
Kind string `json:"kind"`
2222

2323
// Spec is the specification data describing the component itself.
24-
Spec struct {
25-
// Type of component.
26-
Type string `json:"type"`
24+
Spec *ComponentEntityV1alpha1Spec `json:"spec"`
25+
}
26+
27+
// ComponentEntityV1alpha1Spec describes the specification data describing the component itself.
28+
type ComponentEntityV1alpha1Spec struct {
29+
// Type of component.
30+
Type string `json:"type"`
2731

28-
// Lifecycle state of the component.
29-
Lifecycle string `json:"lifecycle"`
32+
// Lifecycle state of the component.
33+
Lifecycle string `json:"lifecycle"`
3034

31-
// Owner is an entity reference to the owner of the component.
32-
Owner string `json:"owner"`
35+
// Owner is an entity reference to the owner of the component.
36+
Owner string `json:"owner"`
3337

34-
// SubcomponentOf is an entity reference to another component of which the component is a part.
35-
SubcomponentOf string `json:"subcomponentOf,omitempty"`
38+
// SubcomponentOf is an entity reference to another component of which the component is a part.
39+
SubcomponentOf string `json:"subcomponentOf,omitempty"`
3640

37-
// ProvidesApis is an array of entity references to the APIs that are provided by the component.
38-
ProvidesApis []string `json:"providesApis,omitempty"`
41+
// ProvidesApis is an array of entity references to the APIs that are provided by the component.
42+
ProvidesApis []string `json:"providesApis,omitempty"`
3943

40-
// ConsumesApis is an array of entity references to the APIs that are consumed by the component.
41-
ConsumesApis []string `json:"consumesApis,omitempty"`
44+
// ConsumesApis is an array of entity references to the APIs that are consumed by the component.
45+
ConsumesApis []string `json:"consumesApis,omitempty"`
4246

43-
// DependsOn is an array of entity references to the components and resources that the component depends on.
44-
DependsOn []string `json:"dependsOn,omitempty"`
47+
// DependsOn is an array of entity references to the components and resources that the component depends on.
48+
DependsOn []string `json:"dependsOn,omitempty"`
4549

46-
// System is an array of references to other entities that the component depends on to function.
47-
System string `json:"system,omitempty"`
48-
} `json:"spec"`
50+
// System is an array of references to other entities that the component depends on to function.
51+
System string `json:"system,omitempty"`
4952
}
5053

5154
// componentService handles communication with the component related methods of the Backstage Catalog API.

backstage/kind_domain.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ type DomainEntityV1alpha1 struct {
2121
Kind string `json:"kind"`
2222

2323
// Spec is the specification data describing the domain itself.
24-
Spec struct {
25-
// Owner is an entity reference to the owner of the component.
26-
Owner string `json:"owner"`
27-
} `json:"spec"`
24+
Spec *DomainEntityV1alpha1Spec `json:"spec"`
25+
}
26+
27+
// DomainEntityV1alpha1Spec describes the specification data describing the domain itself.
28+
type DomainEntityV1alpha1Spec struct {
29+
// Owner is an entity reference to the owner of the component.
30+
Owner string `json:"owner"`
2831
}
2932

3033
// domainService handles communication with the domain related methods of the Backstage Catalog API.

backstage/kind_group.go

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,41 @@ type GroupEntityV1alpha1 struct {
2121
Kind string `json:"kind"`
2222

2323
// Spec is the specification data describing the group itself.
24-
Spec struct {
25-
// Type of group. There is currently no enforced set of values for this field, so it is left up to the adopting
26-
// organization to choose a nomenclature that matches their org hierarchy.
27-
Type string `json:"type"`
28-
29-
// Profile information about the group, mainly for display purposes. All fields of this structure are also optional.
30-
// The email would be a group email of some form, that the group may wish to be used for contacting them.
31-
// The picture is expected to be a URL pointing to an image that's representative of the group, and that a browser could
32-
// fetch and render on a group page or similar.
33-
Profile struct {
34-
// DisplayName to present to users.
35-
DisplayName string `json:"displayName,omitempty"`
36-
37-
// Email where this entity can be reached.
38-
Email string `json:"email,omitempty"`
39-
40-
// Picture is a URL of an image that represents this entity.
41-
Picture string `json:"picture,omitempty"`
42-
} `json:"profile,omitempty"`
43-
44-
// Parent is the immediate parent group in the hierarchy, if any. Not all groups must have a parent; the catalog supports
45-
// multi-root hierarchies. Groups may however not have more than one parent. This field is an entity reference.
46-
Parent string `json:"parent,omitempty"`
47-
48-
// Children contains immediate child groups of this group in the hierarchy (whose parent field points to this group).
49-
// The list must be present, but may be empty if there are no child groups. The items are not guaranteed to be ordered in
50-
// any particular way. The entries of this array are entity references.
51-
Children []string `json:"children"`
52-
53-
// Members contains users that are members of this group. The entries of this array are entity references.
54-
Members []string `json:"members,omitempty"`
55-
} `json:"spec"`
24+
Spec *GroupEntityV1alpha1Spec `json:"spec"`
25+
}
26+
27+
// GroupEntityV1alpha1Spec describes the specification data describing the group itself.
28+
type GroupEntityV1alpha1Spec struct {
29+
// Type of group. There is currently no enforced set of values for this field, so it is left up to the adopting
30+
// organization to choose a nomenclature that matches their org hierarchy.
31+
Type string `json:"type"`
32+
33+
// Profile information about the group, mainly for display purposes. All fields of this structure are also optional.
34+
// The email would be a group email of some form, that the group may wish to be used for contacting them.
35+
// The picture is expected to be a URL pointing to an image that's representative of the group, and that a browser could
36+
// fetch and render on a group page or similar.
37+
Profile struct {
38+
// DisplayName to present to users.
39+
DisplayName string `json:"displayName,omitempty"`
40+
41+
// Email where this entity can be reached.
42+
Email string `json:"email,omitempty"`
43+
44+
// Picture is a URL of an image that represents this entity.
45+
Picture string `json:"picture,omitempty"`
46+
} `json:"profile,omitempty"`
47+
48+
// Parent is the immediate parent group in the hierarchy, if any. Not all groups must have a parent; the catalog supports
49+
// multi-root hierarchies. Groups may however not have more than one parent. This field is an entity reference.
50+
Parent string `json:"parent,omitempty"`
51+
52+
// Children contains immediate child groups of this group in the hierarchy (whose parent field points to this group).
53+
// The list must be present, but may be empty if there are no child groups. The items are not guaranteed to be ordered in
54+
// any particular way. The entries of this array are entity references.
55+
Children []string `json:"children"`
56+
57+
// Members contains users that are members of this group. The entries of this array are entity references.
58+
Members []string `json:"members,omitempty"`
5659
}
5760

5861
// groupService handles communication with the group related methods of the Backstage Catalog API.

backstage/kind_location.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,27 @@ type LocationEntityV1alpha1 struct {
2323
Kind string `json:"kind"`
2424

2525
// Spec is the specification data describing the location itself.
26-
Spec struct {
27-
// Type is the single location type, that's common to the targets specified in the spec. If it is left out, it is inherited
28-
// from the location type that originally read the entity data.
29-
Type string `json:"type,omitempty"`
30-
31-
// Target as a string. Can be either an absolute path/URL (depending on the type), or a relative path
32-
// such as./details/catalog-info.yaml which is resolved relative to the location of this Location entity itself.
33-
Target string `json:"target,omitempty"`
34-
35-
// Targets contains a list of targets as strings. They can all be either absolute paths/URLs (depending on the type),
36-
// or relative paths such as ./details/catalog-info.yaml which are resolved relative to the location of this Location
37-
// entity itself.
38-
Targets []string `json:"targets,omitempty"`
39-
40-
// Presence describes whether the presence of the location target is required, and it should be considered an error if it
41-
// can not be found.
42-
Presence string `json:"presence,omitempty"`
43-
} `json:"spec"`
26+
Spec *LocationEntityV1alpha1Spec `json:"spec"`
27+
}
28+
29+
// LocationEntityV1alpha1Spec describes the specification data describing the location itself.
30+
type LocationEntityV1alpha1Spec struct {
31+
// Type is the single location type, that's common to the targets specified in the spec. If it is left out, it is inherited
32+
// from the location type that originally read the entity data.
33+
Type string `json:"type,omitempty"`
34+
35+
// Target as a string. Can be either an absolute path/URL (depending on the type), or a relative path
36+
// such as./details/catalog-info.yaml which is resolved relative to the location of this Location entity itself.
37+
Target string `json:"target,omitempty"`
38+
39+
// Targets contains a list of targets as strings. They can all be either absolute paths/URLs (depending on the type),
40+
// or relative paths such as ./details/catalog-info.yaml which are resolved relative to the location of this Location
41+
// entity itself.
42+
Targets []string `json:"targets,omitempty"`
43+
44+
// Presence describes whether the presence of the location target is required, and it should be considered an error if it
45+
// can not be found.
46+
Presence string `json:"presence,omitempty"`
4447
}
4548

4649
// LocationCreateResponse defines POST response from location endpoints.

backstage/kind_resource.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,22 @@ type ResourceEntityV1alpha1 struct {
2121
Kind string `json:"kind"`
2222

2323
// Spec is the specification data describing the resource itself.
24-
Spec struct {
25-
// Type of resource.
26-
Type string `json:"type"`
24+
Spec *ResourceEntityV1alpha1Spec `json:"spec"`
25+
}
26+
27+
// ResourceEntityV1alpha1Spec describes the specification data describing the resource itself.
28+
type ResourceEntityV1alpha1Spec struct {
29+
// Type of resource.
30+
Type string `json:"type"`
2731

28-
// Owner is an entity reference to the owner of the resource.
29-
Owner string `json:"owner"`
32+
// Owner is an entity reference to the owner of the resource.
33+
Owner string `json:"owner"`
3034

31-
// DependsOn is an array of references to other entities that the resource depends on to function.
32-
DependsOn []string `json:"dependsOn,omitempty"`
35+
// DependsOn is an array of references to other entities that the resource depends on to function.
36+
DependsOn []string `json:"dependsOn,omitempty"`
3337

34-
// System is an entity reference to the system that the resource belongs to.
35-
System string `json:"system,omitempty"`
36-
} `json:"spec"`
38+
// System is an entity reference to the system that the resource belongs to.
39+
System string `json:"system,omitempty"`
3740
}
3841

3942
// resourceService handles communication with the resource related methods of the Backstage Catalog API.

backstage/kind_system.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ type SystemEntityV1alpha1 struct {
2222
Kind string `json:"kind"`
2323

2424
// Spec is the specification data describing the system itself.
25-
Spec struct {
26-
// Owner is an entity reference to the owner of the system.
27-
Owner string `json:"owner"`
25+
Spec *SystemEntityV1alpha1Spec `json:"spec"`
26+
}
27+
28+
// SystemEntityV1alpha1Spec describes the specification data describing the system itself.
29+
type SystemEntityV1alpha1Spec struct {
30+
// Owner is an entity reference to the owner of the system.
31+
Owner string `json:"owner"`
2832

29-
// Domain is an entity reference to the domain that the system belongs to.
30-
Domain string `json:"domain,omitempty"`
31-
} `json:"spec"`
33+
// Domain is an entity reference to the domain that the system belongs to.
34+
Domain string `json:"domain,omitempty"`
3235
}
3336

3437
// systemService handles communication with the system methods of the Backstage Catalog API.

backstage/kind_user.go

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,30 @@ type UserEntityV1alpha1 struct {
2121
Kind string `json:"kind"`
2222

2323
// Spec is the specification data describing the user itself.
24-
Spec struct {
25-
// Profile information about the user, mainly for display purposes. All fields of this structure are also optional.
26-
// The email would be a primary email of some form, that the user may wish to be used for contacting them.
27-
// The picture is expected to be a URL pointing to an image that's representative of the user, and that a browser could
28-
// fetch and render on a profile page or similar.
29-
Profile struct {
30-
// DisplayName is a simple display name to present to users.
31-
DisplayName string `json:"displayName,omitempty"`
32-
33-
// Email where this user can be reached.
34-
Email string `json:"email,omitempty"`
35-
36-
// Picture is a URL of an image that represents this user.
37-
Picture string `json:"picture,omitempty"`
38-
} `json:"profile,omitempty"`
39-
40-
// MemberOf is the list of groups that the user is a direct member of (i.e., no transitive memberships are listed here).
41-
// The list must be present, but may be empty if the user is not member of any groups. The items are not guaranteed to be
42-
// ordered in any particular way. The entries of this array are entity references.
43-
MemberOf []string `json:"memberOf,omitempty"`
44-
} `json:"spec"`
24+
Spec *UserEntityV1alpha1Spec `json:"spec"`
25+
}
26+
27+
// UserEntityV1alpha1Spec describes the specification data describing the user itself.
28+
type UserEntityV1alpha1Spec struct {
29+
// Profile information about the user, mainly for display purposes. All fields of this structure are also optional.
30+
// The email would be a primary email of some form, that the user may wish to be used for contacting them.
31+
// The picture is expected to be a URL pointing to an image that's representative of the user, and that a browser could
32+
// fetch and render on a profile page or similar.
33+
Profile struct {
34+
// DisplayName is a simple display name to present to users.
35+
DisplayName string `json:"displayName,omitempty"`
36+
37+
// Email where this user can be reached.
38+
Email string `json:"email,omitempty"`
39+
40+
// Picture is a URL of an image that represents this user.
41+
Picture string `json:"picture,omitempty"`
42+
} `json:"profile,omitempty"`
43+
44+
// MemberOf is the list of groups that the user is a direct member of (i.e., no transitive memberships are listed here).
45+
// The list must be present, but may be empty if the user is not member of any groups. The items are not guaranteed to be
46+
// ordered in any particular way. The entries of this array are entity references.
47+
MemberOf []string `json:"memberOf,omitempty"`
4548
}
4649

4750
// userService handles communication with the user methods of the Backstage Catalog API.

0 commit comments

Comments
 (0)