blob: 1f805b9a2581abb276c12cceb648dce36e8fb324 [file] [log] [blame]
Giorgi Lekveishvili7c427602024-01-04 00:13:55 +04001package installer
2
3import (
4 "fmt"
5
6 "helm.sh/helm/v3/pkg/action"
7 "helm.sh/helm/v3/pkg/kube"
8)
9
10type ActionConfigFactory struct {
11 kubeConfigPath string
12}
13
14func NewActionConfigFactory(kubeConfigPath string) ActionConfigFactory {
15 return ActionConfigFactory{kubeConfigPath}
16}
17
18func (f ActionConfigFactory) New(namespace string) (*action.Configuration, error) {
19 config := new(action.Configuration)
20 if err := config.Init(
21 kube.GetConfig(f.kubeConfigPath, "", namespace),
22 namespace,
23 "",
24 func(fmtString string, args ...any) {
25 fmt.Printf(fmtString, args...)
26 fmt.Println()
27 },
28 ); err != nil {
29 return nil, err
30 }
31 return config, nil
32}