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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__pycache__
*.egg-info
.python-version
.python-version

.idea/
16 changes: 13 additions & 3 deletions pyhelm3/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
FilePath,
AnyUrl as PydanticAnyUrl,
HttpUrl as PydanticHttpUrl,
UrlConstraints as PydanticUrlConstraints,
constr,
field_validator
)
from pydantic.functional_validators import AfterValidator
from typing_extensions import Annotated

from .command import Command, SafeLoader

Expand Down Expand Up @@ -46,6 +48,14 @@ def __init__(self, _command: Command, **kwargs):
SemVerVersion = constr(pattern = r"^v?\d+\.\d+\.\d+(-[a-zA-Z0-9\.\-]+)?(\+[a-zA-Z0-9\.\-]+)?$")


#: Type for an OCI scheme URI
OciUrl = Annotated[PydanticAnyUrl, PydanticUrlConstraints(allowed_schemes=["oci"], host_required=True)]


#: Type for an S3 scheme URI
S3Url = Annotated[PydanticAnyUrl, PydanticUrlConstraints(allowed_schemes=["s3"], host_required=True)]


#: Type variables for forward references to the chart and release types
ChartType = t.TypeVar("ChartType", bound = "Chart")
ReleaseType = t.TypeVar("ReleaseType", bound = "Release")
Expand Down Expand Up @@ -195,7 +205,7 @@ class Chart(ModelWithCommand):
"""
Model for a reference to a chart.
"""
ref: t.Union[DirectoryPath, FilePath, HttpUrl, Name] = Field(
ref: t.Union[DirectoryPath, FilePath, HttpUrl, OciUrl, Name] = Field(
...,
description = (
"The chart reference. "
Expand All @@ -205,7 +215,7 @@ class Chart(ModelWithCommand):
"be given."
)
)
repo: t.Optional[HttpUrl] = Field(None, description = "The repository URL.")
repo: t.Optional[t.Union[HttpUrl, S3Url]] = Field(None, description = "The repository URL.")
metadata: ChartMetadata = Field(..., description = "The metadata for the chart.")

# Private attributes used to cache attributes
Expand All @@ -229,7 +239,7 @@ async def _run_command(self, command_method):
"""
method = getattr(self._command, command_method)
# We only need the kwargs if the ref is not a direct reference
if isinstance(self.ref, (pathlib.Path, HttpUrl)):
if isinstance(self.ref, pathlib.Path) or str(self.ref).startswith(('http', 'https', 'oci')):
return await method(self.ref)
else:
return await method(self.ref, repo = self.repo, version = self.metadata.version)
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
import setuptools

if __name__ == "__main__":
setuptools.setup()
setuptools.setup(
version='0.0.1'
)