Skip to content

Commit

Permalink
Introduce endpoints for listing available Thoth s2i bae container images
Browse files Browse the repository at this point in the history
  • Loading branch information
fridex committed Feb 1, 2021
1 parent 8c73e73 commit d6c3cda
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
51 changes: 51 additions & 0 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,20 @@ paths:
schema:
$ref: "#/components/schemas/AnalysisResponseError"

/s2i/python:
get:
tags: [s2i]
x-openapi-router-controller: thoth.user_api.api_v1
operationId: list_s2i_python
summary: Get available S2I base container images for Python applications.
responses:
"200":
description: A list of available Python S2I.
content:
application/json:
schema:
$ref: "#/components/schemas/S2IPythonResponse"

/advise/python/{analysis_id}/log:
get:
tags: [Advise]
Expand Down Expand Up @@ -2022,6 +2036,43 @@ components:
parameters:
type: object
description: Parameters echoed back to user for debugging.

S2IPythonResponse:
type: object
required:
- s2i
properties:
s2i:
type: array
items:
type: object
required:
- thoth_s2i
- thoth_s2i_name
- thoth_s2i_version
- analysis_id
properties:
thoth_s2i:
type: string
description: Full qualifier of Thoth's s2i.
nullable: false
example: quay.io/thoth-station/s2i-thoth-ubi8-py38:v1.0.0
thoth_s2i_name:
type: string
description: Name of the Thoth s2i.
nullable: false
example: quay.io/thoth-station/s2i-thoth-ubi8-py38
thoth_s2i_version:
type: string
description: Version of the Thoth s2i.
nullable: false
example: "1.0.0"
analysis_id:
type: string
description: Container image analysis id.
nullable: false
example: package-extract-foo

AnalysisLogResponse:
type: object
required:
Expand Down
22 changes: 22 additions & 0 deletions thoth/user_api/api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,28 @@ def get_analyze(analysis_id: str):
)


def list_s2i_python() -> typing.Dict[str, typing.List[typing.Dict[str, str]]]:
"""List all available Python s2i."""
from .openapi_server import GRAPH

entries = []
for thoth_s2i_image_name, thoth_s2i_image_version in GRAPH.get_thoth_s2i_all(is_external=False):
analyses = GRAPH.get_thoth_s2i_package_extract_analysis_document_id_all(
thoth_s2i_image_name,
thoth_s2i_image_version,
is_external=False
)

entries.append({
"thoth_s2i_image_name": thoth_s2i_image_name,
"thoth_s2i_image_version": thoth_s2i_image_version,
"thoth_s2i": f"{thoth_s2i_image_name}:v{thoth_s2i_image_version}",
"analysis_id": analyses[-1], # Show only the last, the most recent, one.
})

return {"s2i": entries}


def get_analyze_by_hash(image_hash: str):
"""Get image analysis by hash of the analyzed image."""
parameters = locals()
Expand Down

0 comments on commit d6c3cda

Please sign in to comment.