9
9
"os"
10
10
"path"
11
11
12
+ "github.com/alexellis/arkade/pkg/apps"
12
13
"github.com/alexellis/arkade/pkg/k8s"
14
+ "github.com/alexellis/arkade/pkg/types"
13
15
14
16
"github.com/alexellis/arkade/pkg"
15
17
"github.com/alexellis/arkade/pkg/config"
@@ -34,14 +36,6 @@ func MakeInstallSealedSecrets() *cobra.Command {
34
36
command .RunE = func (command * cobra.Command , args []string ) error {
35
37
36
38
wait , _ := command .Flags ().GetBool ("wait" )
37
- kubeConfigPath := config .GetDefaultKubeconfig ()
38
-
39
- if command .Flags ().Changed ("kubeconfig" ) {
40
- kubeConfigPath , _ = command .Flags ().GetString ("kubeconfig" )
41
- }
42
-
43
- fmt .Printf ("Using kubeconfig: %s\n " , kubeConfigPath )
44
-
45
39
namespace , _ := command .Flags ().GetString ("namespace" )
46
40
47
41
arch := k8s .GetNodeArchitecture ()
@@ -64,22 +58,7 @@ func MakeInstallSealedSecrets() *cobra.Command {
64
58
65
59
os .Setenv ("HELM_HOME" , path .Join (userPath , ".helm" ))
66
60
67
- _ , err = helm .TryDownloadHelm (userPath , clientArch , clientOS )
68
- if err != nil {
69
- return err
70
- }
71
-
72
61
updateRepo , _ := command .Flags ().GetBool ("update-repo" )
73
- err = helm .AddHelmRepo ("stable" , "https://kubernetes-charts.storage.googleapis.com/" , updateRepo )
74
- if err != nil {
75
- return fmt .Errorf ("unable to add repo %s" , err )
76
- }
77
-
78
- err = helm .FetchChart ("stable/sealed-secrets" , defaultVersion )
79
-
80
- if err != nil {
81
- return fmt .Errorf ("unable fetch chart %s" , err )
82
- }
83
62
84
63
overrides := map [string ]string {}
85
64
@@ -92,11 +71,31 @@ func MakeInstallSealedSecrets() *cobra.Command {
92
71
return err
93
72
}
94
73
95
- err = helm .Helm3Upgrade ("stable/sealed-secrets" ,
96
- namespace , "values.yaml" , defaultVersion , overrides , wait )
74
+ sealedSecretAppOptions := types .DefaultInstallOptions ().
75
+ WithNamespace (namespace ).
76
+ WithHelmPath (path .Join (userPath , ".helm" )).
77
+ WithHelmRepo ("stable/sealed-secrets" ).
78
+ WithHelmURL ("https://charts.helm.sh/stable" ).
79
+ WithOverrides (overrides ).
80
+ WithHelmUpdateRepo (updateRepo ).
81
+ WithWait (wait )
82
+
83
+ if command .Flags ().Changed ("kubeconfig" ) {
84
+ kubeConfigPath , _ := command .Flags ().GetString ("kubeconfig" )
85
+ fmt .Printf ("Using kubeconfig: %s\n " , kubeConfigPath )
86
+ sealedSecretAppOptions .WithKubeconfigPath (kubeConfigPath )
87
+ }
88
+
89
+ _ , err = helm .TryDownloadHelm (userPath , clientArch , clientOS )
97
90
if err != nil {
98
- return fmt .Errorf ("unable to sealed secret chart with helm %s" , err )
91
+ return err
92
+ }
93
+
94
+ _ , err = apps .MakeInstallChart (sealedSecretAppOptions )
95
+ if err != nil {
96
+ return err
99
97
}
98
+
100
99
fmt .Println (SealedSecretsPostInstallMsg )
101
100
return nil
102
101
}
0 commit comments