mirror of https://github.com/databricks/cli.git
Pass through paths argument to libs/sync (#1689)
## Changes Requires #1684. ## Tests Ran the sync integration tests.
This commit is contained in:
parent
7de7583b37
commit
2b8cbc31cf
|
@ -28,10 +28,12 @@ func GetSyncOptions(ctx context.Context, rb bundle.ReadOnlyBundle) (*sync.SyncOp
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := &sync.SyncOptions{
|
opts := &sync.SyncOptions{
|
||||||
LocalPath: rb.BundleRoot(),
|
LocalRoot: rb.BundleRoot(),
|
||||||
RemotePath: rb.Config().Workspace.FilePath,
|
Paths: []string{"."},
|
||||||
Include: includes,
|
Include: includes,
|
||||||
Exclude: rb.Config().Sync.Exclude,
|
Exclude: rb.Config().Sync.Exclude,
|
||||||
|
|
||||||
|
RemotePath: rb.Config().Workspace.FilePath,
|
||||||
Host: rb.WorkspaceClient().Config.Host,
|
Host: rb.WorkspaceClient().Config.Host,
|
||||||
|
|
||||||
Full: false,
|
Full: false,
|
||||||
|
|
|
@ -47,7 +47,11 @@ func (f *syncFlags) syncOptionsFromArgs(cmd *cobra.Command, args []string) (*syn
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := sync.SyncOptions{
|
opts := sync.SyncOptions{
|
||||||
LocalPath: vfs.MustNew(args[0]),
|
LocalRoot: vfs.MustNew(args[0]),
|
||||||
|
Paths: []string{"."},
|
||||||
|
Include: nil,
|
||||||
|
Exclude: nil,
|
||||||
|
|
||||||
RemotePath: args[1],
|
RemotePath: args[1],
|
||||||
Full: f.full,
|
Full: f.full,
|
||||||
PollInterval: f.interval,
|
PollInterval: f.interval,
|
||||||
|
|
|
@ -33,7 +33,7 @@ func TestSyncOptionsFromBundle(t *testing.T) {
|
||||||
f := syncFlags{}
|
f := syncFlags{}
|
||||||
opts, err := f.syncOptionsFromBundle(New(), []string{}, b)
|
opts, err := f.syncOptionsFromBundle(New(), []string{}, b)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, tempDir, opts.LocalPath.Native())
|
assert.Equal(t, tempDir, opts.LocalRoot.Native())
|
||||||
assert.Equal(t, "/Users/jane@doe.com/path", opts.RemotePath)
|
assert.Equal(t, "/Users/jane@doe.com/path", opts.RemotePath)
|
||||||
assert.Equal(t, filepath.Join(tempDir, ".databricks", "bundle", "default"), opts.SnapshotBasePath)
|
assert.Equal(t, filepath.Join(tempDir, ".databricks", "bundle", "default"), opts.SnapshotBasePath)
|
||||||
assert.NotNil(t, opts.WorkspaceClient)
|
assert.NotNil(t, opts.WorkspaceClient)
|
||||||
|
@ -59,6 +59,6 @@ func TestSyncOptionsFromArgs(t *testing.T) {
|
||||||
cmd.SetContext(root.SetWorkspaceClient(context.Background(), nil))
|
cmd.SetContext(root.SetWorkspaceClient(context.Background(), nil))
|
||||||
opts, err := f.syncOptionsFromArgs(cmd, []string{local, remote})
|
opts, err := f.syncOptionsFromArgs(cmd, []string{local, remote})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, local, opts.LocalPath.Native())
|
assert.Equal(t, local, opts.LocalRoot.Native())
|
||||||
assert.Equal(t, remote, opts.RemotePath)
|
assert.Equal(t, remote, opts.RemotePath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type SyncOptions struct {
|
type SyncOptions struct {
|
||||||
LocalPath vfs.Path
|
LocalRoot vfs.Path
|
||||||
RemotePath string
|
Paths []string
|
||||||
Include []string
|
Include []string
|
||||||
Exclude []string
|
Exclude []string
|
||||||
|
|
||||||
|
RemotePath string
|
||||||
|
|
||||||
Full bool
|
Full bool
|
||||||
|
|
||||||
SnapshotBasePath string
|
SnapshotBasePath string
|
||||||
|
@ -51,7 +53,7 @@ type Sync struct {
|
||||||
|
|
||||||
// New initializes and returns a new [Sync] instance.
|
// New initializes and returns a new [Sync] instance.
|
||||||
func New(ctx context.Context, opts SyncOptions) (*Sync, error) {
|
func New(ctx context.Context, opts SyncOptions) (*Sync, error) {
|
||||||
fileSet, err := git.NewFileSet(opts.LocalPath)
|
fileSet, err := git.NewFileSet(opts.LocalRoot, opts.Paths)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -61,12 +63,12 @@ func New(ctx context.Context, opts SyncOptions) (*Sync, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
includeFileSet, err := fileset.NewGlobSet(opts.LocalPath, opts.Include)
|
includeFileSet, err := fileset.NewGlobSet(opts.LocalRoot, opts.Include)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
excludeFileSet, err := fileset.NewGlobSet(opts.LocalPath, opts.Exclude)
|
excludeFileSet, err := fileset.NewGlobSet(opts.LocalRoot, opts.Exclude)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ func (s *Sync) applyMkdir(ctx context.Context, localName string) error {
|
||||||
func (s *Sync) applyPut(ctx context.Context, localName string) error {
|
func (s *Sync) applyPut(ctx context.Context, localName string) error {
|
||||||
s.notifyProgress(ctx, EventActionPut, localName, 0.0)
|
s.notifyProgress(ctx, EventActionPut, localName, 0.0)
|
||||||
|
|
||||||
localFile, err := s.LocalPath.Open(localName)
|
localFile, err := s.LocalRoot.Open(localName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue