From 133881b2dfc29f5b24bb28374e7c09f13d3bd7e8 Mon Sep 17 00:00:00 2001 From: monalisa Date: Wed, 16 Aug 2023 19:03:35 +0200 Subject: [PATCH 1/4] Add template directory flag for bundle templates --- cmd/bundle/init.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/bundle/init.go b/cmd/bundle/init.go index e3d76ecf28..b3ca166819 100644 --- a/cmd/bundle/init.go +++ b/cmd/bundle/init.go @@ -43,8 +43,10 @@ func newInitCommand() *cobra.Command { var configFile string var projectDir string + var templateDir string cmd.Flags().StringVar(&configFile, "config-file", "", "File containing input parameters for template initialization.") cmd.Flags().StringVar(&projectDir, "project-dir", "", "The project will be initialized in this directory.") + cmd.Flags().StringVar(&templateDir, "template-directory", "", "Directory within repository that holds the template specification. This is useful when TEMPLATE_PATH is a repository containing multiple templates.") cmd.MarkFlagRequired("project-dir") cmd.RunE = func(cmd *cobra.Command, args []string) error { @@ -60,19 +62,18 @@ func newInitCommand() *cobra.Command { // Download the template in a temporary directory tmpDir := os.TempDir() templateURL := templatePath - templateDir := filepath.Join(tmpDir, repoName(templateURL)) - err := os.MkdirAll(templateDir, 0755) + repoDir := filepath.Join(tmpDir, repoName(templateURL)) + err := os.MkdirAll(repoDir, 0755) if err != nil { return err } // TODO: Add automated test that the downloaded git repo is cleaned up. - err = git.Clone(ctx, templateURL, "", templateDir) + err = git.Clone(ctx, templateURL, "", repoDir) if err != nil { return err } - defer os.RemoveAll(templateDir) - - return template.Materialize(ctx, configFile, templateDir, projectDir) + defer os.RemoveAll(repoDir) + return template.Materialize(ctx, configFile, filepath.Join(repoDir, templateDir), projectDir) } return cmd From 25128082a0d81889c3ac4c7907252b728fc41e3d Mon Sep 17 00:00:00 2001 From: monalisa Date: Wed, 16 Aug 2023 19:07:17 +0200 Subject: [PATCH 2/4] - --- cmd/bundle/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/bundle/init.go b/cmd/bundle/init.go index b3ca166819..1b744c56ff 100644 --- a/cmd/bundle/init.go +++ b/cmd/bundle/init.go @@ -46,7 +46,7 @@ func newInitCommand() *cobra.Command { var templateDir string cmd.Flags().StringVar(&configFile, "config-file", "", "File containing input parameters for template initialization.") cmd.Flags().StringVar(&projectDir, "project-dir", "", "The project will be initialized in this directory.") - cmd.Flags().StringVar(&templateDir, "template-directory", "", "Directory within repository that holds the template specification. This is useful when TEMPLATE_PATH is a repository containing multiple templates.") + cmd.Flags().StringVar(&templateDir, "template-directory", "", "Directory within repository that holds the template specification, that is the databricks_template_schema.json file.") cmd.MarkFlagRequired("project-dir") cmd.RunE = func(cmd *cobra.Command, args []string) error { From e572ab12dee7036c4cc6246cac3a03acfa281f6a Mon Sep 17 00:00:00 2001 From: monalisa Date: Wed, 16 Aug 2023 19:08:09 +0200 Subject: [PATCH 3/4] - --- cmd/bundle/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/bundle/init.go b/cmd/bundle/init.go index 1b744c56ff..0ac8b9b316 100644 --- a/cmd/bundle/init.go +++ b/cmd/bundle/init.go @@ -46,7 +46,7 @@ func newInitCommand() *cobra.Command { var templateDir string cmd.Flags().StringVar(&configFile, "config-file", "", "File containing input parameters for template initialization.") cmd.Flags().StringVar(&projectDir, "project-dir", "", "The project will be initialized in this directory.") - cmd.Flags().StringVar(&templateDir, "template-directory", "", "Directory within repository that holds the template specification, that is the databricks_template_schema.json file.") + cmd.Flags().StringVar(&templateDir, "template-directory", "", "Directory within repository that holds the template specification.") cmd.MarkFlagRequired("project-dir") cmd.RunE = func(cmd *cobra.Command, args []string) error { From 06c030837a7202396d321b0854b304633dcc5c66 Mon Sep 17 00:00:00 2001 From: monalisa Date: Thu, 17 Aug 2023 22:34:08 +0200 Subject: [PATCH 4/4] rename directory -> dir --- cmd/bundle/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/bundle/init.go b/cmd/bundle/init.go index 0ac8b9b316..21dd24f562 100644 --- a/cmd/bundle/init.go +++ b/cmd/bundle/init.go @@ -46,7 +46,7 @@ func newInitCommand() *cobra.Command { var templateDir string cmd.Flags().StringVar(&configFile, "config-file", "", "File containing input parameters for template initialization.") cmd.Flags().StringVar(&projectDir, "project-dir", "", "The project will be initialized in this directory.") - cmd.Flags().StringVar(&templateDir, "template-directory", "", "Directory within repository that holds the template specification.") + cmd.Flags().StringVar(&templateDir, "template-dir", "", "Directory within repository that holds the template specification.") cmd.MarkFlagRequired("project-dir") cmd.RunE = func(cmd *cobra.Command, args []string) error {