Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/cmd/beta/alb/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Creating loadbalancer")
_, err = wait.CreateOrUpdateLoadbalancerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, *resp.Name).WaitWithContext(ctx)
err := spinner.Run(params.Printer, "Creating loadbalancer", func() error {
_, err := wait.CreateOrUpdateLoadbalancerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, *resp.Name).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("wait for loadbalancer creation: %w", err)
}
s.Stop()
}

return outputResult(params.Printer, model, projectLabel, resp)
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/beta/alb/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ func NewCmd(params *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(params.Printer)
s.Start("updating loadbalancer")
_, err = wait.CreateOrUpdateLoadbalancerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, *resp.Name).
WaitWithContext(ctx)
err := spinner.Run(params.Printer, "updating loadbalancer", func() error {
_, err = wait.CreateOrUpdateLoadbalancerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, *resp.Name).
WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("wait for loadbalancer update: %w", err)
}
s.Stop()
}

return outputResult(params.Printer, model, projectLabel, resp)
Expand Down
19 changes: 9 additions & 10 deletions internal/cmd/beta/edge/instance/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,18 @@ func NewCmd(params *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Creating instance")
// The waiter handler needs a concrete client type. We can safely cast here as the real implementation will always match.
client, ok := apiClient.(*edge.APIClient)
if !ok {
return fmt.Errorf("failed to configure API client")
}
_, err = wait.CreateOrUpdateInstanceWaitHandler(ctx, client, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx)

err := spinner.Run(params.Printer, "Creating instance", func() error {
// The waiter handler needs a concrete concreteClient type. We can safely cast here as the real implementation will always match.
concreteClient, ok := apiClient.(*edge.APIClient)
if !ok {
return fmt.Errorf("failed to configure API concreteClient")
}
_, err = wait.CreateOrUpdateInstanceWaitHandler(ctx, concreteClient, model.ProjectId, model.Region, instanceId).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("wait for edge instance creation: %w", err)
}
s.Stop()
}

// Handle output to printer
Expand Down
29 changes: 15 additions & 14 deletions internal/cmd/beta/edge/instance/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,26 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
// Wait for async operation, if async mode not enabled
operationState := "Triggered deletion of"
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Deleting instance")
// Determine identifier and waiter to use
waiterFactory, err := getWaiterFactory(ctx, model)
if err != nil {
err := spinner.Run(params.Printer, "Deleting instance", func() error {
// Determine identifier and waiter to use
waiterFactory, err := getWaiterFactory(ctx, model)
if err != nil {
return err
}
// The waiter factory needs a concrete concreteClient type. We can safely cast here as the real implementation will always match.
concreteClient, ok := apiClient.(*edge.APIClient)
if !ok {
return fmt.Errorf("failed to configure API concreteClient")
}
waiter := waiterFactory(concreteClient)
_, err = waiter.WaitWithContext(ctx)
return err
}
// The waiter factory needs a concrete client type. We can safely cast here as the real implementation will always match.
client, ok := apiClient.(*edge.APIClient)
if !ok {
return fmt.Errorf("failed to configure API client")
}
waiter := waiterFactory(client)
})

if _, err = waiter.WaitWithContext(ctx); err != nil {
if err != nil {
return fmt.Errorf("wait for edge instance deletion: %w", err)
}
operationState = "Deleted"
s.Stop()
}

params.Printer.Info("%s instance with %q %q of project %q.\n", operationState, model.identifier.Flag, model.identifier.Value, projectLabel)
Expand Down
29 changes: 15 additions & 14 deletions internal/cmd/beta/edge/instance/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,26 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
if !model.Async {
// Wait for async operation, if async mode not enabled
// Show spinner while waiting
s := spinner.New(params.Printer)
s.Start("Updating instance")
// Determine identifier and waiter to use
waiterFactory, err := getWaiterFactory(ctx, model)
if err != nil {
err := spinner.Run(params.Printer, "Updating instance", func() error {
// Determine identifier and waiter to use
waiterFactory, err := getWaiterFactory(ctx, model)
if err != nil {
return err
}
// The waiter handler needs a concrete concreteClient type. We can safely cast here as the real implementation will always match.
concreteClient, ok := apiClient.(*edge.APIClient)
if !ok {
return fmt.Errorf("failed to configure API concreteClient")
}
waiter := waiterFactory(concreteClient)
_, err = waiter.WaitWithContext(ctx)
return err
}
// The waiter handler needs a concrete client type. We can safely cast here as the real implementation will always match.
client, ok := apiClient.(*edge.APIClient)
if !ok {
return fmt.Errorf("failed to configure API client")
}
waiter := waiterFactory(client)
})

if _, err = waiter.WaitWithContext(ctx); err != nil {
if err != nil {
return fmt.Errorf("wait for edge instance update: %w", err)
}
operationState = "Updated"
s.Stop()
}

params.Printer.Info("%s instance with %q %q of project %q.\n", operationState, model.identifier.Flag, model.identifier.Value, projectLabel)
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/intake/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ func NewCmd(p *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(p.Printer)
s.Start("Creating STACKIT Intake instance")
_, err = wait.CreateOrUpdateIntakeWaitHandler(ctx, apiClient, model.ProjectId, model.Region, resp.GetId()).WaitWithContext(ctx)
err := spinner.Run(p.Printer, "Creating STACKIT Intake instance", func() error {
_, err = wait.CreateOrUpdateIntakeWaitHandler(ctx, apiClient, model.ProjectId, model.Region, resp.GetId()).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("wait for STACKIT Instance creation: %w", err)
}
s.Stop()
}

return outputResult(p.Printer, model, projectLabel, resp)
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/intake/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ func NewCmd(p *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(p.Printer)
s.Start("Deleting STACKIT Intake instance")
_, err = wait.DeleteIntakeWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.IntakeId).WaitWithContext(ctx)
err := spinner.Run(p.Printer, "Deleting STACKIT Intake instance", func() error {
_, err = wait.DeleteIntakeWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.IntakeId).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("wait for STACKIT Instance deletion: %w", err)
}
s.Stop()
}

operationState := "Deleted"
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/intake/runner/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ func NewCmd(p *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(p.Printer)
s.Start("Creating STACKIT Intake Runner")
_, err = wait.CreateOrUpdateIntakeRunnerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, resp.GetId()).WaitWithContext(ctx)
err := spinner.Run(p.Printer, "Creating STACKIT Intake Runner", func() error {
_, err = wait.CreateOrUpdateIntakeRunnerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, resp.GetId()).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("wait for STACKIT Intake Runner creation: %w", err)
}
s.Stop()
}

return outputResult(p.Printer, model, projectLabel, resp)
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/intake/runner/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ func NewCmd(p *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(p.Printer)
s.Start("Deleting STACKIT Intake Runner")
_, err = wait.DeleteIntakeRunnerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.RunnerId).WaitWithContext(ctx)
err := spinner.Run(p.Printer, "Deleting STACKIT Intake Runner", func() error {
_, err = wait.DeleteIntakeRunnerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.RunnerId).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("wait for STACKIT Intake Runner deletion: %w", err)
}
s.Stop()
}

operationState := "Deleted"
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/intake/runner/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ func NewCmd(p *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(p.Printer)
s.Start("Updating STACKIT Intake Runner")
_, err = wait.CreateOrUpdateIntakeRunnerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.RunnerId).WaitWithContext(ctx)
err := spinner.Run(p.Printer, "Updating STACKIT Intake Runner", func() error {
_, err = wait.CreateOrUpdateIntakeRunnerWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.RunnerId).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("wait for STACKIT Intake Runner update: %w", err)
}
s.Stop()
}

return outputResult(p.Printer, model, projectLabel, resp)
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/intake/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ func NewCmd(p *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(p.Printer)
s.Start("Updating STACKIT Intake Runner instance")
_, err = wait.CreateOrUpdateIntakeWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.IntakeId).WaitWithContext(ctx)
err := spinner.Run(p.Printer, "Updating STACKIT Intake Runner instance", func() error {
_, err = wait.CreateOrUpdateIntakeWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.IntakeId).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("wait for STACKIT Instance creation: %w", err)
}
s.Stop()
}

return outputResult(p.Printer, model, projectLabel, resp)
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/sfs/resource-pool/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ The available performance class values can be obtained by running:

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Create resource pool")
_, err = wait.CreateResourcePoolWaitHandler(ctx, apiClient, model.ProjectId, model.Region, resourcePoolId).WaitWithContext(ctx)
err := spinner.Run(params.Printer, "Create resource pool", func() error {
_, err = wait.CreateResourcePoolWaitHandler(ctx, apiClient, model.ProjectId, model.Region, resourcePoolId).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("wait for resource pool creation: %w", err)
}
s.Stop()
}

return outputResult(params.Printer, model.OutputFormat, model.Async, projectLabel, resp)
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/sfs/resource-pool/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Delete resource pool")
_, err = wait.DeleteResourcePoolWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId).WaitWithContext(ctx)
err := spinner.Run(params.Printer, "Delete resource pool", func() error {
_, err = wait.DeleteResourcePoolWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("wait for resource pool deletion: %w", err)
}
s.Stop()
}

return outputResult(params.Printer, model.OutputFormat, model.Async, resourcePoolName, resp)
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/sfs/resource-pool/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ The available performance class values can be obtained by running:

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Update resource pool")
_, err = wait.UpdateResourcePoolWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId).WaitWithContext(ctx)
err := spinner.Run(params.Printer, "Update resource pool", func() error {
_, err = wait.UpdateResourcePoolWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("wait for resource pool update: %w", err)
}
s.Stop()
}

return outputResult(params.Printer, model.OutputFormat, model.Async, resp)
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/sfs/share/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Creating share")
_, err = wait.CreateShareWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId, shareId).WaitWithContext(ctx)
err := spinner.Run(params.Printer, "Creating share", func() error {
_, err = wait.CreateShareWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId, shareId).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("waiting for share creation: %w", err)
}
s.Stop()
}

return outputResult(params.Printer, model.OutputFormat, model.Async, resourcePoolLabel, resp)
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/sfs/share/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Deleting share")
_, err = wait.DeleteShareWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId).WaitWithContext(ctx)
err := spinner.Run(params.Printer, "Deleting share", func() error {
_, err = wait.DeleteShareWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("waiting for share deletion: %w", err)
}
s.Stop()
}

operation := "Deleted"
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/beta/sfs/share/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command {

// Wait for async operation, if async mode not enabled
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Updating share")
_, err = wait.UpdateShareWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId).WaitWithContext(ctx)
err := spinner.Run(params.Printer, "Updating share", func() error {
_, err = wait.UpdateShareWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ResourcePoolId, model.ShareId).WaitWithContext(ctx)
return err
})
if err != nil {
return fmt.Errorf("waiting for share update: %w", err)
}
s.Stop()
}

return outputResult(params.Printer, model.OutputFormat, model.Async, resourcePoolLabel, resp)
Expand Down
8 changes: 3 additions & 5 deletions internal/cmd/beta/sqlserverflex/database/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command {

// Call API
req := buildRequest(ctx, model, apiClient)
s := spinner.New(params.Printer)
s.Start("Creating database")
resp, err := req.Execute()
resp, err := spinner.Run2(params.Printer, "Creating database", func() (*sqlserverflex.CreateDatabaseResponse, error) {
return req.Execute()
})
if err != nil {
s.StopWithError()
return fmt.Errorf("create SQLServer Flex database: %w", err)
}
s.Stop()

return outputResult(params.Printer, model.OutputFormat, model.DatabaseName, resp)
},
Expand Down
Loading
Loading