diff --git a/pyhelm3/client.py b/pyhelm3/client.py index 423b6d6..a5a11f3 100644 --- a/pyhelm3/client.py +++ b/pyhelm3/client.py @@ -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( @@ -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, diff --git a/pyhelm3/models.py b/pyhelm3/models.py index ef915e8..9c6473b 100644 --- a/pyhelm3/models.py +++ b/pyhelm3/models.py @@ -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 @@ -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.