diff --git a/cmd/sync/sync.go b/cmd/sync/sync.go index 5853a4d8..5c7a2c0a 100644 --- a/cmd/sync/sync.go +++ b/cmd/sync/sync.go @@ -1,12 +1,9 @@ package sync import ( - "context" "fmt" - "io" "log" "path" - "strings" "time" "github.com/databricks/bricks/cmd/root" @@ -60,14 +57,14 @@ var syncCmd = &cobra.Command{ }, } -func ImportFile(ctx context.Context, path string, content io.Reader) error { - client := project.Current.Client() - apiPath := fmt.Sprintf( - "/workspace-files/import-file/%s?overwrite=true", - strings.TrimLeft(path, "/")) - // TODO: change upstream client to support io.Reader as body - return client.Post(ctx, apiPath, content, nil) -} +// func ImportFile(ctx context.Context, path string, content io.Reader) error { +// client := project.Current.Client() +// apiPath := fmt.Sprintf( +// "/workspace-files/import-file/%s?overwrite=true", +// strings.TrimLeft(path, "/")) +// // TODO: change upstream client to support io.Reader as body +// return client.Post(ctx, apiPath, content, nil) +// } // project files polling interval var interval *time.Duration diff --git a/ext/databricks-sdk-go b/ext/databricks-sdk-go index 9e9cc8f8..521bddb1 160000 --- a/ext/databricks-sdk-go +++ b/ext/databricks-sdk-go @@ -1 +1 @@ -Subproject commit 9e9cc8f8115b8d3cb9e778806066c7cffe5b9b76 +Subproject commit 521bddb126b490fcf7fac4dcff7774d749871b0f diff --git a/project/project.go b/project/project.go index f0566caf..bce9317a 100644 --- a/project/project.go +++ b/project/project.go @@ -5,11 +5,11 @@ import ( "fmt" "sync" + "github.com/databricks/databricks-sdk-go/databricks" "github.com/databricks/databricks-sdk-go/service/clusters" "github.com/databricks/databricks-sdk-go/service/commands" + "github.com/databricks/databricks-sdk-go/service/scim" "github.com/databricks/databricks-sdk-go/workspaces" - "github.com/databrickslabs/terraform-provider-databricks/common" - "github.com/databrickslabs/terraform-provider-databricks/scim" ) // Current CLI application state - fixure out @@ -21,7 +21,6 @@ type inner struct { project *Project wsc *workspaces.WorkspacesClient - client *common.DatabricksClient me *scim.User } @@ -29,15 +28,11 @@ func (i *inner) init() { i.mu.Lock() defer i.mu.Unlock() i.once.Do(func() { - client := &common.DatabricksClient{} - i.client = client - i.wsc = workspaces.New() prj, err := loadProjectConf() + i.wsc = workspaces.New(&databricks.Config{Profile: prj.Profile}) if err != nil { panic(err) } - client.Profile = prj.Profile // Databricks CLI profile - err = client.Configure() if err != nil { panic(err) } @@ -45,11 +40,6 @@ func (i *inner) init() { }) } -func (i *inner) Client() *common.DatabricksClient { - i.init() - return i.client -} - func (i *inner) Project() *Project { i.init() return i.project @@ -68,12 +58,12 @@ func (i *inner) Me() *scim.User { if i.me != nil { return i.me } - me, err := scim.NewUsersAPI(context.Background(), i.Client()).Me() + me, err := i.wsc.CurrentUser.Me(context.Background()) if err != nil { panic(err) } - i.me = &me - return &me + i.me = me + return me } func (i *inner) DeploymentIsolationPrefix() string {