databricks-cli/libs/template/materialize.go

26 lines
616 B
Go
Raw Normal View History

2023-05-21 20:37:38 +00:00
package template
2023-05-21 20:48:38 +00:00
import (
"path/filepath"
)
2023-05-21 20:37:38 +00:00
2023-05-21 20:48:38 +00:00
const schemaFileName = "schema.json"
const templateDirName = "template"
2023-05-21 20:37:38 +00:00
func Materialize(templateRoot, instanceRoot, configPath string) error {
2023-05-21 20:37:38 +00:00
// read the file containing schema for template input parameters
schema, err := ReadSchema(filepath.Join(templateRoot, schemaFileName))
2023-05-21 20:37:38 +00:00
if err != nil {
return err
}
// read user config to initalize the template with
2023-05-22 03:58:05 +00:00
config, err := schema.ReadConfig(configPath)
2023-05-21 20:37:38 +00:00
if err != nil {
return err
}
// materialize the template
return walkFileTree(config, filepath.Join(templateRoot, templateDirName), instanceRoot)
2023-05-21 20:37:38 +00:00
}