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
24 changes: 12 additions & 12 deletions cmd/account/groups/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ func newDelete() *cobra.Command {
a := cmdctx.AccountClient(ctx)

if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Account Groups drop-down.")
names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -231,10 +231,10 @@ func newGet() *cobra.Command {
a := cmdctx.AccountClient(ctx)

if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Account Groups drop-down.")
names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -375,10 +375,10 @@ func newPatch() *cobra.Command {
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Account Groups drop-down.")
names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -468,10 +468,10 @@ func newUpdate() *cobra.Command {
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Account Groups drop-down.")
names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down
24 changes: 12 additions & 12 deletions cmd/account/service-principals/service-principals.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ func newDelete() *cobra.Command {
a := cmdctx.AccountClient(ctx)

if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Account Service Principals drop-down.")
names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -230,10 +230,10 @@ func newGet() *cobra.Command {
a := cmdctx.AccountClient(ctx)

if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Account Service Principals drop-down.")
names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -373,10 +373,10 @@ func newPatch() *cobra.Command {
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Account Service Principals drop-down.")
names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -468,10 +468,10 @@ func newUpdate() *cobra.Command {
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Account Service Principals drop-down.")
names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down
24 changes: 12 additions & 12 deletions cmd/account/users/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ func newDelete() *cobra.Command {
a := cmdctx.AccountClient(ctx)

if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Account Users drop-down.")
names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -246,10 +246,10 @@ func newGet() *cobra.Command {
a := cmdctx.AccountClient(ctx)

if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Account Users drop-down.")
names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -389,10 +389,10 @@ func newPatch() *cobra.Command {
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Account Users drop-down.")
names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -484,10 +484,10 @@ func newUpdate() *cobra.Command {
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Account Users drop-down.")
names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down
24 changes: 12 additions & 12 deletions cmd/workspace/groups/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ func newDelete() *cobra.Command {
w := cmdctx.WorkspaceClient(ctx)

if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Groups drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Groups drop-down.")
names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -231,10 +231,10 @@ func newGet() *cobra.Command {
w := cmdctx.WorkspaceClient(ctx)

if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Groups drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Groups drop-down.")
names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -373,10 +373,10 @@ func newPatch() *cobra.Command {
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Groups drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Groups drop-down.")
names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -466,10 +466,10 @@ func newUpdate() *cobra.Command {
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Groups drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Groups drop-down.")
names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/workspace/repos/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ func updateOverride(updateCmd *cobra.Command, updateReq *workspace.UpdateRepoReq
func repoArgumentToRepoID(ctx context.Context, w *databricks.WorkspaceClient, args []string) (int64, error) {
// ---- Begin copy from cmd/workspace/repos/repos.go ----
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No REPO_ID argument specified. Loading names for Repos drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No REPO_ID argument specified. Loading names for Repos drop-down.")
names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return 0, fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down
24 changes: 12 additions & 12 deletions cmd/workspace/service-principals/service-principals.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ func newDelete() *cobra.Command {
w := cmdctx.WorkspaceClient(ctx)

if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Service Principals drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Service Principals drop-down.")
names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -230,10 +230,10 @@ func newGet() *cobra.Command {
w := cmdctx.WorkspaceClient(ctx)

if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Service Principals drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Service Principals drop-down.")
names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -373,10 +373,10 @@ func newPatch() *cobra.Command {
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Service Principals drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Service Principals drop-down.")
names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -468,10 +468,10 @@ func newUpdate() *cobra.Command {
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Service Principals drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Service Principals drop-down.")
names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down
24 changes: 12 additions & 12 deletions cmd/workspace/users/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ func newDelete() *cobra.Command {
w := cmdctx.WorkspaceClient(ctx)

if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Users drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Users drop-down.")
names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -250,10 +250,10 @@ func newGet() *cobra.Command {
w := cmdctx.WorkspaceClient(ctx)

if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Users drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Users drop-down.")
names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -478,10 +478,10 @@ func newPatch() *cobra.Command {
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Users drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Users drop-down.")
names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down Expand Up @@ -644,10 +644,10 @@ func newUpdate() *cobra.Command {
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Users drop-down."
sp := cmdio.NewSpinner(ctx)
sp.Update("No ID argument specified. Loading names for Users drop-down.")
names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{})
close(promptSpinner)
sp.Close()
if err != nil {
return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err)
}
Expand Down
5 changes: 0 additions & 5 deletions libs/cmdio/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@ func RunSelect(ctx context.Context, prompt *promptui.Select) (int, string, error
return prompt.Run()
}

func Spinner(ctx context.Context) chan string {
c := fromContext(ctx)
return c.Spinner(ctx)
}

// NewSpinner creates a new spinner for displaying progress indicators.
// The returned spinner should be closed when done to release resources.
//
Expand Down
28 changes: 0 additions & 28 deletions libs/cmdio/spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,31 +165,3 @@ func (c *cmdIO) NewSpinner(ctx context.Context) *spinner {

return sp
}

// Spinner returns a channel for updating spinner status messages.
// Send messages to update the suffix, close the channel to stop.
// The spinner runs until the channel is closed or context is cancelled.
func (c *cmdIO) Spinner(ctx context.Context) chan string {
updates := make(chan string)
sp := c.NewSpinner(ctx)

// Bridge goroutine: channel -> spinner.Update()
go func() {
defer sp.Close()

for {
select {
case <-ctx.Done():
return
case msg, ok := <-updates:
if !ok {
// Channel closed
return
}
sp.Update(msg)
}
}
}()

return updates
}
Loading
Loading