| Giorgi Lekveishvili | 7c42760 | 2024-01-04 00:13:55 +0400 | [diff] [blame] | 1 | package installer |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "helm.sh/helm/v3/pkg/action" |
| 7 | "helm.sh/helm/v3/pkg/kube" |
| 8 | ) |
| 9 | |
| 10 | type ActionConfigFactory struct { |
| 11 | kubeConfigPath string |
| 12 | } |
| 13 | |
| 14 | func NewActionConfigFactory(kubeConfigPath string) ActionConfigFactory { |
| 15 | return ActionConfigFactory{kubeConfigPath} |
| 16 | } |
| 17 | |
| 18 | func (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 | } |