2023-04-11 14:57:01 +00:00
|
|
|
package files
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle"
|
|
|
|
"github.com/databricks/cli/libs/sync"
|
2023-04-11 14:57:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func getSync(ctx context.Context, b *bundle.Bundle) (*sync.Sync, error) {
|
|
|
|
cacheDir, err := b.CacheDir()
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("cannot get bundle cache directory: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
opts := sync.SyncOptions{
|
|
|
|
LocalPath: b.Config.Path,
|
2023-04-12 14:54:36 +00:00
|
|
|
RemotePath: b.Config.Workspace.FilesPath,
|
2023-04-11 14:57:01 +00:00
|
|
|
Full: false,
|
|
|
|
|
|
|
|
SnapshotBasePath: cacheDir,
|
|
|
|
WorkspaceClient: b.WorkspaceClient(),
|
2023-06-01 22:04:18 +00:00
|
|
|
|
|
|
|
PersistSnapshot: true,
|
|
|
|
AllowOverwrites: true,
|
2023-04-11 14:57:01 +00:00
|
|
|
}
|
|
|
|
return sync.New(ctx, opts)
|
|
|
|
}
|