mirror of https://github.com/databricks/cli.git
added flag for config file location
This commit is contained in:
parent
a21fbdd383
commit
350053487a
|
@ -1,6 +1,8 @@
|
|||
package bundle
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/databricks/cli/libs/template"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -11,13 +13,19 @@ var initCmd = &cobra.Command{
|
|||
Long: `Initialize template`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
// initialize default value for config file path
|
||||
if configFile == "" {
|
||||
configFile = filepath.Join(targetDir, template.ConfigFileName)
|
||||
}
|
||||
return template.Materialize(args[0], targetDir)
|
||||
},
|
||||
}
|
||||
|
||||
var targetDir string
|
||||
var configFile string
|
||||
|
||||
func init() {
|
||||
initCmd.Flags().StringVar(&targetDir, "target-dir", ".", "path to directory template will be initialized in")
|
||||
initCmd.Flags().StringVar(&configFile, "config-file", "", "path to config to use for template initialization")
|
||||
AddCommand(initCmd)
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package template
|
||||
|
||||
import "path/filepath"
|
||||
import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
const ConfigFileName = "config.json"
|
||||
const SchemaFileName = "schema.json"
|
||||
const TemplateDirName = "template"
|
||||
const schemaFileName = "schema.json"
|
||||
const templateDirName = "template"
|
||||
|
||||
func Materialize(templatePath, instancePath string) error {
|
||||
// read the file containing schema for template input parameters
|
||||
schema, err := ReadSchema(filepath.Join(templatePath, SchemaFileName))
|
||||
schema, err := ReadSchema(filepath.Join(templatePath, schemaFileName))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -20,5 +22,5 @@ func Materialize(templatePath, instancePath string) error {
|
|||
}
|
||||
|
||||
// materialize the template
|
||||
return WalkFileTree(config, filepath.Join(templatePath, TemplateDirName), instancePath)
|
||||
return WalkFileTree(config, filepath.Join(templatePath, templateDirName), instancePath)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue