diff --git a/cmd/apply.go b/cmd/apply.go index 22c26d8..41e94e9 100644 --- a/cmd/apply.go +++ b/cmd/apply.go @@ -16,8 +16,9 @@ import ( ) var ( - configFile string - dryRun bool + configFile string + dryRun bool + autoApprove bool ) var applyCmd = &cobra.Command{ @@ -33,14 +34,14 @@ the necessary changes to deploy your applications across multiple cloudlets.`, os.Exit(1) } - if err := runApply(configFile, dryRun); err != nil { + if err := runApply(configFile, dryRun, autoApprove); err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) os.Exit(1) } }, } -func runApply(configPath string, isDryRun bool) error { +func runApply(configPath string, isDryRun bool, autoApprove bool) error { // Step 1: Validate and resolve config file path absPath, err := filepath.Abs(configPath) if err != nil { @@ -112,7 +113,7 @@ func runApply(configPath string, isDryRun bool) error { fmt.Printf("\nThis will perform %d actions. Estimated time: %v\n", result.Plan.TotalActions, result.Plan.EstimatedDuration) - if !confirmDeployment() { + if !autoApprove && !confirmDeployment() { fmt.Println("Deployment cancelled.") return nil } @@ -170,6 +171,7 @@ func init() { applyCmd.Flags().StringVarP(&configFile, "file", "f", "", "configuration file path (required)") applyCmd.Flags().BoolVar(&dryRun, "dry-run", false, "preview changes without applying them") + applyCmd.Flags().BoolVar(&autoApprove, "auto-approve", false, "automatically approve the deployment plan") applyCmd.MarkFlagRequired("file") }