Skip to content

Commit

Permalink
Add /readme and /yaml Endpoints
Browse files Browse the repository at this point in the history
- With providing support for reading private catalogs there is a need to
  serve the readme and yaml as the client of Hub API will not be able to
  access the Readme and Yaml from the git provider directly
- Clients of Hub APIs will get the copy of Readme and YAML which was
  there at the time catalog refresh was done. This will ensure that the
  same copy is made available
- The endpoints will return the string content after reading the file
  from the repo which was cloned in the target directory

Signed-off-by: vinamra28 <vinjain@redhat.com>
  • Loading branch information
vinamra28 committed Feb 22, 2022
1 parent ae03d07 commit ac29632
Show file tree
Hide file tree
Showing 21 changed files with 2,195 additions and 190 deletions.
16 changes: 16 additions & 0 deletions api/design/types/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,22 @@ var Resource = ResultType("application/vnd.hub.resource", "Resource", func() {
Required("data")
})

var ResourceVersionReadme = ResultType("application/vnd.hub.resource.version.readme", "ResourceVersionReadme", func() {
Description("Returns README of a particular Resource")
Attribute("readme", String, "Readme", func() {
Example("readme", "#Readme\n Sample readme content")
})
Required("readme")
})

var ResourceVersionYaml = ResultType("application/vnd.hub.resource.version.yaml", "ResourceVersionYaml", func() {
Description("Returns YAML of a particular Resource")
Attribute("yaml", String, "Yaml", func() {
Example("yaml", "#YAML\n Sample yaml content")
})
Required("yaml")
})

var CatalogErrors = Type("CatalogErrors", func() {
Description("CatalogErrors define the errors that occurred during catalog refresh")
Attribute("type", String, "Catalog Errror type", func() {
Expand Down
62 changes: 62 additions & 0 deletions api/v1/design/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,64 @@ var _ = Service("resource", func() {
})
})

Method("ByCatalogKindNameVersionReadme", func() {
Description("Find resource README using name of catalog & name, kind and version of resource")
Payload(func() {
Attribute("catalog", String, "name of catalog", func() {
Example("catalog", "tektoncd")
})
Attribute("kind", String, "kind of resource", func() {
Enum("task", "pipeline")
})
Attribute("name", String, "name of resource", func() {
Example("name", "buildah")
})
Attribute("version", String, "version of resource", func() {
Example("version", "0.1")
})

Required("catalog", "kind", "name", "version")
})
Result(types.ResourceVersionReadme)

HTTP(func() {
GET("/resource/{catalog}/{kind}/{name}/{version}/readme")

Response(StatusOK)
Response("internal-error", StatusInternalServerError)
Response("not-found", StatusNotFound)
})
})

Method("ByCatalogKindNameVersionYaml", func() {
Description("Find resource YAML using name of catalog & name, kind and version of resource")
Payload(func() {
Attribute("catalog", String, "name of catalog", func() {
Example("catalog", "tektoncd")
})
Attribute("kind", String, "kind of resource", func() {
Enum("task", "pipeline")
})
Attribute("name", String, "name of resource", func() {
Example("name", "buildah")
})
Attribute("version", String, "version of resource", func() {
Example("version", "0.1")
})

Required("catalog", "kind", "name", "version")
})
Result(types.ResourceVersionYaml)

HTTP(func() {
GET("/resource/{catalog}/{kind}/{name}/{version}/yaml")

Response(StatusOK)
Response("internal-error", StatusInternalServerError)
Response("not-found", StatusNotFound)
})
})

Method("ByVersionId", func() {
Description("Find a resource using its version's id")
Payload(func() {
Expand Down Expand Up @@ -223,3 +281,7 @@ var _ = Service("resource", func() {
})

})

// /resource/catalog/kind/rname/version/readme
// /resource/name/version/yaml
// /resource/resource_version_id/yaml
66 changes: 61 additions & 5 deletions api/v1/gen/http/cli/hub/cli.go

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

2 changes: 1 addition & 1 deletion api/v1/gen/http/openapi.json

Large diffs are not rendered by default.

Loading

0 comments on commit ac29632

Please sign in to comment.