...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package helm
19
20 import (
21 "context"
22 "fmt"
23 "os"
24
25 "helm.sh/helm/v3/pkg/cli"
26
27 "github.com/chaos-mesh/chaos-mesh/pkg/log"
28 )
29
30 func ExampleHelmClient_InstallRelease() {
31 chart, err := FetchChaosMeshChart(context.Background(), "2.2.0")
32 if err != nil {
33 panic(err)
34 }
35
36 settings := cli.New()
37 restClientGetter := settings.RESTClientGetter()
38 logger, err := log.NewDefaultZapLogger()
39 if err != nil {
40 panic(err)
41 }
42 client, err := NewHelmClient(restClientGetter, logger)
43 if err != nil {
44 panic(err)
45 }
46 _, err = client.InstallRelease(
47 "chaos-mesh",
48 "chaos-mesh-in-remote-cluster",
49 chart,
50 nil,
51 )
52 if err != nil {
53 panic(err)
54 }
55
56 }
57
58 func ExampleHelmClient_UpgradeRelease() {
59 chart, err := FetchChaosMeshChart(context.Background(), "2.5.0")
60 if err != nil {
61 panic(err)
62 }
63
64 settings := cli.New()
65 restClientGetter := settings.RESTClientGetter()
66 logger, err := log.NewDefaultZapLogger()
67 if err != nil {
68 panic(err)
69 }
70 client, err := NewHelmClient(restClientGetter, logger)
71 if err != nil {
72 panic(err)
73 }
74 _, err = client.UpgradeRelease(
75 "chaos-mesh",
76 "chaos-mesh-in-remote-cluster",
77 chart,
78 nil,
79 )
80 if err != nil {
81 panic(err)
82 }
83
84 }
85
86 func ExampleHelmClient_GetRelease() {
87 settings := cli.New()
88 restClientGetter := settings.RESTClientGetter()
89 logger, err := log.NewDefaultZapLogger()
90 if err != nil {
91 panic(err)
92 }
93 client, err := NewHelmClient(restClientGetter, logger)
94 if err != nil {
95 panic(err)
96 }
97 release, err := client.GetRelease(
98 "chaos-mesh",
99 "chaos-mesh-in-remote-cluster",
100 )
101 if err != nil {
102 panic(err)
103 }
104 fmt.Fprintln(os.Stderr, release.Name)
105
106 }
107
108 func ExampleHelmClient_UninstallRelease() {
109 settings := cli.New()
110 restClientGetter := settings.RESTClientGetter()
111 logger, err := log.NewDefaultZapLogger()
112 if err != nil {
113 panic(err)
114 }
115 client, err := NewHelmClient(restClientGetter, logger)
116 if err != nil {
117 panic(err)
118 }
119 _, err = client.UninstallRelease(
120 "chaos-mesh",
121 "chaos-mesh-in-remote-cluster",
122 )
123 if err != nil {
124 panic(err)
125 }
126
127 }
128