@@ -69,20 +69,23 @@ struct Opt {
69
69
/// Secrets folder where the secrets are read from
70
70
#[ structopt( short, long, default_value = "./secrets" , env) ]
71
71
secrets_folder : String ,
72
+
73
+ /// Local cluster tool. Options: kind, minikube, auto. Default: Auto
74
+ #[ structopt( long, env) ]
75
+ local_cluster_tool : Option < String > ,
76
+ }
77
+
78
+ #[ derive( Debug ) ]
79
+ enum ClusterTool {
80
+ Kind ,
81
+ Minikube ,
72
82
}
73
83
74
84
enum Branch {
75
85
Base ,
76
86
Target ,
77
87
}
78
88
79
- fn apps_file ( branch : & Branch ) -> & ' static str {
80
- match branch {
81
- Branch :: Base => "apps_base_branch.yaml" ,
82
- Branch :: Target => "apps_target_branch.yaml" ,
83
- }
84
- }
85
-
86
89
impl std:: fmt:: Display for Branch {
87
90
fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
88
91
match self {
@@ -92,6 +95,13 @@ impl std::fmt::Display for Branch {
92
95
}
93
96
}
94
97
98
+ fn apps_file ( branch : & Branch ) -> & ' static str {
99
+ match branch {
100
+ Branch :: Base => "apps_base_branch.yaml" ,
101
+ Branch :: Target => "apps_target_branch.yaml" ,
102
+ }
103
+ }
104
+
95
105
static ERROR_MESSAGES : [ & str ; 6 ] = [
96
106
"helm template ." ,
97
107
"authentication required" ,
@@ -135,7 +145,20 @@ async fn main() -> Result<(), Box<dyn Error>> {
135
145
let output_folder = opt. output_folder . as_str ( ) ;
136
146
let secrets_folder = opt. secrets_folder . as_str ( ) ;
137
147
148
+ // select local cluster tool
149
+ let tool = match opt. local_cluster_tool {
150
+ Some ( t) if t == "kind" => ClusterTool :: Kind ,
151
+ Some ( t) if t == "minikube" => ClusterTool :: Minikube ,
152
+ _ if kind:: is_installed ( ) . await => ClusterTool :: Kind ,
153
+ _ if minikube:: is_installed ( ) . await => ClusterTool :: Minikube ,
154
+ _ => {
155
+ error ! ( "❌ No local cluster tool found. Please install kind or minikube" ) ;
156
+ panic ! ( "No local cluster tool found" )
157
+ }
158
+ } ;
159
+
138
160
info ! ( "✨ Running with:" ) ;
161
+ info ! ( "✨ - local-cluster-tool: {:?}" , tool) ;
139
162
info ! ( "✨ - base-branch: {}" , base_branch_name) ;
140
163
info ! ( "✨ - target-branch: {}" , target_branch_name) ;
141
164
info ! ( "✨ - base-branch-folder: {}" , base_branch_folder) ;
@@ -163,7 +186,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
163
186
164
187
let cluster_name = "argocd-diff-preview" ;
165
188
166
- kind:: create_cluster ( & cluster_name) . await ?;
189
+ match tool {
190
+ ClusterTool :: Kind => kind:: create_cluster ( & cluster_name) . await ?,
191
+ ClusterTool :: Minikube => minikube:: create_cluster ( ) . await ?,
192
+ }
167
193
argocd:: install_argo_cd ( ) . await ?;
168
194
169
195
create_folder_if_not_exists ( secrets_folder) ;
@@ -190,7 +216,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
190
216
tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 10 ) ) . await ;
191
217
get_resources ( & Branch :: Target , timeout, output_folder) . await ?;
192
218
193
- kind:: delete_cluster ( & cluster_name) ;
219
+ match tool {
220
+ ClusterTool :: Kind => kind:: delete_cluster ( & cluster_name) ,
221
+ ClusterTool :: Minikube => minikube:: delete_cluster ( ) ,
222
+ }
194
223
195
224
diff:: generate_diff (
196
225
output_folder,
0 commit comments