Revert "Using go sdk for ./bricks fs ls DIR_NAME command"

This reverts commit 6217d20e57.
This commit is contained in:
Shreyas Goenka 2022-09-01 13:42:34 +02:00
parent 5e2c5888e0
commit 9951068c62
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 5 additions and 10 deletions

View File

@ -3,9 +3,10 @@ package fs
import ( import (
"fmt" "fmt"
"github.com/databricks/bricks/project"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/databricks/databricks-sdk-go/workspaces"
"github.com/databricks/databricks-sdk-go/service/dbfs" "github.com/databrickslabs/terraform-provider-databricks/storage"
) )
// lsCmd represents the ls command // lsCmd represents the ls command
@ -15,17 +16,11 @@ var lsCmd = &cobra.Command{
Long: `Lists files`, Long: `Lists files`,
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
// Question (shreyas): Where does the client pick up the login creds from ? Context ? api := storage.NewDbfsAPI(cmd.Context(), project.Current.Client())
// Maybe this client can be added on a higher level ? files, err := api.List(args[0], false)
// Create issue to add tests for this ? How to write those for cli ?
workspacesClient := workspaces.New()
listStatusResponse, err := workspacesClient.Dbfs.ListStatus(cmd.Context(),
dbfs.ListStatusRequest{Path: args[0]},
)
if err != nil { if err != nil {
panic(err) panic(err)
} }
files := listStatusResponse.Files
// TODO: output formatting: JSON, CSV, tables and default // TODO: output formatting: JSON, CSV, tables and default
for _, v := range files { for _, v := range files {
fmt.Printf("[-] %s (%d, %v)\n", v.Path, v.FileSize, v.IsDir) fmt.Printf("[-] %s (%d, %v)\n", v.Path, v.FileSize, v.IsDir)