Skip to content

Commit 5543a6b

Browse files
committed
[chore] fix nelm
Signed-off-by: kerimov <brileyforbusiness@gmail.com>
1 parent b13646f commit 5543a6b

File tree

4 files changed

+33
-81
lines changed

4 files changed

+33
-81
lines changed

pkg/helm/client/client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ type HelmClient interface {
1919
WithLogLabels(map[string]string)
2020
WithExtraLabels(map[string]string)
2121
WithExtraAnnotations(map[string]string)
22-
WithVirtualChart(bool)
2322
}

pkg/helm/helm3lib/helm3lib.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,6 @@ func (h *LibClient) WithExtraAnnotations(_ map[string]string) {
9090
// helm3lib doesn't support annotations, no-op implementation
9191
}
9292

93-
func (h *LibClient) WithVirtualChart(_ bool) {
94-
// helm3lib doesn't need virtual chart flag, no-op implementation
95-
}
96-
97-
func (h *LibClient) WithModulePath(_ string) {
98-
// helm3lib doesn't need module path, no-op implementation
99-
}
100-
10193
// buildConfigFlagsFromEnv builds a ConfigFlags object from the environment and
10294
// returns it. It uses a persistent config, meaning that underlying clients will
10395
// be cached and reused.

pkg/helm/nelm/nelm.go

Lines changed: 33 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,8 @@ type NelmClient struct {
106106
labels map[string]string
107107
annotations map[string]string
108108

109-
opts *CommonOptions
110-
actions NelmActions
111-
virtualChart bool
112-
modulePath string
109+
opts *CommonOptions
110+
actions NelmActions
113111
}
114112

115113
// GetReleaseLabels returns a specific label value from the release.
@@ -161,14 +159,6 @@ func (c *NelmClient) WithExtraAnnotations(annotations map[string]string) {
161159
}
162160
}
163161

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-
172162
// GetAnnotations returns the annotations for testing purposes
173163
func (c *NelmClient) GetAnnotations() map[string]string {
174164
return c.annotations
@@ -232,33 +222,22 @@ func (c *NelmClient) UpgradeRelease(releaseName string, chart *chart.Chart, valu
232222

233223
// Prepare chart options based on whether this is a virtual chart
234224
opts := action.ReleaseInstallOptions{
235-
Chart: c.modulePath,
236-
ExtraLabels: c.labels,
237-
ExtraAnnotations: extraAnnotations,
238-
KubeContext: c.opts.KubeContext,
239-
NoInstallCRDs: true,
240-
ReleaseHistoryLimit: int(c.opts.HistoryMax),
241-
ReleaseLabels: releaseLabels,
242-
ReleaseStorageDriver: c.opts.HelmDriver,
243-
Timeout: c.opts.Timeout,
244-
ValuesFilesPaths: valuesPaths,
245-
ValuesSets: setValues,
246-
ForceAdoption: true,
247-
NoPodLogs: true,
248-
}
249-
250-
if c.virtualChart {
251-
logger.Info("NELM: Using virtual chart mode",
252-
slog.String("defaultName", chart.Metadata.Name),
253-
slog.String("defaultVersion", chart.Metadata.Version),
254-
slog.String("defaultAPIVersion", chart.Metadata.APIVersion),
255-
slog.String("modulePath", c.modulePath),
256-
slog.Bool("usePrebuiltChart", true),
257-
slog.Int("chartTemplatesCount", len(chart.Templates)),
258-
slog.Int("chartRawCount", len(chart.Raw)))
259-
opts.DefaultChartAPIVersion = chart.Metadata.APIVersion
260-
opts.DefaultChartName = chart.Metadata.Name
261-
opts.DefaultChartVersion = chart.Metadata.Version
225+
Chart: chart.Metadata.Name,
226+
DefaultChartVersion: chart.Metadata.Version,
227+
DefaultChartName: chart.Metadata.Name,
228+
DefaultChartAPIVersion: chart.Metadata.APIVersion,
229+
ExtraLabels: c.labels,
230+
ExtraAnnotations: extraAnnotations,
231+
KubeContext: c.opts.KubeContext,
232+
NoInstallCRDs: true,
233+
ReleaseHistoryLimit: int(c.opts.HistoryMax),
234+
ReleaseLabels: releaseLabels,
235+
ReleaseStorageDriver: c.opts.HelmDriver,
236+
Timeout: c.opts.Timeout,
237+
ValuesFilesPaths: valuesPaths,
238+
ValuesSets: setValues,
239+
ForceAdoption: true,
240+
NoPodLogs: true,
262241
}
263242

264243
if err = c.actions.ReleaseInstall(context.TODO(), releaseName, namespace, opts); err != nil {
@@ -407,37 +386,21 @@ func (c *NelmClient) Render(releaseName string, chart *chart.Chart, valuesPaths,
407386

408387
// Prepare chart render options based on whether this is a virtual chart
409388
renderOpts := action.ChartRenderOptions{
410-
OutputFilePath: "/dev/null", // No output file, we want to return the manifest as a string
411-
ExtraLabels: c.labels,
412-
ExtraAnnotations: extraAnnotations,
413-
KubeContext: c.opts.KubeContext,
414-
ReleaseName: releaseName,
415-
ReleaseNamespace: namespace,
416-
ReleaseStorageDriver: c.opts.HelmDriver,
417-
Remote: true,
418-
ValuesFilesPaths: valuesPaths,
419-
ValuesSets: setValues,
420-
ForceAdoption: true,
421-
}
422-
423-
if c.virtualChart {
424-
// For virtual charts, use default chart fields and empty chart path
425-
// The chart object passed to this method already contains filtered files
426-
c.logger.Info("NELM Render: Using virtual chart mode",
427-
slog.String("defaultName", chart.Metadata.Name),
428-
slog.String("defaultVersion", chart.Metadata.Version),
429-
slog.String("defaultAPIVersion", chart.Metadata.APIVersion),
430-
slog.String("modulePath", c.modulePath),
431-
slog.Bool("usePrebuiltChart", true))
432-
renderOpts.Chart = ""
433-
renderOpts.DefaultChartAPIVersion = chart.Metadata.APIVersion
434-
renderOpts.DefaultChartName = chart.Metadata.Name
435-
renderOpts.DefaultChartVersion = chart.Metadata.Version
436-
} else {
437-
// For regular charts, use the module path
438-
c.logger.Info("NELM Render: Using regular chart mode",
439-
slog.String("chartPath", c.modulePath))
440-
renderOpts.Chart = c.modulePath
389+
Chart: chart.ChartPath(),
390+
DefaultChartAPIVersion: chart.Metadata.APIVersion,
391+
DefaultChartName: chart.Metadata.Name,
392+
DefaultChartVersion: chart.Metadata.Version,
393+
OutputFilePath: "/dev/null", // No output file, we want to return the manifest as a string
394+
ExtraLabels: c.labels,
395+
ExtraAnnotations: extraAnnotations,
396+
KubeContext: c.opts.KubeContext,
397+
ReleaseName: releaseName,
398+
ReleaseNamespace: namespace,
399+
ReleaseStorageDriver: c.opts.HelmDriver,
400+
Remote: true,
401+
ValuesFilesPaths: valuesPaths,
402+
ValuesSets: setValues,
403+
ForceAdoption: true,
441404
}
442405

443406
chartRenderResult, err := c.actions.ChartRender(context.TODO(), renderOpts)

pkg/module_manager/models/modules/helm.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ func (hm *HelmModule) RunHelmInstall(ctx context.Context, logLabels map[string]s
312312
}
313313

314314
helmClient := hm.dependencies.HelmClientFactory.NewClient(hm.logger.Named("helm-client"), helmClientOptions...)
315-
helmClient.WithVirtualChart(!hm.hasChartFile)
316315

317316
if state == Unmanaged {
318317
isUnmanaged, err := helmClient.GetReleaseLabels(helmReleaseName, LabelMaintenanceNoResourceReconciliation)
@@ -559,7 +558,6 @@ func (hm *HelmModule) Render(namespace string, debug bool, state MaintenanceStat
559558
}
560559

561560
helmClient := hm.dependencies.HelmClientFactory.NewClient(hm.logger.Named("helm-client"), helmClientOptions...)
562-
helmClient.WithVirtualChart(!hm.hasChartFile)
563561

564562
return helmClient.Render(hm.name, moduleChart, []string{valuesPath}, nil, releaseLabels, namespace, debug)
565563
}

0 commit comments

Comments
 (0)