mirror of https://github.com/databricks/cli.git
address PR feedback
This commit is contained in:
parent
84d1bbf2d5
commit
6bf59ff981
|
@ -141,8 +141,7 @@ func Detect(name string) (notebook bool, language workspace.Language, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type inMemoryFile struct {
|
type inMemoryFile struct {
|
||||||
content []byte
|
buffer bytes.Buffer
|
||||||
readIndex int64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type inMemoryFS struct {
|
type inMemoryFS struct {
|
||||||
|
@ -158,20 +157,12 @@ func (f *inMemoryFile) Stat() (fs.FileInfo, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *inMemoryFile) Read(b []byte) (n int, err error) {
|
func (f *inMemoryFile) Read(b []byte) (n int, err error) {
|
||||||
if f.readIndex >= int64(len(f.content)) {
|
return f.buffer.Read(b)
|
||||||
err = io.EOF
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
n = copy(b, f.content[f.readIndex:])
|
|
||||||
f.readIndex += int64(n)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs inMemoryFS) Open(name string) (fs.File, error) {
|
func (fs inMemoryFS) Open(name string) (fs.File, error) {
|
||||||
return &inMemoryFile{
|
return &inMemoryFile{
|
||||||
content: fs.content,
|
buffer: *bytes.NewBuffer(fs.content),
|
||||||
readIndex: 0,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,6 +153,7 @@ func (r *renderer) computeFile(relPathTemplate string) (file, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we need the absolute path in case we need to write notebooks using the REST API
|
||||||
rootPath, err := filepath.Abs(r.instanceRoot)
|
rootPath, err := filepath.Abs(r.instanceRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue