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)
|
|
|
|
}
|
|
|
|
|
2023-08-14 15:36:37 +00:00
|
|
|
internalDir, err := b.InternalDir()
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("cannot get bundle internal directory: %w", err)
|
|
|
|
}
|
|
|
|
|
2023-04-11 14:57:01 +00:00
|
|
|
opts := sync.SyncOptions{
|
2023-08-14 15:36:37 +00:00
|
|
|
LocalPath: b.Config.Path,
|
|
|
|
RemotePath: b.Config.Workspace.FilesPath,
|
|
|
|
Include: b.Config.Sync.Include,
|
|
|
|
Exclude: b.Config.Sync.Exclude,
|
|
|
|
|
2023-07-30 07:19:49 +00:00
|
|
|
Full: false,
|
|
|
|
CurrentUser: b.Config.Workspace.CurrentUser.User,
|
2023-04-11 14:57:01 +00:00
|
|
|
|
2023-08-14 15:36:37 +00:00
|
|
|
InternalDir: internalDir,
|
2023-04-11 14:57:01 +00:00
|
|
|
SnapshotBasePath: cacheDir,
|
|
|
|
WorkspaceClient: b.WorkspaceClient(),
|
|
|
|
}
|
|
|
|
return sync.New(ctx, opts)
|
|
|
|
}
|