NewChart creates a new helm chart for the project from helm's default template. It returns a chart.Chart that references the newly created chart or an error.
(name string)
| 52 | // NewChart creates a new helm chart for the project from helm's default template. |
| 53 | // It returns a chart.Chart that references the newly created chart or an error. |
| 54 | func NewChart(name string) (*chart.Chart, error) { |
| 55 | tmpDir, err := os.MkdirTemp("", "osdk-helm-chart") |
| 56 | if err != nil { |
| 57 | return nil, err |
| 58 | } |
| 59 | defer func() { |
| 60 | if err := os.RemoveAll(tmpDir); err != nil { |
| 61 | log.Errorf("Failed to remove temporary directory %s: %v", tmpDir, err) |
| 62 | } |
| 63 | }() |
| 64 | |
| 65 | // Create a new chart |
| 66 | chartPath, err := chartutil.Create(name, tmpDir) |
| 67 | if err != nil { |
| 68 | return nil, err |
| 69 | } |
| 70 | |
| 71 | return loader.Load(chartPath) |
| 72 | } |
| 73 | |
| 74 | // LoadChart creates a new helm chart for the project based on the passed opts. |
| 75 | // It returns a chart.Chart that references the newly created chart or an error. |