From c39fabf1debad0afb64ed5666be0315cc75e95af Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Mon, 11 Sep 2023 10:20:16 -0400 Subject: [PATCH] DXCDT-538: Adding progress spinner to `tf generate` command (#838) Adding progress spinners Co-authored-by: Will Vedder --- internal/cli/terraform.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/cli/terraform.go b/internal/cli/terraform.go index 27d2d6857..5a2aadef3 100644 --- a/internal/cli/terraform.go +++ b/internal/cli/terraform.go @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/terraform-exec/tfexec" "github.com/spf13/cobra" + "github.com/auth0/auth0-cli/internal/ansi" "github.com/auth0/auth0-cli/internal/auth0" "github.com/auth0/auth0-cli/internal/prompt" ) @@ -144,7 +145,11 @@ func generateTerraformCmdRun(cli *cli, inputs *terraformInputs) func(cmd *cobra. return err } - data, err := fetchImportData(cmd.Context(), resources...) + var data importDataList + err = ansi.Spinner("Fetching data from Auth0", func() error { + data, err = fetchImportData(cmd.Context(), resources...) + return err + }) if err != nil { return err } @@ -162,7 +167,11 @@ func generateTerraformCmdRun(cli *cli, inputs *terraformInputs) func(cmd *cobra. } if terraformProviderCredentialsAreAvailable() { - if err := generateTerraformResourceConfig(cmd.Context(), inputs.OutputDIR); err == nil { + err = ansi.Spinner("Generating Terraform configuration", func() error { + return generateTerraformResourceConfig(cmd.Context(), inputs.OutputDIR) + }) + + if err == nil { cli.renderer.Infof("Terraform resource config files generated successfully in: %q", inputs.OutputDIR) cli.renderer.Infof( "Review the config and generate the terraform state by running: \n\n cd %s && ./terraform apply",