Skip to content
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 @@ -213,6 +213,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 @@ -43,7 +43,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 @@ -195,6 +195,31 @@ class ChartMetadata(BaseModel):
)


class ChartVersion(ModelWithCommand):
"""
Model for chart version, from search results
"""
name: NonEmptyString = Field(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the source of truth for the Chart.yaml structure https://github.com/helm/helm/blob/7e641d30a9355b43a9729d04c2771215ed926899/internal/chart/v3/metadata.go#L48 It says that the description should be an optional nonEmpty string and the chart name shouldn't have capital letters as it needs to meet the DNS rules enforced by Kubernetes objects.

...,
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