databricks-cli/libs/template/materialize.go

27 lines
653 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
const ConfigFileName = "config.json"
2023-05-21 20:48:38 +00:00
const schemaFileName = "schema.json"
const templateDirName = "template"
2023-05-21 20:37:38 +00:00
2023-05-22 03:58:05 +00:00
func Materialize(templatePath, instancePath, configPath string) error {
2023-05-21 20:37:38 +00:00
// read the file containing schema for template input parameters
2023-05-21 20:48:38 +00:00
schema, err := ReadSchema(filepath.Join(templatePath, 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
2023-05-21 20:48:38 +00:00
return WalkFileTree(config, filepath.Join(templatePath, templateDirName), instancePath)
2023-05-21 20:37:38 +00:00
}