New creates a new helm deployment client
(helmClient helmtypes.Client, deployConfig *latest.DeploymentConfig)
| 36 | |
| 37 | // New creates a new helm deployment client |
| 38 | func New(helmClient helmtypes.Client, deployConfig *latest.DeploymentConfig) (deployer.Interface, error) { |
| 39 | // Exchange chart |
| 40 | if deployConfig.Helm.Chart == nil || (deployConfig.Helm.Chart.Name == DevSpaceChartConfig.Name && deployConfig.Helm.Chart.RepoURL == DevSpaceChartConfig.RepoURL) { |
| 41 | // extract component chart if possible |
| 42 | filename := "component-chart-" + DevSpaceChartConfig.Version + ".tgz" |
| 43 | componentChartBytes, err := assets.Asset(filename) |
| 44 | if err == nil { |
| 45 | homedir, _ := homedir.Dir() |
| 46 | completePath := filepath.Join(homedir, constants.DefaultHomeDevSpaceFolder, ComponentChartFolder, filename) |
| 47 | _, err := os.Stat(completePath) |
| 48 | if err != nil { |
| 49 | // make folder |
| 50 | err = os.MkdirAll(filepath.Dir(completePath), 0755) |
| 51 | if err != nil { |
| 52 | return nil, err |
| 53 | } |
| 54 | |
| 55 | // write file |
| 56 | err = os.WriteFile(completePath, componentChartBytes, 0666) |
| 57 | if err != nil { |
| 58 | return nil, fmt.Errorf("error writing component chart to file: %v", err) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | deployConfig.Helm.Chart = &latest.ChartConfig{ |
| 63 | Name: completePath, |
| 64 | } |
| 65 | } else { |
| 66 | deployConfig.Helm.Chart = DevSpaceChartConfig |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | return &DeployConfig{ |
| 71 | Helm: helmClient, |
| 72 | DeploymentConfig: deployConfig, |
| 73 | }, nil |
| 74 | } |
| 75 | |
| 76 | // Delete deletes the deployment |
| 77 | func Delete(ctx devspacecontext.Context, deploymentName string) error { |