@@ -106,8 +106,10 @@ type NelmClient struct {
106106 labels map [string ]string
107107 annotations map [string ]string
108108
109- opts * CommonOptions
110- actions NelmActions
109+ opts * CommonOptions
110+ actions NelmActions
111+ virtualChart bool
112+ modulePath string
111113}
112114
113115// GetReleaseLabels returns a specific label value from the release.
@@ -159,6 +161,14 @@ func (c *NelmClient) WithExtraAnnotations(annotations map[string]string) {
159161 }
160162}
161163
164+ func (c * NelmClient ) WithVirtualChart (virtual bool ) {
165+ c .virtualChart = virtual
166+ }
167+
168+ func (c * NelmClient ) WithModulePath (path string ) {
169+ c .modulePath = path
170+ }
171+
162172// GetAnnotations returns the annotations for testing purposes
163173func (c * NelmClient ) GetAnnotations () map [string ]string {
164174 return c .annotations
@@ -220,8 +230,8 @@ func (c *NelmClient) UpgradeRelease(releaseName string, chart *chart.Chart, valu
220230 }
221231 }
222232
223- if err := c . actions . ReleaseInstall ( context . TODO (), releaseName , namespace , action. ReleaseInstallOptions {
224- Chart : chart . Metadata . Name , // TODO: This is a temporary fix - nelm needs chart path, not name
233+ // Prepare chart options based on whether this is a virtual chart
234+ opts := action. ReleaseInstallOptions {
225235 ExtraLabels : c .labels ,
226236 ExtraAnnotations : extraAnnotations ,
227237 KubeContext : c .opts .KubeContext ,
@@ -234,7 +244,20 @@ func (c *NelmClient) UpgradeRelease(releaseName string, chart *chart.Chart, valu
234244 ValuesSets : setValues ,
235245 ForceAdoption : true ,
236246 NoPodLogs : true ,
237- }); err != nil {
247+ }
248+
249+ if c .virtualChart {
250+ // For virtual charts, use default chart fields and empty chart path
251+ opts .Chart = ""
252+ opts .DefaultChartAPIVersion = chart .Metadata .APIVersion
253+ opts .DefaultChartName = chart .Metadata .Name
254+ opts .DefaultChartVersion = chart .Metadata .Version
255+ } else {
256+ // For regular charts, use the module path
257+ opts .Chart = c .modulePath
258+ }
259+
260+ if err := c .actions .ReleaseInstall (context .TODO (), releaseName , namespace , opts ); err != nil {
238261 return fmt .Errorf ("install nelm release %q: %w" , releaseName , err )
239262 }
240263
@@ -378,9 +401,9 @@ func (c *NelmClient) Render(releaseName string, chart *chart.Chart, valuesPaths,
378401 extraAnnotations ["maintenance.deckhouse.io/no-resource-reconciliation" ] = ""
379402 }
380403
381- chartRenderResult , err := c . actions . ChartRender ( context . TODO (), action. ChartRenderOptions {
382- OutputFilePath : "/dev/null" , // No output file, we want to return the manifest as a string
383- Chart : chart . Metadata . Name , // TODO: This is a temporary fix - nelm needs chart path, not name
404+ // Prepare chart render options based on whether this is a virtual chart
405+ renderOpts := action. ChartRenderOptions {
406+ OutputFilePath : "/dev/null" , // No output file, we want to return the manifest as a string
384407 ExtraLabels : c .labels ,
385408 ExtraAnnotations : extraAnnotations ,
386409 KubeContext : c .opts .KubeContext ,
@@ -391,7 +414,20 @@ func (c *NelmClient) Render(releaseName string, chart *chart.Chart, valuesPaths,
391414 ValuesFilesPaths : valuesPaths ,
392415 ValuesSets : setValues ,
393416 ForceAdoption : true ,
394- })
417+ }
418+
419+ if c .virtualChart {
420+ // For virtual charts, use default chart fields and empty chart path
421+ renderOpts .Chart = ""
422+ renderOpts .DefaultChartAPIVersion = chart .Metadata .APIVersion
423+ renderOpts .DefaultChartName = chart .Metadata .Name
424+ renderOpts .DefaultChartVersion = chart .Metadata .Version
425+ } else {
426+ // For regular charts, use the module path
427+ renderOpts .Chart = c .modulePath
428+ }
429+
430+ chartRenderResult , err := c .actions .ChartRender (context .TODO (), renderOpts )
395431 if err != nil {
396432 if ! debug {
397433 return "" , fmt .Errorf ("render nelm chart %q: %w\n \n Use --debug flag to render out invalid YAML" , chart .Metadata .Name , err )
0 commit comments