cli: add output before long-running actions

This commit is contained in:
Thomas Tendyck 2022-04-05 09:11:45 +02:00 committed by Thomas Tendyck
parent daf2280e3f
commit 7315e80374
3 changed files with 12 additions and 5 deletions

View File

@ -9,10 +9,6 @@ import (
"io/fs" "io/fs"
"net" "net"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
"github.com/edgelesssys/constellation/cli/azure" "github.com/edgelesssys/constellation/cli/azure"
"github.com/edgelesssys/constellation/cli/file" "github.com/edgelesssys/constellation/cli/file"
"github.com/edgelesssys/constellation/cli/gcp" "github.com/edgelesssys/constellation/cli/gcp"
@ -23,6 +19,10 @@ import (
"github.com/edgelesssys/constellation/coordinator/util" "github.com/edgelesssys/constellation/coordinator/util"
"github.com/edgelesssys/constellation/internal/config" "github.com/edgelesssys/constellation/internal/config"
"github.com/edgelesssys/constellation/internal/state" "github.com/edgelesssys/constellation/internal/state"
"github.com/kr/text"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
) )
func newInitCmd() *cobra.Command { func newInitCmd() *cobra.Command {
@ -94,6 +94,7 @@ func initialize(ctx context.Context, cmd *cobra.Command, protCl protoClient, vpn
} }
} }
cmd.Println("Creating service account ...")
serviceAccount, stat, err := serviceAccountCr.createServiceAccount(ctx, stat, config) serviceAccount, stat, err := serviceAccountCr.createServiceAccount(ctx, stat, config)
if err != nil { if err != nil {
return err return err
@ -108,6 +109,7 @@ func initialize(ctx context.Context, cmd *cobra.Command, protCl protoClient, vpn
} }
endpoints := ipsToEndpoints(append(coordinators.PublicIPs(), nodes.PublicIPs()...), *config.CoordinatorPort) endpoints := ipsToEndpoints(append(coordinators.PublicIPs(), nodes.PublicIPs()...), *config.CoordinatorPort)
cmd.Println("Waiting for cloud provider to finish resource creation ...")
if err := waiter.WaitForAll(ctx, endpoints, coordinatorstate.AcceptingInit); err != nil { if err := waiter.WaitForAll(ctx, endpoints, coordinatorstate.AcceptingInit); err != nil {
return fmt.Errorf("failed to wait for peer status: %w", err) return fmt.Errorf("failed to wait for peer status: %w", err)
} }
@ -158,7 +160,9 @@ func activate(ctx context.Context, cmd *cobra.Command, client protoClient, input
return activationResult{}, err return activationResult{}, err
} }
if err := respCl.WriteLogStream(cmd.OutOrStdout()); err != nil { indentOut := text.NewIndentWriter(cmd.OutOrStdout(), []byte{'\t'})
cmd.Println("Activating the cluster ...")
if err := respCl.WriteLogStream(indentOut); err != nil {
return activationResult{}, err return activationResult{}, err
} }

View File

@ -48,6 +48,8 @@ func terminate(cmd *cobra.Command, fileHandler file.Handler, config *config.Conf
return err return err
} }
cmd.Println("Terminating ...")
if len(stat.EC2Instances) != 0 || stat.EC2SecurityGroup != "" { if len(stat.EC2Instances) != 0 || stat.EC2SecurityGroup != "" {
ec2client, err := ec2.NewFromDefault(cmd.Context()) ec2client, err := ec2.NewFromDefault(cmd.Context())
if err != nil { if err != nil {

1
go.mod
View File

@ -71,6 +71,7 @@ require (
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
github.com/googleapis/gax-go/v2 v2.2.0 github.com/googleapis/gax-go/v2 v2.2.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/kr/text v0.2.0
github.com/martinjungblut/go-cryptsetup v0.0.0-20220317181052-e70d6b615049 github.com/martinjungblut/go-cryptsetup v0.0.0-20220317181052-e70d6b615049
github.com/schollz/progressbar/v3 v3.8.6 github.com/schollz/progressbar/v3 v3.8.6
github.com/spf13/afero v1.8.2 github.com/spf13/afero v1.8.2