@@ -11,15 +11,6 @@ import (
11
11
"sigs.k8s.io/e2e-framework/third_party/helm"
12
12
)
13
13
14
- type HelmArguments struct {
15
- Name string
16
- Namespace string
17
- Chart string
18
- Version string
19
- ValuesFilePath string
20
- OciRepository string
21
- }
22
-
23
14
func NewHelmManager (kubeConfigFile string ) * helm.Manager {
24
15
return helm .New (kubeConfigFile )
25
16
}
@@ -29,54 +20,45 @@ func AddHelmRepository(helmMgr *helm.Manager, repoURL, chartName string) error {
29
20
}
30
21
31
22
func DeployHelmChart (helmMgr * helm.Manager , src argo.ApplicationSource , namespace string ) error {
32
- opts , err := buildHelmArguments (src , namespace )
23
+ opts , err := buildHelmOptions (src , namespace )
33
24
if err != nil {
34
25
return fmt .Errorf ("building helm options: %w" , err )
35
26
}
36
27
37
- options := []helm.Option {
38
- helm .WithName (opts .Name ),
39
- helm .WithNamespace (opts .Namespace ),
40
- helm .WithChart (opts .Chart ),
41
- helm .WithVersion (opts .Version ),
42
- helm .WithArgs ("--install" , "--create-namespace" ),
43
- }
44
-
45
- if opts .ValuesFilePath != "" {
46
- options = append (options , helm .WithArgs ("-f" , opts .ValuesFilePath ))
47
- }
48
-
49
- if err := helmMgr .RunUpgrade (options ... ); err != nil {
28
+ if err := helmMgr .RunUpgrade (opts ... ); err != nil {
50
29
return fmt .Errorf ("helm upgrade/install failed: %w" , err )
51
30
}
52
31
53
32
return nil
54
33
}
55
34
56
- func buildHelmArguments (src argo.ApplicationSource , namespace string ) (* HelmArguments , error ) {
57
- opts := & HelmArguments {
58
- Name : src .Chart ,
59
- Namespace : namespace ,
60
- Version : src .TargetRevision ,
61
- }
62
-
35
+ func buildHelmOptions (src argo.ApplicationSource , namespace string ) ([]helm.Option , error ) {
36
+ chart := ""
63
37
if strings .HasPrefix (src .RepoURL , "oci://" ) {
64
38
base := strings .TrimSuffix (src .RepoURL , "/" )
65
- opts .Chart = fmt .Sprintf ("%s/%s" , base , src .Chart )
66
- opts .OciRepository = ""
39
+ chart = fmt .Sprintf ("%s/%s" , base , src .Chart )
67
40
} else {
68
- opts .Chart = fmt .Sprintf ("%s/%s" , src .Chart , src .Chart )
41
+ chart = fmt .Sprintf ("%s/%s" , src .Chart , src .Chart )
42
+ }
43
+
44
+ options := []helm.Option {
45
+ helm .WithName (src .Chart ),
46
+ helm .WithNamespace (namespace ),
47
+ helm .WithChart (chart ),
48
+ helm .WithVersion (src .TargetRevision ),
49
+ helm .WithArgs ("--install" , "--create-namespace" ),
69
50
}
70
51
71
52
if src .Helm != nil && src .Helm .Values != "" {
72
53
valuesFilePath , err := writeValuesFile (src .Chart , src .TargetRevision , src .Helm .Values )
73
54
if err != nil {
74
55
return nil , fmt .Errorf ("writing values file: %w" , err )
75
56
}
76
- opts .ValuesFilePath = valuesFilePath
57
+
58
+ options = append (options , helm .WithArgs ("-f" , valuesFilePath ))
77
59
}
78
60
79
- return opts , nil
61
+ return options , nil
80
62
}
81
63
82
64
func writeValuesFile (chart , revision , valuesContent string ) (string , error ) {
0 commit comments