mirror of https://github.com/databricks/cli.git
move walker to a separate library
This commit is contained in:
parent
9ef3547a3a
commit
4b7a606d72
|
@ -6,6 +6,7 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"github.com/databricks/bricks/cmd/root"
|
||||
"github.com/databricks/bricks/libs/template"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -26,7 +27,7 @@ var initCmd = &cobra.Command{
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
schema := Schema{}
|
||||
schema := template.Schema{}
|
||||
err = json.Unmarshal(schemaBytes, &schema)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -57,7 +58,7 @@ var initCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
// materialize the template
|
||||
return walkFileTree(config, filepath.Join(args[0], TemplateDirname), ".")
|
||||
return template.WalkFileTree(config, filepath.Join(args[0], TemplateDirname), ".")
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package init
|
||||
package template
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
@ -64,7 +64,7 @@ func generateFile(config map[string]any, parentDir, nameTempate, contentTemplate
|
|||
return err
|
||||
}
|
||||
|
||||
func walkFileTree(config map[string]any, templatePath, instancePath string) error {
|
||||
func WalkFileTree(config map[string]any, templatePath, instancePath string) error {
|
||||
enteries, err := os.ReadDir(templatePath)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -79,7 +79,7 @@ func walkFileTree(config map[string]any, templatePath, instancePath string) erro
|
|||
|
||||
// recusive generate files and directories inside inside our newly generated
|
||||
// directory from the template defination
|
||||
err = walkFileTree(config, filepath.Join(templatePath, entry.Name()), filepath.Join(instancePath, dirName))
|
||||
err = WalkFileTree(config, filepath.Join(templatePath, entry.Name()), filepath.Join(instancePath, dirName))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package init
|
||||
package template
|
||||
|
||||
import (
|
||||
"errors"
|
|
@ -1,4 +1,4 @@
|
|||
package init
|
||||
package template
|
||||
|
||||
import (
|
||||
"fmt"
|
Loading…
Reference in New Issue