mirror of https://github.com/databricks/cli.git
Replace scim Me terraform call with go sdk (#46)
This PR: 1. Replaces scim.Me call to use the go SDK instead of the terraform client 2. Removes terraform client from bricks project Tested manually that the scim.Me call works now and returns the correct user go build works
This commit is contained in:
parent
d829ce36d5
commit
21bc774491
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 9e9cc8f8115b8d3cb9e778806066c7cffe5b9b76
|
||||
Subproject commit 521bddb126b490fcf7fac4dcff7774d749871b0f
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue