Skip to content

Commit

Permalink
Modifies the response of v1 Resources API's by adding array of Catego…
Browse files Browse the repository at this point in the history
…ries

    - This patch updates the design of Resources by adding
      an array of Categories for the following API's

         - /v1/resource/{catalog}/{kind}/{name}/{version}
         - /v1/resource/version/{versionId}

    - Updates the v1 resources tests which adds category array in the
      response of CatalogKindNameVersion and ResourceBYVersionID

Signed-off-by: Puneet Punamiya <ppunamiy@redhat.com>
  • Loading branch information
PuneetPunamiya committed Jul 5, 2021
1 parent 12b908b commit 480a06d
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 23 deletions.
2 changes: 1 addition & 1 deletion api/v1/gen/http/openapi.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions api/v1/gen/http/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,9 @@ definitions:
catalog:
id: 1
type: community
categories:
- id: 1
name: Build Tools
id: 1
kind: task
name: buildah
Expand Down Expand Up @@ -976,6 +979,9 @@ definitions:
catalog:
id: 1
type: community
categories:
- id: 1
name: Build Tools
id: 1
kind: task
name: buildah
Expand Down Expand Up @@ -1087,6 +1093,14 @@ definitions:
properties:
catalog:
$ref: '#/definitions/CatalogResponseBodyMin'
categories:
type: array
items:
$ref: '#/definitions/CategoryResponseBody'
description: Categories related to resource
example:
- id: 1
name: image-build
id:
type: integer
description: ID is the unique id of the resource
Expand Down Expand Up @@ -1119,6 +1133,9 @@ definitions:
id: 1
name: tekton
type: community
categories:
- id: 1
name: image-build
id: 1
kind: task
name: buildah
Expand All @@ -1130,6 +1147,7 @@ definitions:
- id
- name
- catalog
- categories
- kind
- tags
- rating
Expand Down Expand Up @@ -1728,6 +1746,9 @@ definitions:
catalog:
id: 1
type: community
categories:
- id: 1
name: Build Tools
id: 1
kind: task
name: buildah
Expand Down
2 changes: 1 addition & 1 deletion api/v1/gen/http/openapi3.json

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions api/v1/gen/http/openapi3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ paths:
catalog:
id: 1
type: community
categories:
- id: 1
name: Build Tools
id: 1
kind: task
name: buildah
Expand Down Expand Up @@ -627,6 +630,9 @@ paths:
catalog:
id: 1
type: community
categories:
- id: 1
name: Build Tools
id: 1
kind: task
name: buildah
Expand Down Expand Up @@ -1130,6 +1136,9 @@ components:
catalog:
id: 1
type: community
categories:
- id: 1
name: Build Tools
id: 1
kind: task
name: buildah
Expand Down Expand Up @@ -1196,6 +1205,9 @@ components:
catalog:
id: 1
type: community
categories:
- id: 1
name: Build Tools
id: 1
kind: task
name: buildah
Expand Down
6 changes: 6 additions & 0 deletions api/v1/gen/http/resource/server/encode_decode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/v1/gen/http/resource/server/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 28 additions & 16 deletions api/v1/gen/resource/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions api/v1/gen/resource/views/view.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions api/v1/service/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,22 @@ func versionInfoFromResource(r model.Resource) *resource.ResourceVersion {
Name: tag.Name,
})
}

var categories []*resource.Category
for _, category := range r.Categories {
categories = append(categories, &resource.Category{
ID: category.ID,
Name: category.Name,
})
}

res := &resource.ResourceData{
ID: r.ID,
Name: r.Name,
Kind: r.Kind,
Rating: r.Rating,
Tags: tags,
ID: r.ID,
Name: r.Name,
Kind: r.Kind,
Rating: r.Rating,
Tags: tags,
Categories: categories,
Catalog: &resource.Catalog{
ID: r.Catalog.ID,
Name: r.Catalog.Name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
"name": "catalog-official",
"type": "official"
},
"categories": [
{
"id": 3,
"name": "pqr"
}
],
"kind": "task",
"tags": [
{
Expand Down
6 changes: 6 additions & 0 deletions api/v1/service/resource/testdata/TestByVersionID_Http.golden
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
"name": "catalog-official",
"type": "official"
},
"categories": [
{
"id": 2,
"name": "abc"
}
],
"kind": "pipeline",
"tags": [
{
Expand Down

0 comments on commit 480a06d

Please sign in to comment.