@@ -194,53 +194,55 @@ impl WorkflowPlanner {
194194
195195 last_tasks = vec ! [ "workflow:deployment-plan" . to_string( ) ] ;
196196
197- if self . profile . approval == crate :: workflow:: profile:: ApprovalMode :: Prompt {
198- effects. prompts_user = true ;
199- tasks. push ( WorkflowTaskPlan {
200- id : "workflow:approval" . to_string ( ) ,
201- label : "Approval" . to_string ( ) ,
202- kind : WorkflowTaskKind :: Approval ,
203- dependencies : last_tasks. clone ( ) ,
204- effects : WorkflowEffects {
205- prompts_user : true ,
206- ..Default :: default ( )
207- } ,
208- description : "Ask for local confirmation before applying deployment changes."
209- . to_string ( ) ,
210- } ) ;
211-
212- for t in & last_tasks {
213- edges. push ( WorkflowEdge {
214- from : t. clone ( ) ,
215- to : "workflow:approval" . to_string ( ) ,
197+ if self . profile . deploy == crate :: workflow:: profile:: WorkflowStepMode :: Run {
198+ if self . profile . approval == crate :: workflow:: profile:: ApprovalMode :: Prompt {
199+ effects. prompts_user = true ;
200+ tasks. push ( WorkflowTaskPlan {
201+ id : "workflow:approval" . to_string ( ) ,
202+ label : "Approval" . to_string ( ) ,
203+ kind : WorkflowTaskKind :: Approval ,
204+ dependencies : last_tasks. clone ( ) ,
205+ effects : WorkflowEffects {
206+ prompts_user : true ,
207+ ..Default :: default ( )
208+ } ,
209+ description :
210+ "Ask for local confirmation before applying deployment changes."
211+ . to_string ( ) ,
216212 } ) ;
217- }
218213
219- last_tasks = vec ! [ "workflow:approval" . to_string( ) ] ;
220- }
214+ for t in & last_tasks {
215+ edges. push ( WorkflowEdge {
216+ from : t. clone ( ) ,
217+ to : "workflow:approval" . to_string ( ) ,
218+ } ) ;
219+ }
221220
222- if self . profile . deploy == crate :: workflow:: profile:: WorkflowStepMode :: Run
223- && self . profile . apply
224- {
225- effects. mutates_cluster = true ;
226- tasks. push ( WorkflowTaskPlan {
227- id : "workflow:deploy" . to_string ( ) ,
228- label : "Deploy" . to_string ( ) ,
229- kind : WorkflowTaskKind :: Deploy ,
230- dependencies : last_tasks. clone ( ) ,
231- effects : WorkflowEffects {
232- mutates_cluster : true ,
233- ..Default :: default ( )
234- } ,
235- description : "Apply generated manifests to the configured Kubernetes context."
236- . to_string ( ) ,
237- } ) ;
221+ last_tasks = vec ! [ "workflow:approval" . to_string( ) ] ;
222+ }
238223
239- for t in & last_tasks {
240- edges. push ( WorkflowEdge {
241- from : t. clone ( ) ,
242- to : "workflow:deploy" . to_string ( ) ,
224+ if self . profile . apply {
225+ effects. mutates_cluster = true ;
226+ tasks. push ( WorkflowTaskPlan {
227+ id : "workflow:deploy" . to_string ( ) ,
228+ label : "Deploy" . to_string ( ) ,
229+ kind : WorkflowTaskKind :: Deploy ,
230+ dependencies : last_tasks. clone ( ) ,
231+ effects : WorkflowEffects {
232+ mutates_cluster : true ,
233+ ..Default :: default ( )
234+ } ,
235+ description :
236+ "Apply generated manifests to the configured Kubernetes context."
237+ . to_string ( ) ,
243238 } ) ;
239+
240+ for t in & last_tasks {
241+ edges. push ( WorkflowEdge {
242+ from : t. clone ( ) ,
243+ to : "workflow:deploy" . to_string ( ) ,
244+ } ) ;
245+ }
244246 }
245247 }
246248 }
@@ -368,24 +370,48 @@ impl WorkflowPlanner {
368370 . clone ( )
369371 . unwrap_or_else ( || "default" . to_string ( ) ) ;
370372
373+ let is_static_plan =
374+ self . profile . deploy == crate :: workflow:: profile:: WorkflowStepMode :: Plan ;
375+
371376 task = task. exec_fn ( move |_ctx| {
372377 let env_name = env_name. clone ( ) ;
373378 let context = context. clone ( ) ;
374379 let namespace = namespace. clone ( ) ;
375380 async move {
376381 crate :: LOGGER . info ( "Deployment plan:" ) ;
377- let plan =
378- crate :: plan:: generate_deployment_plan ( & env_name, & context, & namespace)
379- . await
380- . map_err ( |e| anyhow:: anyhow!( "Deployment plan failed: {}" , e) ) ?;
381-
382- crate :: plan:: validate_plan_safety ( & plan)
383- . map_err ( |e| anyhow:: anyhow!( "Deployment plan validation failed: {}" , e) ) ?;
384-
385- // Display is a method on DeploymentPlan
386- // Wait, let's look at src/plan.rs to see how to print the plan.
387- // Actually, the spec says `plan.display()`, maybe that exists.
388- // Let's assume there is a way to display.
382+
383+ if is_static_plan {
384+ let plan = crate :: workflow:: plan:: generate_static_deployment_plan (
385+ & env_name, & context, & namespace,
386+ )
387+ . map_err ( |e| anyhow:: anyhow!( "Static deployment plan failed: {}" , e) ) ?;
388+
389+ println ! ( "Sailr deployment plan:" ) ;
390+ println ! ( " environment: {}" , plan. environment) ;
391+ println ! ( " context: {}" , plan. context) ;
392+ println ! ( " namespace: {}" , plan. namespace) ;
393+ println ! ( " mode: static" ) ;
394+ println ! ( " requires cluster: no" ) ;
395+ println ! ( " mutates cluster: no\n " ) ;
396+ println ! ( "Resources:" ) ;
397+ for res in plan. resources {
398+ println ! ( " - {} {} \t would apply" , res. kind, res. name) ;
399+ }
400+ } else {
401+ let plan =
402+ crate :: plan:: generate_deployment_plan ( & env_name, & context, & namespace)
403+ . await
404+ . map_err ( |e| anyhow:: anyhow!( "Deployment plan failed: {}" , e) ) ?;
405+
406+ crate :: plan:: validate_plan_safety ( & plan) . map_err ( |e| {
407+ anyhow:: anyhow!( "Deployment plan validation failed: {}" , e)
408+ } ) ?;
409+
410+ // Display is a method on DeploymentPlan
411+ // Wait, let's look at src/plan.rs to see how to print the plan.
412+ // Actually, the spec says `plan.display()`, maybe that exists.
413+ // Let's assume there is a way to display.
414+ }
389415
390416 Ok ( ( ) )
391417 }
0 commit comments