Skip to content

Commit 5cf69e8

Browse files
ldmonsteryalosevCopilot
authored
[addon-operator] Remove helm binary using (#597)
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com> Signed-off-by: Yuriy Losev <yuriy.losev@flant.com> Co-authored-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com> Co-authored-by: Yuriy Losev <yuriy.losev@flant.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d6ab5ae commit 5cf69e8

File tree

10 files changed

+14
-753
lines changed

10 files changed

+14
-753
lines changed

docs/src/RUNNING.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,7 @@ Default is `heritage=addon-operator`.
8383

8484
### Helm settings
8585

86-
Addon-operator expects that "helm" binary is available in $PATH. It detects Helm version at start by executing "helm --help" command. If this is not appropriate by some reasons, you can use these settings:
87-
88-
**HELM_BIN_PATH** — a path to a Helm binary.
89-
90-
**HELM_POST_RENDERER_PATH** — a path to a Helm post-renderer binary.
91-
92-
**HELM3** — set to "yes" to disable auto-detection and explicitly enable compatibility with helm3.
86+
Addon-operator works with helm by using internal lib
9387

9488
**HELM_IGNORE_RELEASE** — a name of the release that should not be treated as the module's release. Prevent self-destruction when addon-operator release is stored in the same namespace as releases for modules.
9589

pkg/helm/helm.go

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package helm
22

33
import (
4-
"log/slog"
54
"maps"
65
"time"
76

87
"github.com/deckhouse/deckhouse/pkg/log"
98

109
"github.com/flant/addon-operator/pkg/helm/client"
11-
"github.com/flant/addon-operator/pkg/helm/helm3"
1210
"github.com/flant/addon-operator/pkg/helm/helm3lib"
1311
)
1412

@@ -54,42 +52,28 @@ type Options struct {
5452
}
5553

5654
func InitHelmClientFactory(helmopts *Options, labels map[string]string) (*ClientFactory, error) {
57-
helmVersion, err := DetectHelmVersion()
55+
_, err := DetectHelmVersion()
5856
if err != nil {
5957
return nil, err
6058
}
6159

6260
factory := new(ClientFactory)
6361
factory.labels = labels
6462

65-
switch helmVersion {
66-
case Helm3Lib:
67-
log.Info("Helm3Lib detected. Use builtin Helm.")
68-
factory.ClientType = Helm3Lib
69-
factory.NewClientFn = helm3lib.NewClient
70-
err = helm3lib.Init(&helm3lib.Options{
71-
Namespace: helmopts.Namespace,
72-
HistoryMax: helmopts.HistoryMax,
73-
Timeout: helmopts.Timeout,
74-
HelmIgnoreRelease: helmopts.HelmIgnoreRelease,
75-
}, helmopts.Logger)
76-
77-
case Helm3:
78-
log.Info("Helm 3 detected", slog.String("path", helm3.Helm3Path))
79-
// Use helm3 client.
80-
factory.ClientType = Helm3
81-
factory.NewClientFn = helm3.NewClient
82-
err = helm3.Init(&helm3.Helm3Options{
83-
Namespace: helmopts.Namespace,
84-
HistoryMax: helmopts.HistoryMax,
85-
Timeout: helmopts.Timeout,
86-
HelmIgnoreRelease: helmopts.HelmIgnoreRelease,
87-
Logger: helmopts.Logger,
88-
})
89-
}
63+
log.Info("Helm3Lib detected. Use builtin Helm.")
64+
65+
factory.ClientType = Helm3Lib
66+
factory.NewClientFn = helm3lib.NewClient
9067

68+
err = helm3lib.Init(&helm3lib.Options{
69+
Namespace: helmopts.Namespace,
70+
HistoryMax: helmopts.HistoryMax,
71+
Timeout: helmopts.Timeout,
72+
HelmIgnoreRelease: helmopts.HelmIgnoreRelease,
73+
}, helmopts.Logger)
9174
if err != nil {
9275
return nil, err
9376
}
77+
9478
return factory, nil
9579
}

0 commit comments

Comments
 (0)