mirror of https://github.com/databricks/cli.git
undo remote path public
This commit is contained in:
parent
49f7969363
commit
298fed28e5
|
@ -54,9 +54,10 @@ var importDirCmd = &cobra.Command{
|
||||||
// Initialize error wait group, and spawn the progress event emitter inside
|
// Initialize error wait group, and spawn the progress event emitter inside
|
||||||
// the error wait group
|
// the error wait group
|
||||||
group, ctx := errgroup.WithContext(ctx)
|
group, ctx := errgroup.WithContext(ctx)
|
||||||
|
eventsChannel := s.Events()
|
||||||
group.Go(
|
group.Go(
|
||||||
func() error {
|
func() error {
|
||||||
return renderSyncEvents(ctx, s.Events(), s)
|
return renderSyncEvents(ctx, eventsChannel, s)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Start Uploading local files
|
// Start Uploading local files
|
||||||
|
|
|
@ -53,11 +53,12 @@ func renderSyncEvents(ctx context.Context, eventChannel <-chan sync.Event, synce
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// TODO: test this works with windows paths
|
// TODO: test this works with windows paths
|
||||||
remotePath, err := syncer.RemotePath(progressEvent.Path)
|
// remotePath, err := syncer.RemotePath(progressEvent.Path)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
err = cmdio.Render(ctx, newUploadCompleteEvent(progressEvent.Path, remotePath))
|
remotePath := "TODO"
|
||||||
|
err := cmdio.Render(ctx, newUploadCompleteEvent(progressEvent.Path, remotePath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ func Create(repoRoot, localRoot string, w *databricks.WorkspaceClient, opts *Rep
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RepoFiles) RemotePath(relativePath string) (string, error) {
|
func (r *RepoFiles) remotePath(relativePath string) (string, error) {
|
||||||
fullPath := path.Join(r.repoRoot, relativePath)
|
fullPath := path.Join(r.repoRoot, relativePath)
|
||||||
cleanFullPath := path.Clean(fullPath)
|
cleanFullPath := path.Clean(fullPath)
|
||||||
if !strings.HasPrefix(cleanFullPath, r.repoRoot) {
|
if !strings.HasPrefix(cleanFullPath, r.repoRoot) {
|
||||||
|
@ -82,7 +82,7 @@ func (r *RepoFiles) writeRemote(ctx context.Context, relativePath string, conten
|
||||||
// files, folders and notebooks might not have been cleaned up and they
|
// files, folders and notebooks might not have been cleaned up and they
|
||||||
// can't overwrite each other. If a folder `foo` exists, then attempts to
|
// can't overwrite each other. If a folder `foo` exists, then attempts to
|
||||||
// PUT a file `foo` will fail
|
// PUT a file `foo` will fail
|
||||||
remotePath, err := r.RemotePath(relativePath)
|
remotePath, err := r.remotePath(relativePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,66 +14,66 @@ func TestRepoFilesRemotePath(t *testing.T) {
|
||||||
repoFiles, err := Create(repoRoot, "/doraemon/foo/bar", nil, nil)
|
repoFiles, err := Create(repoRoot, "/doraemon/foo/bar", nil, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
remotePath, err := repoFiles.RemotePath("a/b/c")
|
remotePath, err := repoFiles.remotePath("a/b/c")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, repoRoot+"/a/b/c", remotePath)
|
assert.Equal(t, repoRoot+"/a/b/c", remotePath)
|
||||||
|
|
||||||
remotePath, err = repoFiles.RemotePath("a/b/../d")
|
remotePath, err = repoFiles.remotePath("a/b/../d")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, repoRoot+"/a/d", remotePath)
|
assert.Equal(t, repoRoot+"/a/d", remotePath)
|
||||||
|
|
||||||
remotePath, err = repoFiles.RemotePath("a/../c")
|
remotePath, err = repoFiles.remotePath("a/../c")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, repoRoot+"/c", remotePath)
|
assert.Equal(t, repoRoot+"/c", remotePath)
|
||||||
|
|
||||||
remotePath, err = repoFiles.RemotePath("a/b/c/.")
|
remotePath, err = repoFiles.remotePath("a/b/c/.")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, repoRoot+"/a/b/c", remotePath)
|
assert.Equal(t, repoRoot+"/a/b/c", remotePath)
|
||||||
|
|
||||||
remotePath, err = repoFiles.RemotePath("a/b/c/d/./../../f/g")
|
remotePath, err = repoFiles.remotePath("a/b/c/d/./../../f/g")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, repoRoot+"/a/b/f/g", remotePath)
|
assert.Equal(t, repoRoot+"/a/b/f/g", remotePath)
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath("..")
|
_, err = repoFiles.remotePath("..")
|
||||||
assert.ErrorContains(t, err, `relative file path is not inside repo root: ..`)
|
assert.ErrorContains(t, err, `relative file path is not inside repo root: ..`)
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath("a/../..")
|
_, err = repoFiles.remotePath("a/../..")
|
||||||
assert.ErrorContains(t, err, `relative file path is not inside repo root: a/../..`)
|
assert.ErrorContains(t, err, `relative file path is not inside repo root: a/../..`)
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath("./../.")
|
_, err = repoFiles.remotePath("./../.")
|
||||||
assert.ErrorContains(t, err, `relative file path is not inside repo root: ./../.`)
|
assert.ErrorContains(t, err, `relative file path is not inside repo root: ./../.`)
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath("/./.././..")
|
_, err = repoFiles.remotePath("/./.././..")
|
||||||
assert.ErrorContains(t, err, `relative file path is not inside repo root: /./.././..`)
|
assert.ErrorContains(t, err, `relative file path is not inside repo root: /./.././..`)
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath("./../.")
|
_, err = repoFiles.remotePath("./../.")
|
||||||
assert.ErrorContains(t, err, `relative file path is not inside repo root: ./../.`)
|
assert.ErrorContains(t, err, `relative file path is not inside repo root: ./../.`)
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath("./..")
|
_, err = repoFiles.remotePath("./..")
|
||||||
assert.ErrorContains(t, err, `relative file path is not inside repo root: ./..`)
|
assert.ErrorContains(t, err, `relative file path is not inside repo root: ./..`)
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath("./../../..")
|
_, err = repoFiles.remotePath("./../../..")
|
||||||
assert.ErrorContains(t, err, `relative file path is not inside repo root: ./../../..`)
|
assert.ErrorContains(t, err, `relative file path is not inside repo root: ./../../..`)
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath("./../a/./b../../..")
|
_, err = repoFiles.remotePath("./../a/./b../../..")
|
||||||
assert.ErrorContains(t, err, `relative file path is not inside repo root: ./../a/./b../../..`)
|
assert.ErrorContains(t, err, `relative file path is not inside repo root: ./../a/./b../../..`)
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath("../..")
|
_, err = repoFiles.remotePath("../..")
|
||||||
assert.ErrorContains(t, err, `relative file path is not inside repo root: ../..`)
|
assert.ErrorContains(t, err, `relative file path is not inside repo root: ../..`)
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath(".//a/..//./b/..")
|
_, err = repoFiles.remotePath(".//a/..//./b/..")
|
||||||
assert.ErrorContains(t, err, `file path relative to repo root cannot be empty`)
|
assert.ErrorContains(t, err, `file path relative to repo root cannot be empty`)
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath("a/b/../..")
|
_, err = repoFiles.remotePath("a/b/../..")
|
||||||
assert.ErrorContains(t, err, "file path relative to repo root cannot be empty")
|
assert.ErrorContains(t, err, "file path relative to repo root cannot be empty")
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath("")
|
_, err = repoFiles.remotePath("")
|
||||||
assert.ErrorContains(t, err, "file path relative to repo root cannot be empty")
|
assert.ErrorContains(t, err, "file path relative to repo root cannot be empty")
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath(".")
|
_, err = repoFiles.remotePath(".")
|
||||||
assert.ErrorContains(t, err, "file path relative to repo root cannot be empty")
|
assert.ErrorContains(t, err, "file path relative to repo root cannot be empty")
|
||||||
|
|
||||||
_, err = repoFiles.RemotePath("/")
|
_, err = repoFiles.remotePath("/")
|
||||||
assert.ErrorContains(t, err, "file path relative to repo root cannot be empty")
|
assert.ErrorContains(t, err, "file path relative to repo root cannot be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,14 +135,6 @@ func (s *Sync) notifyComplete(ctx context.Context, d diff) {
|
||||||
s.seq++
|
s.seq++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sync) RemotePath(localPath string) (string, error) {
|
|
||||||
relativePath, ok := s.snapshot.LocalToRemoteNames[localPath]
|
|
||||||
if !ok {
|
|
||||||
return "", fmt.Errorf("could not find remote path for %s", localPath)
|
|
||||||
}
|
|
||||||
return s.repoFiles.RemotePath(relativePath)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Sync) RunOnce(ctx context.Context) error {
|
func (s *Sync) RunOnce(ctx context.Context) error {
|
||||||
// tradeoff: doing portable monitoring only due to macOS max descriptor manual ulimit setting requirement
|
// tradeoff: doing portable monitoring only due to macOS max descriptor manual ulimit setting requirement
|
||||||
// https://github.com/gorakhargosh/watchdog/blob/master/src/watchdog/observers/kqueue.py#L394-L418
|
// https://github.com/gorakhargosh/watchdog/blob/master/src/watchdog/observers/kqueue.py#L394-L418
|
||||||
|
|
Loading…
Reference in New Issue