MCPcopy Create free account
hub / github.com/auth0/auth0-cli / checkOutputDirectoryIsEmpty

Function checkOutputDirectoryIsEmpty

internal/cli/terraform.go:438–464  ·  view source on GitHub ↗
(cli *cli, cmd *cobra.Command, outputDIR string)

Source from the content-addressed store, hash-verified

436}
437
438func checkOutputDirectoryIsEmpty(cli *cli, cmd *cobra.Command, outputDIR string) bool {
439 _, err := os.Stat(outputDIR)
440 if os.IsNotExist(err) {
441 return true
442 }
443
444 _, mainFileErr := os.Stat(path.Join(outputDIR, "auth0_main.tf"))
445 _, importFileErr := os.Stat(path.Join(outputDIR, "auth0_import.tf"))
446 _, generatedFileErr := os.Stat(path.Join(outputDIR, "auth0_generated.tf"))
447 if os.IsNotExist(mainFileErr) && os.IsNotExist(importFileErr) && os.IsNotExist(generatedFileErr) {
448 return true
449 }
450
451 cli.renderer.Warnf(
452 "Output directory %q is not empty. "+
453 "Proceeding will overwrite the auth0_main.tf, auth0_import.tf and auth0_generated.tf files.",
454 outputDIR,
455 )
456
457 if !cli.force && canPrompt(cmd) {
458 if confirmed := prompt.Confirm("Are you sure you want to proceed?"); !confirmed {
459 return false
460 }
461 }
462
463 return true
464}
465
466func cleanOutputDirectory(outputDIR string) error {
467 var joinedErrors error

Callers 2

generateTerraformCmdRunFunction · 0.85

Calls 3

ConfirmFunction · 0.92
canPromptFunction · 0.85
WarnfMethod · 0.80

Tested by 1