MCPcopy
hub / github.com/1Panel-dev/KubePi / Install

Method Install

pkg/util/helm/helm.go:141–178  ·  view source on GitHub ↗
(name, repoName, chartName, chartVersion string, values map[string]interface{})

Source from the content-addressed store, hash-verified

139}
140
141func (c Client) Install(name, repoName, chartName, chartVersion string, values map[string]interface{}) (*release.Release, error) {
142 repos, err := c.ListRepo()
143 if err != nil {
144 return nil, err
145 }
146 var rp *repo.Entry
147 for _, r := range repos {
148 if r.Name == repoName {
149 rp = r
150 }
151 }
152 if rp == nil {
153 return nil, errors.New("get chart detail failed, repo not found")
154 }
155 client := action.NewInstall(c.actionConfig)
156 client.ReleaseName = name
157 client.Namespace = c.Namespace
158 client.RepoURL = rp.URL
159 client.Username = rp.Username
160 client.Password = rp.Password
161 client.ChartPathOptions.InsecureSkipTLSverify = true
162 if len(chartVersion) != 0 {
163 client.ChartPathOptions.Version = chartVersion
164 }
165 p, err := client.ChartPathOptions.LocateChart(chartName, c.settings)
166 if err != nil {
167 return nil, fmt.Errorf("locate chart %s failed: %v", chartName, err)
168 }
169 ct, err := loader.Load(p)
170 if err != nil {
171 return nil, fmt.Errorf("load chart %s failed: %v", chartName, err)
172 }
173 re, err := client.Run(ct, values)
174 if err != nil {
175 return re, errors.Wrap(err, fmt.Sprintf("install %s with chart %s failed: %v", name, chartName, err))
176 }
177 return re, nil
178}
179
180func (c Client) Upgrade(name, repoName, chartName, chartVersion string, values map[string]interface{}) (*release.Release, error) {
181 repos, err := c.ListRepo()

Callers 2

InstallChartMethod · 0.80
AddV1RouteFunction · 0.80

Calls 3

ListRepoMethod · 0.95
NewMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected