InstallRelease performs a Helm release install.
(opts ...InstallOption)
| 167 | |
| 168 | // InstallRelease performs a Helm release install. |
| 169 | func (m manager) InstallRelease(opts ...InstallOption) (*rpb.Release, error) { |
| 170 | install := action.NewInstall(m.actionConfig) |
| 171 | install.ReleaseName = m.releaseName |
| 172 | install.Namespace = m.namespace |
| 173 | for _, o := range opts { |
| 174 | if err := o(install); err != nil { |
| 175 | return nil, fmt.Errorf("failed to apply install option: %w", err) |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | installedRelease, err := install.Run(m.chart, m.values) |
| 180 | if err != nil { |
| 181 | // Workaround for helm/helm#3338 |
| 182 | if installedRelease != nil { |
| 183 | uninstall := action.NewUninstall(m.actionConfig) |
| 184 | _, uninstallErr := uninstall.Run(m.releaseName) |
| 185 | |
| 186 | // In certain cases, InstallRelease will return a partial release in |
| 187 | // the response even when it doesn't record the release in its release |
| 188 | // store (e.g. when there is an error rendering the release manifest). |
| 189 | // In that case the rollback will fail with a not found error because |
| 190 | // there was nothing to rollback. |
| 191 | // |
| 192 | // Only log a message about a rollback failure if the failure was caused |
| 193 | // by something other than the release not being found. |
| 194 | if uninstallErr != nil && !notFoundErr(uninstallErr) { |
| 195 | return nil, fmt.Errorf("failed installation (%s) and failed rollback: %w", err, uninstallErr) |
| 196 | } |
| 197 | } |
| 198 | return nil, fmt.Errorf("failed to install release: %w", err) |
| 199 | } |
| 200 | return installedRelease, nil |
| 201 | } |
| 202 | |
| 203 | func ForceUpgrade(force bool) UpgradeOption { |
| 204 | return func(u *action.Upgrade) error { |
nothing calls this directly
no test coverage detected