Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/bundle/env"
"github.com/databricks/cli/bundle/metadata"
"github.com/databricks/cli/libs/fileset"
"github.com/databricks/cli/libs/folders"
"github.com/databricks/cli/libs/git"
"github.com/databricks/cli/libs/locker"
Expand Down Expand Up @@ -50,6 +51,9 @@ type Bundle struct {
clientOnce sync.Once
client *databricks.WorkspaceClient

// Files that are synced to the workspace.file_path
SyncedFiles []fileset.File
Comment thread
shreyas-goenka marked this conversation as resolved.
Outdated

// Stores an initialized copy of this bundle's Terraform wrapper.
Terraform *tfexec.Terraform

Expand Down
2 changes: 1 addition & 1 deletion bundle/deploy/files/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (m *upload) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
return diag.FromErr(err)
}

err = sync.RunOnce(ctx)
b.SyncedFiles, err = sync.RunOnce(ctx)
if err != nil {
return diag.FromErr(err)
}
Expand Down
16 changes: 2 additions & 14 deletions bundle/deploy/state_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"time"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/deploy/files"
"github.com/databricks/cli/internal/build"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/log"
Expand Down Expand Up @@ -40,19 +39,8 @@ func (s *stateUpdate) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnost
state.CliVersion = build.GetInfo().Version
state.Version = DeploymentStateVersion

// Get the current file list.
sync, err := files.GetSync(ctx, bundle.ReadOnly(b))
if err != nil {
return diag.FromErr(err)
}

files, err := sync.GetFileList(ctx)
if err != nil {
return diag.FromErr(err)
}

// Update the state with the current file list.
fl, err := FromSlice(files)
// Update the state with the current list of synced files.
fl, err := FromSlice(b.SyncedFiles)
if err != nil {
return diag.FromErr(err)
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/bundle/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ func newSyncCommand() *cobra.Command {
return s.RunContinuous(ctx)
}

return s.RunOnce(ctx)
_, err = s.RunOnce(ctx)
return err
}

return cmd
Expand Down
2 changes: 1 addition & 1 deletion cmd/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func New() *cobra.Command {
if f.watch {
err = s.RunContinuous(ctx)
} else {
err = s.RunOnce(ctx)
_, err = s.RunOnce(ctx)
}

s.Close()
Expand Down
21 changes: 13 additions & 8 deletions libs/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,36 +152,41 @@ func (s *Sync) notifyComplete(ctx context.Context, d diff) {
s.seq++
}

func (s *Sync) RunOnce(ctx context.Context) error {
// Upload all files in the file tree rooted at the local path configured in the
// SyncOptions to the remote path configured in the SyncOptions.
//
// Returns the list of files tracked (and synchronized) by the syncer during the run,
// and an error if any occurred.
func (s *Sync) RunOnce(ctx context.Context) ([]fileset.File, error) {
files, err := s.GetFileList(ctx)
if err != nil {
return err
return files, err
}

change, err := s.snapshot.diff(ctx, files)
if err != nil {
return err
return files, err
}

s.notifyStart(ctx, change)
if change.IsEmpty() {
s.notifyComplete(ctx, change)
return nil
return files, nil
}

err = s.applyDiff(ctx, change)
if err != nil {
return err
return files, err
}

err = s.snapshot.Save(ctx)
if err != nil {
log.Errorf(ctx, "cannot store snapshot: %s", err)
return err
return files, err
}

s.notifyComplete(ctx, change)
return nil
return files, nil
}

func (s *Sync) GetFileList(ctx context.Context) ([]fileset.File, error) {
Expand Down Expand Up @@ -231,7 +236,7 @@ func (s *Sync) RunContinuous(ctx context.Context) error {
case <-ctx.Done():
return ctx.Err()
case <-ticker.C:
err := s.RunOnce(ctx)
_, err := s.RunOnce(ctx)
if err != nil {
return err
}
Expand Down