-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_async.py
More file actions
99 lines (82 loc) · 3.29 KB
/
basic_async.py
File metadata and controls
99 lines (82 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python3
# Copyright 2025 Vantage Compute
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Example showing basic async helm-sdkpy usage."""
import asyncio
import helm_sdkpy
async def main():
"""Basic example of using helm-sdkpy with async/await."""
print(f"helm-sdkpy version: {helm_sdkpy.__version__}")
try:
print(f"Library version: {helm_sdkpy.get_version()}")
except helm_sdkpy.HelmLibraryNotFound:
print("Library not found - please build the library first with 'just build-lib'")
return
print("\nAvailable action classes:")
print("- Configuration: Manage Helm configuration")
print("- Install: Install a chart (async)")
print("- Upgrade: Upgrade a release (async)")
print("- Uninstall: Uninstall a release (async)")
print("- List: List releases (async)")
print("- Status: Get release status (async)")
print("- Rollback: Rollback a release (async)")
print("- GetValues: Get release values (async)")
print("- History: Get release history (async)")
print("\nChart operations:")
print("- Pull: Download a chart (async)")
print("- Show: Show chart information (async)")
print("- Test: Run release tests (async)")
print("- Lint: Lint a chart (async)")
print("- Package: Package a chart (async)")
print("\n" + "="*60)
print("Example usage:")
print("="*60)
example_code = """
import asyncio
from helm_sdkpy import Configuration, Install, List
async def main():
# Create a configuration for the default namespace
config = Configuration(namespace="default")
# Install a chart from a local path
install = Install(config)
result = await install.run(
release_name="my-nginx",
chart_path="./nginx-chart",
values={"replicaCount": 3}
)
print(f"Installed release: {result}")
# Install a chart from an OCI registry
result = await install.run(
release_name="my-app",
chart_path="oci://ghcr.io/nginxinc/charts/nginx-ingress",
values={"controller": {"service": {"type": "LoadBalancer"}}}
)
print(f"Installed from OCI: {result}")
# Install a chart from an HTTPS URL
result = await install.run(
release_name="my-release",
chart_path="https://charts.bitnami.com/bitnami/nginx-15.0.0.tgz",
values={"replicaCount": 2}
)
print(f"Installed from HTTPS: {result}")
# List releases
list_action = List(config)
releases = await list_action.run(all=True)
for release in releases:
print(f"Release: {release['name']}, Status: {release['status']}")
asyncio.run(main())
"""
print(example_code)
if __name__ == "__main__":
asyncio.run(main())