Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bb3047a
First commit
shreyas-goenka Sep 1, 2022
fba7a5b
WIP
shreyas-goenka Sep 1, 2022
227a64a
Removed isolation soft implementation, and migrated to go sdk for lau…
shreyas-goenka Sep 1, 2022
6a28593
replaces repos API with go sdk in sync.go
shreyas-goenka Sep 1, 2022
195f713
Replaced dbfs api calls in wheel.go (still some todos here)
shreyas-goenka Sep 1, 2022
c80509c
replaced dbfs api uses in python wheel and tf state runner with the g…
shreyas-goenka Sep 2, 2022
8ff7ac7
Creating workspace client on init now
shreyas-goenka Sep 2, 2022
f893c62
ls command now uses the preexisting workspace client, and works
shreyas-goenka Sep 2, 2022
b26bb6c
added old version of development cluster implementation, kept around …
shreyas-goenka Sep 2, 2022
1a8faab
renamed workspaceClient to wsc
shreyas-goenka Sep 2, 2022
8b04f0f
cleaned comments from go.mod
shreyas-goenka Sep 2, 2022
bf616e8
Moved GetAllRepos to utilities and created issue to move it to go sdk
shreyas-goenka Sep 2, 2022
bd497ea
Pull in remote changes
shreyas-goenka Sep 2, 2022
a1c0452
updated git version to 1.18 in github workflows
shreyas-goenka Sep 2, 2022
45dcc6f
added checkout submodules to push github action
shreyas-goenka Sep 2, 2022
2f6322b
deco github token
shreyas-goenka Sep 2, 2022
fcc9f65
removed comment explaining why go versoin 1.18 is needed
shreyas-goenka Sep 5, 2022
ae45f79
converted first word of error message to lower case
shreyas-goenka Sep 5, 2022
1599a68
ran gofmt -s -w .
shreyas-goenka Sep 5, 2022
c27bb4e
Added equivalent issues in bricks to track utility function replaceme…
shreyas-goenka Sep 5, 2022
e775b4a
made 1e6 a named constant
shreyas-goenka Sep 5, 2022
656d21b
Added close api call for dbfs and linked documentation next to the he…
shreyas-goenka Sep 5, 2022
052ba4f
removed question wala comment
shreyas-goenka Sep 5, 2022
e515a2b
moved close call outside loop
shreyas-goenka Sep 6, 2022
1a61417
pulled in the latest databricks-sdk-go
shreyas-goenka Sep 6, 2022
fd9635d
Merge remote-tracking branch 'origin' into use-go-sdk
shreyas-goenka Sep 6, 2022
3f3a22f
ran go mod tidy
shreyas-goenka Sep 6, 2022
85b47cb
Merge remote-tracking branch 'origin' into use-go-sdk
shreyas-goenka Sep 6, 2022
dd6dacb
making build pass after serge's consistancy changes
shreyas-goenka Sep 6, 2022
793ac56
fetching the latest staticcheck to fix build workflow
shreyas-goenka Sep 7, 2022
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
9 changes: 6 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
token: ${{ secrets.DECO_GITHUB_TOKEN }}
submodules: recursive

- name: Unshallow
run: git fetch --prune --unshallow

- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.16.x
go-version: 1.18.x

- name: Cache packages
uses: actions/cache@v2
Expand All @@ -38,7 +41,7 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
go get gotest.tools/gotestsum
go install honnef.co/go/tools/cmd/staticcheck@v0.2.2
go install honnef.co/go/tools/cmd/staticcheck@latest

- name: Pull external libraries
run: make vendor
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.18
- name: Import GPG key
id: import_gpg
uses: hashicorp/ghaction-import-gpg@v2.1.0
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "ext/databricks-sdk-go"]
path = ext/databricks-sdk-go
url = git@github.com:databricks/databricks-sdk-go.git
7 changes: 3 additions & 4 deletions cmd/fs/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (

"github.com/databricks/bricks/project"
"github.com/spf13/cobra"

"github.com/databrickslabs/terraform-provider-databricks/storage"
)

// lsCmd represents the ls command
Expand All @@ -16,11 +14,12 @@ var lsCmd = &cobra.Command{
Long: `Lists files`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
api := storage.NewDbfsAPI(cmd.Context(), project.Current.Client())
files, err := api.List(args[0], false)
wsc := project.Current.WorkspacesClient()
listStatusResponse, err := wsc.Dbfs.ListByPath(cmd.Context(), args[0])
if err != nil {
panic(err)
}
files := listStatusResponse.Files
// TODO: output formatting: JSON, CSV, tables and default
for _, v := range files {
fmt.Printf("[-] %s (%d, %v)\n", v.Path, v.FileSize, v.IsDir)
Expand Down
2 changes: 1 addition & 1 deletion cmd/launch/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var launchCmd = &cobra.Command{
}

func init() {
// TODO: detect if we can skip registering
// TODO: detect if we can skip registering
// launch command for DBSQL projects
root.RootCmd.AddCommand(launchCmd)
}
2 changes: 1 addition & 1 deletion cmd/sync/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func githubGetPAT(ctx context.Context) (string, error) {
}
if result.Get("error") == "slow_down" {
t, _ := strconv.Atoi(result.Get("interval"))
time.Sleep(time.Duration(t)*time.Second)
time.Sleep(time.Duration(t) * time.Second)
log.Printf("[WARN] Rate limited, sleeping for %d seconds", t)
}
reason := result.Get("error_description")
Expand Down
2 changes: 1 addition & 1 deletion cmd/sync/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ func TestGithubGetPAT(t *testing.T) {
pat, err := githubGetPAT(context.Background())
assert.NoError(t, err)
assert.NotEqual(t, "..", pat)
}
}
1 change: 0 additions & 1 deletion cmd/sync/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func (d diff) IsEmpty() bool {
return len(d.put) == 0 && len(d.delete) == 0
}


func (d diff) String() string {
if d.IsEmpty() {
return "no changes"
Expand Down
18 changes: 10 additions & 8 deletions cmd/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/databricks/bricks/cmd/root"
"github.com/databricks/bricks/git"
"github.com/databricks/bricks/project"
"github.com/databrickslabs/terraform-provider-databricks/repos"
"github.com/databrickslabs/terraform-provider-databricks/workspace"
"github.com/databricks/bricks/utilities"
"github.com/databricks/databricks-sdk-go/service/workspace"
"github.com/spf13/cobra"
)

Expand All @@ -28,11 +28,9 @@ var syncCmd = &cobra.Command{
}
log.Printf("[INFO] %s", origin)
ctx := cmd.Context()
client := project.Current.Client()
reposAPI := repos.NewReposAPI(ctx, client)


checkouts, err := reposAPI.List("/")
wsc := project.Current.WorkspacesClient()
checkouts, err := utilities.GetAllRepos(ctx, wsc, "/")
if err != nil {
return err
}
Expand All @@ -46,9 +44,13 @@ var syncCmd = &cobra.Command{
}
base := fmt.Sprintf("/Repos/%s/%s", me.UserName, repositoryName)
return watchForChanges(ctx, git.MustGetFileSet(), *interval, func(d diff) error {
wsAPI := workspace.NewNotebooksAPI(ctx, client)
for _, v := range d.delete {
err := wsAPI.Delete(path.Join(base, v), true)
err := wsc.Workspace.Delete(ctx,
workspace.DeleteRequest{
Path: path.Join(base, v),
Recursive: true,
},
)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ func TestItSyncs(t *testing.T) {
root.RootCmd.SetArgs([]string{"sync"})
err := root.RootCmd.ExecuteContext(ctx)
assert.NoError(t, err)
}
}
1 change: 1 addition & 0 deletions ext/databricks-sdk-go
Submodule databricks-sdk-go added at 9e9cc8
4 changes: 2 additions & 2 deletions git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ func Origin() (*url.URL, error) {
func HttpsOrigin() (string, error) {
origin, err := Origin()
if err != nil {
return "", err
return "", err
}
// if current repo is checked out with a SSH key
if origin.Scheme != "https" {
origin.Scheme = "https"
}
// `git@` is not required for HTTPS, as Databricks Repos are checked
// `git@` is not required for HTTPS, as Databricks Repos are checked
// out using an API token instead of username. But does it hold true
// for all of the git implementations?
if origin.User != nil {
Expand Down
2 changes: 1 addition & 1 deletion git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ func TestHttpsOrigin(t *testing.T) {
// must pass on the upcoming forks
assert.True(t, strings.HasPrefix(url, "https://github.com"), url)
assert.True(t, strings.HasSuffix(url, "bricks.git"), url)
}
}
23 changes: 10 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.18

require (
github.com/atotto/clipboard v0.1.4
github.com/databricks/databricks-sdk-go v0.0.0
github.com/databrickslabs/terraform-provider-databricks v0.5.8 // Apache 2.0
github.com/ghodss/yaml v1.0.0 // MIT + NOTICE
github.com/hashicorp/go-version v1.5.0 // MPL 2.0
Expand All @@ -17,7 +18,7 @@ require (
github.com/spf13/cobra v1.4.0 // Apache 2.0
github.com/stretchr/testify v1.8.0 // MIT
github.com/whilp/git-urls v1.0.0 // MIT
golang.org/x/mod v0.5.1 // BSD-3-Clause
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // BSD-3-Clause
gopkg.in/ini.v1 v1.67.0 // Apache 2.0
)

Expand All @@ -43,22 +44,17 @@ require (
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.2.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.4.3 // indirect
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/hcl/v2 v2.12.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.9.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.4.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0 // indirect
github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.10 // indirect
Expand All @@ -67,7 +63,6 @@ require (
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
Expand All @@ -76,16 +71,18 @@ require (
github.com/zclconf/go-cty v1.10.0 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect
golang.org/x/oauth2 v0.0.0-20220628200809-02e64fa58f26 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/api v0.79.0 // indirect
google.golang.org/api v0.82.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3 // indirect
google.golang.org/grpc v1.46.0 // indirect
google.golang.org/genproto v0.0.0-20220527130721-00d5c0f3be58 // indirect
google.golang.org/grpc v1.46.2 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/databricks/databricks-sdk-go v0.0.0 => ./ext/databricks-sdk-go
Loading