@@ -430,6 +430,7 @@ func editEnvCmd() *cobra.Command {
430
430
gpus int
431
431
follow bool
432
432
user string
433
+ force bool
433
434
)
434
435
435
436
cmd := & cobra.Command {
@@ -482,6 +483,19 @@ coder envs edit back-end-env --disk 20`,
482
483
return err
483
484
}
484
485
486
+ if ! force && env .LatestStat .ContainerStatus == coder .EnvironmentOn {
487
+ _ , err = (& promptui.Prompt {
488
+ Label : fmt .Sprintf ("Rebuild environment \" %s\" ? (will destroy any work outside of /home)" , env .Name ),
489
+ IsConfirm : true ,
490
+ }).Run ()
491
+ if err != nil {
492
+ return clog .Fatal (
493
+ "failed to confirm prompt" , clog .BlankLine ,
494
+ clog .Tipf (`use "--force" to rebuild without a confirmation prompt` ),
495
+ )
496
+ }
497
+ }
498
+
485
499
if err := client .EditEnvironment (ctx , env .ID , * req ); err != nil {
486
500
return xerrors .Errorf ("failed to apply changes to environment %q: %w" , envName , err )
487
501
}
@@ -510,6 +524,7 @@ coder envs edit back-end-env --disk 20`,
510
524
cmd .Flags ().IntVarP (& gpus , "gpu" , "g" , 0 , "The amount of disk storage to provision the environment with." )
511
525
cmd .Flags ().BoolVar (& follow , "follow" , false , "follow buildlog after initiating rebuild" )
512
526
cmd .Flags ().StringVar (& user , "user" , coder .Me , "Specify the user whose resources to target" )
527
+ cmd .Flags ().BoolVar (& force , "force" , false , "force rebuild without showing a confirmation prompt" )
513
528
return cmd
514
529
}
515
530
0 commit comments