-
Couldn't load subscription status.
- Fork 4
feat: oci support, internal helm client, defaults for config
#28
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c6ccf77
chore: fork pyhelm3 internally
ion-elgreco af1b4db
chore: bump version, typos
ion-elgreco 32ef8ac
feat: oci chart support
ion-elgreco 0e6af1d
chore: use hatchling
ion-elgreco 87e8e43
fix: assignment typo
ion-elgreco 5dc6b4e
fix: typo
ion-elgreco 262974f
fix: readme naming
ion-elgreco 48ac6d4
feat: default config support and schema validation disable support
ion-elgreco eab1b0c
chore: typehints
ion-elgreco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from dagster_uc._helm.client import Client | ||
|
|
||
| __all__ = [ | ||
| "Client", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import functools | ||
| import pathlib | ||
| from typing import Any | ||
|
|
||
| from dagster_uc._helm.command import Command | ||
| from dagster_uc._helm.models import Chart, ReleaseRevision | ||
|
|
||
|
|
||
| def mergeconcat( | ||
| defaults: dict[Any, Any], | ||
| *overrides: dict[Any, Any], | ||
| ) -> dict[Any, Any]: | ||
| """Deep-merge two or more dictionaries together. Lists are concatenated.""" | ||
|
|
||
| def mergeconcat2(defaults, overrides): # noqa: ANN001, ANN202 | ||
ion-elgreco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if isinstance(defaults, dict) and isinstance(overrides, dict): | ||
| merged = dict(defaults) | ||
| for key, value in overrides.items(): | ||
| if key in defaults: | ||
| merged[key] = mergeconcat2(defaults[key], value) | ||
| else: | ||
| merged[key] = value | ||
| return merged | ||
| elif isinstance(defaults, list | tuple) and isinstance(overrides, list | tuple): | ||
ion-elgreco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| merged = list(defaults) | ||
| merged.extend(overrides) | ||
| return merged | ||
| else: | ||
| return overrides if overrides is not None else defaults | ||
|
|
||
| return functools.reduce(mergeconcat2, overrides, defaults) # type: ignore | ||
|
|
||
|
|
||
| class Client: | ||
| """Entrypoint for interactions with Helm.""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| default_timeout: int | str = "5m", | ||
| executable: str = "helm", | ||
| history_max_revisions: int = 10, | ||
| insecure_skip_tls_verify: bool = False, | ||
| kubeconfig: pathlib.Path | None = None, | ||
| kubecontext: str | None = None, | ||
| unpack_directory: str | None = None, | ||
| ): | ||
| self._command = Command( | ||
| default_timeout=default_timeout, | ||
| executable=executable, | ||
| history_max_revisions=history_max_revisions, | ||
| insecure_skip_tls_verify=insecure_skip_tls_verify, | ||
| kubeconfig=kubeconfig, | ||
| kubecontext=kubecontext, | ||
| unpack_directory=unpack_directory, | ||
| ) | ||
|
|
||
| async def get_chart( | ||
| self, | ||
| chart_ref: pathlib.Path | str, | ||
| *, | ||
| devel: bool = False, | ||
| repo: str | None = None, | ||
| version: str | None = None, | ||
| ) -> Chart: | ||
| """Returns the resolved chart for the given ref, repo and version.""" | ||
| return Chart( | ||
| self._command, # type: ignore | ||
| ref=chart_ref, | ||
| repo=repo, | ||
| # Load the metadata for the specified args | ||
| metadata=await self._command.show_chart( | ||
| chart_ref, | ||
| devel=devel, | ||
| repo=repo, | ||
| version=version, | ||
| ), | ||
| ) | ||
|
|
||
| async def install_or_upgrade_release( | ||
| self, | ||
| release_name: str, | ||
| chart: Chart, | ||
| *values: dict[str, Any], | ||
| atomic: bool = False, | ||
| cleanup_on_fail: bool = False, | ||
| create_namespace: bool = True, | ||
| description: str | None = None, | ||
| dry_run: bool = False, | ||
| force: bool = False, | ||
| namespace: str | None = None, | ||
| no_hooks: bool = False, | ||
| reset_values: bool = False, | ||
| reuse_values: bool = False, | ||
| skip_crds: bool = False, | ||
| timeout: int | str | None = None, | ||
| wait: bool = False, | ||
| disable_openapi_validation: bool = False, | ||
| ) -> ReleaseRevision: | ||
| """Install or upgrade the named release using the given chart and values and return | ||
| the new revision. | ||
| """ | ||
| return ReleaseRevision._from_status( | ||
| await self._command.install_or_upgrade( | ||
| release_name, | ||
| chart.ref, | ||
| mergeconcat(*values) if values else None, | ||
| atomic=atomic, | ||
| cleanup_on_fail=cleanup_on_fail, | ||
| create_namespace=create_namespace, | ||
| description=description, | ||
| dry_run=dry_run, | ||
| force=force, | ||
| namespace=namespace, | ||
| no_hooks=no_hooks, | ||
| repo=chart.repo, | ||
| reset_values=reset_values, | ||
| reuse_values=reuse_values, | ||
| skip_crds=skip_crds, | ||
| timeout=timeout, | ||
| version=chart.metadata.version, | ||
| wait=wait, | ||
| disable_openapi_validation=disable_openapi_validation, | ||
| ), | ||
| self._command, | ||
| ) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.