Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the search repo api and implement the model #14

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion pyhelm3/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from .command import Command, SafeLoader
from .errors import ReleaseNotFoundError
from .models import Chart, Release, ReleaseRevision, ReleaseRevisionStatus
from .models import Chart, Release, ReleaseRevision, ReleaseRevisionStatus, ChartVersion


def mergeconcat(
Expand Down Expand Up @@ -209,6 +209,31 @@ async def get_current_revision(
self._command
)

async def search_chart(
self,
search_keyword: str = None,
all_versions: bool = False,
devel: bool = False,
) -> t.Iterable[ChartVersion]:
"""
Returns an iterable of the available versions.
"""
return (
ChartVersion(
self._command,
name = release["name"],
version = release["version"],
description = release["description"],
app_version = release["app_version"]
)
for release in await self._command.search(
search_keyword=search_keyword,
all_versions=all_versions,
devel=devel,
)
)


async def install_or_upgrade_release(
self,
release_name: str,
Expand Down
27 changes: 26 additions & 1 deletion pyhelm3/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, _command: Command, **kwargs):


#: Type for a name (chart or release)
Name = constr(pattern = r"^[a-z0-9-]+$")
Name = constr(pattern = r"^[a-zA-Z0-9-]+$")


#: Type for a SemVer version
Expand Down Expand Up @@ -191,6 +191,31 @@ class ChartMetadata(BaseModel):
)


class ChartVersion(ModelWithCommand):
"""
Model for chart version, from search results
"""
name: NonEmptyString = Field(
...,
description = "The full name of the chart."
)
version: SemVerVersion = Field(
...,
description = "The version of the chart."
)
description: str = Field(
None,
description = "A single-sentence description of the chart."
)

app_version: NonEmptyString = Field(
None,
alias = "appVersion",
description = (
"The version of the app that this chart deploys. "
)
)

class Chart(ModelWithCommand):
"""
Model for a reference to a chart.
Expand Down