feat(cli): Added an auto approve flag for apply
All checks were successful
ci / goreleaser (push) Successful in 1m53s
All checks were successful
ci / goreleaser (push) Successful in 1m53s
This commit is contained in:
parent
975b5ad525
commit
51ce4ed111
1 changed files with 7 additions and 5 deletions
12
cmd/apply.go
12
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")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue