Skip to content

Commit

Permalink
Expose Spec types for kinds (#33)
Browse files Browse the repository at this point in the history
Having the Spec types exposed for all kinds mind be beneficial for the
users of the library.
  • Loading branch information
tdabasinskas committed Apr 3, 2024
2 parents 9cb2e82 + a9aaad1 commit 86e6b76
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 121 deletions.
27 changes: 15 additions & 12 deletions backstage/kind_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,25 @@ type ApiEntityV1alpha1 struct {
Kind string `json:"kind"`

// Spec is the specification data describing the API itself.
Spec struct {
// Type of the API definition.
Type string `json:"type"`
Spec *ApiEntityV1alpha1Spec `json:"spec"`
}

// ApiEntityV1alpha1Spec describes the specification data describing the API itself.
type ApiEntityV1alpha1Spec struct {
// Type of the API definition.
Type string `json:"type"`

// Lifecycle state of the API.
Lifecycle string `json:"lifecycle"`
// Lifecycle state of the API.
Lifecycle string `json:"lifecycle"`

// Owner is entity reference to the owner of the API.
Owner string `json:"owner"`
// Owner is entity reference to the owner of the API.
Owner string `json:"owner"`

// Definition of the API, based on the format defined by the type.
Definition string `json:"definition"`
// Definition of the API, based on the format defined by the type.
Definition string `json:"definition"`

// System is entity reference to the system that the API belongs to.
System string `json:"system,omitempty"`
} `json:"spec"`
// System is entity reference to the system that the API belongs to.
System string `json:"system,omitempty"`
}

// apiService handles communication with the API related methods of the Backstage Catalog API.
Expand Down
39 changes: 21 additions & 18 deletions backstage/kind_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,34 @@ type ComponentEntityV1alpha1 struct {
Kind string `json:"kind"`

// Spec is the specification data describing the component itself.
Spec struct {
// Type of component.
Type string `json:"type"`
Spec *ComponentEntityV1alpha1Spec `json:"spec"`
}

// ComponentEntityV1alpha1Spec describes the specification data describing the component itself.
type ComponentEntityV1alpha1Spec struct {
// Type of component.
Type string `json:"type"`

// Lifecycle state of the component.
Lifecycle string `json:"lifecycle"`
// Lifecycle state of the component.
Lifecycle string `json:"lifecycle"`

// Owner is an entity reference to the owner of the component.
Owner string `json:"owner"`
// Owner is an entity reference to the owner of the component.
Owner string `json:"owner"`

// SubcomponentOf is an entity reference to another component of which the component is a part.
SubcomponentOf string `json:"subcomponentOf,omitempty"`
// SubcomponentOf is an entity reference to another component of which the component is a part.
SubcomponentOf string `json:"subcomponentOf,omitempty"`

// ProvidesApis is an array of entity references to the APIs that are provided by the component.
ProvidesApis []string `json:"providesApis,omitempty"`
// ProvidesApis is an array of entity references to the APIs that are provided by the component.
ProvidesApis []string `json:"providesApis,omitempty"`

// ConsumesApis is an array of entity references to the APIs that are consumed by the component.
ConsumesApis []string `json:"consumesApis,omitempty"`
// ConsumesApis is an array of entity references to the APIs that are consumed by the component.
ConsumesApis []string `json:"consumesApis,omitempty"`

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

// System is an array of references to other entities that the component depends on to function.
System string `json:"system,omitempty"`
} `json:"spec"`
// System is an array of references to other entities that the component depends on to function.
System string `json:"system,omitempty"`
}

// componentService handles communication with the component related methods of the Backstage Catalog API.
Expand Down
11 changes: 7 additions & 4 deletions backstage/kind_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ type DomainEntityV1alpha1 struct {
Kind string `json:"kind"`

// Spec is the specification data describing the domain itself.
Spec struct {
// Owner is an entity reference to the owner of the component.
Owner string `json:"owner"`
} `json:"spec"`
Spec *DomainEntityV1alpha1Spec `json:"spec"`
}

// DomainEntityV1alpha1Spec describes the specification data describing the domain itself.
type DomainEntityV1alpha1Spec struct {
// Owner is an entity reference to the owner of the component.
Owner string `json:"owner"`
}

// domainService handles communication with the domain related methods of the Backstage Catalog API.
Expand Down
67 changes: 35 additions & 32 deletions backstage/kind_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,41 @@ type GroupEntityV1alpha1 struct {
Kind string `json:"kind"`

// Spec is the specification data describing the group itself.
Spec struct {
// Type of group. There is currently no enforced set of values for this field, so it is left up to the adopting
// organization to choose a nomenclature that matches their org hierarchy.
Type string `json:"type"`

// Profile information about the group, mainly for display purposes. All fields of this structure are also optional.
// The email would be a group email of some form, that the group may wish to be used for contacting them.
// The picture is expected to be a URL pointing to an image that's representative of the group, and that a browser could
// fetch and render on a group page or similar.
Profile struct {
// DisplayName to present to users.
DisplayName string `json:"displayName,omitempty"`

// Email where this entity can be reached.
Email string `json:"email,omitempty"`

// Picture is a URL of an image that represents this entity.
Picture string `json:"picture,omitempty"`
} `json:"profile,omitempty"`

// Parent is the immediate parent group in the hierarchy, if any. Not all groups must have a parent; the catalog supports
// multi-root hierarchies. Groups may however not have more than one parent. This field is an entity reference.
Parent string `json:"parent,omitempty"`

// Children contains immediate child groups of this group in the hierarchy (whose parent field points to this group).
// The list must be present, but may be empty if there are no child groups. The items are not guaranteed to be ordered in
// any particular way. The entries of this array are entity references.
Children []string `json:"children"`

// Members contains users that are members of this group. The entries of this array are entity references.
Members []string `json:"members,omitempty"`
} `json:"spec"`
Spec *GroupEntityV1alpha1Spec `json:"spec"`
}

// GroupEntityV1alpha1Spec describes the specification data describing the group itself.
type GroupEntityV1alpha1Spec struct {
// Type of group. There is currently no enforced set of values for this field, so it is left up to the adopting
// organization to choose a nomenclature that matches their org hierarchy.
Type string `json:"type"`

// Profile information about the group, mainly for display purposes. All fields of this structure are also optional.
// The email would be a group email of some form, that the group may wish to be used for contacting them.
// The picture is expected to be a URL pointing to an image that's representative of the group, and that a browser could
// fetch and render on a group page or similar.
Profile struct {
// DisplayName to present to users.
DisplayName string `json:"displayName,omitempty"`

// Email where this entity can be reached.
Email string `json:"email,omitempty"`

// Picture is a URL of an image that represents this entity.
Picture string `json:"picture,omitempty"`
} `json:"profile,omitempty"`

// Parent is the immediate parent group in the hierarchy, if any. Not all groups must have a parent; the catalog supports
// multi-root hierarchies. Groups may however not have more than one parent. This field is an entity reference.
Parent string `json:"parent,omitempty"`

// Children contains immediate child groups of this group in the hierarchy (whose parent field points to this group).
// The list must be present, but may be empty if there are no child groups. The items are not guaranteed to be ordered in
// any particular way. The entries of this array are entity references.
Children []string `json:"children"`

// Members contains users that are members of this group. The entries of this array are entity references.
Members []string `json:"members,omitempty"`
}

// groupService handles communication with the group related methods of the Backstage Catalog API.
Expand Down
39 changes: 21 additions & 18 deletions backstage/kind_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,27 @@ type LocationEntityV1alpha1 struct {
Kind string `json:"kind"`

// Spec is the specification data describing the location itself.
Spec struct {
// Type is the single location type, that's common to the targets specified in the spec. If it is left out, it is inherited
// from the location type that originally read the entity data.
Type string `json:"type,omitempty"`

// Target as a string. Can be either an absolute path/URL (depending on the type), or a relative path
// such as./details/catalog-info.yaml which is resolved relative to the location of this Location entity itself.
Target string `json:"target,omitempty"`

// Targets contains a list of targets as strings. They can all be either absolute paths/URLs (depending on the type),
// or relative paths such as ./details/catalog-info.yaml which are resolved relative to the location of this Location
// entity itself.
Targets []string `json:"targets,omitempty"`

// Presence describes whether the presence of the location target is required, and it should be considered an error if it
// can not be found.
Presence string `json:"presence,omitempty"`
} `json:"spec"`
Spec *LocationEntityV1alpha1Spec `json:"spec"`
}

// LocationEntityV1alpha1Spec describes the specification data describing the location itself.
type LocationEntityV1alpha1Spec struct {
// Type is the single location type, that's common to the targets specified in the spec. If it is left out, it is inherited
// from the location type that originally read the entity data.
Type string `json:"type,omitempty"`

// Target as a string. Can be either an absolute path/URL (depending on the type), or a relative path
// such as./details/catalog-info.yaml which is resolved relative to the location of this Location entity itself.
Target string `json:"target,omitempty"`

// Targets contains a list of targets as strings. They can all be either absolute paths/URLs (depending on the type),
// or relative paths such as ./details/catalog-info.yaml which are resolved relative to the location of this Location
// entity itself.
Targets []string `json:"targets,omitempty"`

// Presence describes whether the presence of the location target is required, and it should be considered an error if it
// can not be found.
Presence string `json:"presence,omitempty"`
}

// LocationCreateResponse defines POST response from location endpoints.
Expand Down
23 changes: 13 additions & 10 deletions backstage/kind_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@ type ResourceEntityV1alpha1 struct {
Kind string `json:"kind"`

// Spec is the specification data describing the resource itself.
Spec struct {
// Type of resource.
Type string `json:"type"`
Spec *ResourceEntityV1alpha1Spec `json:"spec"`
}

// ResourceEntityV1alpha1Spec describes the specification data describing the resource itself.
type ResourceEntityV1alpha1Spec struct {
// Type of resource.
Type string `json:"type"`

// Owner is an entity reference to the owner of the resource.
Owner string `json:"owner"`
// Owner is an entity reference to the owner of the resource.
Owner string `json:"owner"`

// DependsOn is an array of references to other entities that the resource depends on to function.
DependsOn []string `json:"dependsOn,omitempty"`
// DependsOn is an array of references to other entities that the resource depends on to function.
DependsOn []string `json:"dependsOn,omitempty"`

// System is an entity reference to the system that the resource belongs to.
System string `json:"system,omitempty"`
} `json:"spec"`
// System is an entity reference to the system that the resource belongs to.
System string `json:"system,omitempty"`
}

// resourceService handles communication with the resource related methods of the Backstage Catalog API.
Expand Down
15 changes: 9 additions & 6 deletions backstage/kind_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ type SystemEntityV1alpha1 struct {
Kind string `json:"kind"`

// Spec is the specification data describing the system itself.
Spec struct {
// Owner is an entity reference to the owner of the system.
Owner string `json:"owner"`
Spec *SystemEntityV1alpha1Spec `json:"spec"`
}

// SystemEntityV1alpha1Spec describes the specification data describing the system itself.
type SystemEntityV1alpha1Spec struct {
// Owner is an entity reference to the owner of the system.
Owner string `json:"owner"`

// Domain is an entity reference to the domain that the system belongs to.
Domain string `json:"domain,omitempty"`
} `json:"spec"`
// Domain is an entity reference to the domain that the system belongs to.
Domain string `json:"domain,omitempty"`
}

// systemService handles communication with the system methods of the Backstage Catalog API.
Expand Down
45 changes: 24 additions & 21 deletions backstage/kind_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,30 @@ type UserEntityV1alpha1 struct {
Kind string `json:"kind"`

// Spec is the specification data describing the user itself.
Spec struct {
// Profile information about the user, mainly for display purposes. All fields of this structure are also optional.
// The email would be a primary email of some form, that the user may wish to be used for contacting them.
// The picture is expected to be a URL pointing to an image that's representative of the user, and that a browser could
// fetch and render on a profile page or similar.
Profile struct {
// DisplayName is a simple display name to present to users.
DisplayName string `json:"displayName,omitempty"`

// Email where this user can be reached.
Email string `json:"email,omitempty"`

// Picture is a URL of an image that represents this user.
Picture string `json:"picture,omitempty"`
} `json:"profile,omitempty"`

// MemberOf is the list of groups that the user is a direct member of (i.e., no transitive memberships are listed here).
// 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
// ordered in any particular way. The entries of this array are entity references.
MemberOf []string `json:"memberOf,omitempty"`
} `json:"spec"`
Spec *UserEntityV1alpha1Spec `json:"spec"`
}

// UserEntityV1alpha1Spec describes the specification data describing the user itself.
type UserEntityV1alpha1Spec struct {
// Profile information about the user, mainly for display purposes. All fields of this structure are also optional.
// The email would be a primary email of some form, that the user may wish to be used for contacting them.
// The picture is expected to be a URL pointing to an image that's representative of the user, and that a browser could
// fetch and render on a profile page or similar.
Profile struct {
// DisplayName is a simple display name to present to users.
DisplayName string `json:"displayName,omitempty"`

// Email where this user can be reached.
Email string `json:"email,omitempty"`

// Picture is a URL of an image that represents this user.
Picture string `json:"picture,omitempty"`
} `json:"profile,omitempty"`

// MemberOf is the list of groups that the user is a direct member of (i.e., no transitive memberships are listed here).
// 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
// ordered in any particular way. The entries of this array are entity references.
MemberOf []string `json:"memberOf,omitempty"`
}

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

0 comments on commit 86e6b76

Please sign in to comment.